Skip to content

Commit

Permalink
#15 fix touch screen A/B buttons in the inventory; fix single/two pla…
Browse files Browse the repository at this point in the history
…yers mode switching
  • Loading branch information
XProger committed Jan 9, 2019
1 parent 227cd3c commit 6d0cca4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -1156,11 +1156,13 @@ struct Inventory {

#ifdef _OS_NX
// swap A/B keys for Nintendo (Japanese) UX style
if (Input::touchTimerVis == 0.0f) {
if (key == cAction) {
key = cInventory;
} else if (key == cInventory) {
key = cAction;
}
}
#endif

if (Input::lastState[playerIndex] == cInventory)
Expand Down
16 changes: 9 additions & 7 deletions src/platform/nx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,12 @@ void joyUpdate() {

hidScanInput();

u64 mDown = 0;
bool waitForSplit = false;

for (int i = 0; i < (joyIsSplit ? 2 : 1); i++) {
HidControllerID ctrl = (i == 0 ? CONTROLLER_P1_AUTO : CONTROLLER_PLAYER_2);

u64 mask = hidKeysDown(ctrl) | hidKeysHeld(ctrl);
mDown |= mask;

for (int j = 1; j < jkMAX; j++) {
if (j != jkSelect && j != jkStart) {
Expand All @@ -244,13 +243,16 @@ void joyUpdate() {
hidJoystickRead(&sR, ctrl, JOYSTICK_RIGHT);
Input::setJoyPos(i, jkL, vec2(float(sL.dx), float(-sL.dy)) / 32767.0f);
Input::setJoyPos(i, jkR, vec2(float(sR.dx), float(-sR.dy)) / 32767.0f);

if ((mask & (KEY_L | KEY_R)) == (KEY_L | KEY_R)) { // hold L and R to split/merge joy-con's
if (joySplitTime + 1000 < osGetTime()) { // 1 sec timer
joySplit(!joyIsSplit);
}
waitForSplit = true;
}
}

if ((mDown & (KEY_L | KEY_R)) == (KEY_L | KEY_R)) { // hold L and R to split/merge joy-con's
if (joySplitTime + 1000 < osGetTime()) { // 1 sec timer
joySplit(!joyIsSplit);
}
} else {
if (!waitForSplit) {
joySplitTime = osGetTime();
}
}
Expand Down

0 comments on commit 6d0cca4

Please sign in to comment.