From 6d0cca47478cb9cce56bfc41be18b0594f9b6398 Mon Sep 17 00:00:00 2001 From: XProger Date: Wed, 9 Jan 2019 06:00:07 +0300 Subject: [PATCH] #15 fix touch screen A/B buttons in the inventory; fix single/two players mode switching --- src/inventory.h | 2 ++ src/platform/nx/main.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/inventory.h b/src/inventory.h index 6b5eac4c..ab523567 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -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) diff --git a/src/platform/nx/main.cpp b/src/platform/nx/main.cpp index 72235290..95528116 100644 --- a/src/platform/nx/main.cpp +++ b/src/platform/nx/main.cpp @@ -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) { @@ -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(); } }