From 1ad9a3d857eb4fa39bebe665009c8fff1b6c8223 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 8 Oct 2022 09:56:49 -0400 Subject: [PATCH] For Qt GUI, added logic to prevent controller buttons that are bound to the keyboard from being active when family keyboard is enabled. Controller buttons that are mapped to physical gamepad or joystick are unaffected. For issue #572. --- src/drivers/Qt/input.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index 9bddbc7c..ff4c4f34 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -65,7 +65,7 @@ static int cspec = 0; static int buttonConfigInProgress = 0; extern int gametype; -static int DTestButton(ButtConfig *bc); +static int DTestButton(ButtConfig *bc, bool isFKB = false); //std::list gpKeySeqList; @@ -1416,12 +1416,18 @@ void ButtonConfigEnd() * Tests to see if a specified button is currently pressed. */ static int -DTestButton(ButtConfig *bc) +DTestButton(ButtConfig *bc, bool isFKB) { - if (bc->ButtType == BUTTC_KEYBOARD) { - if (g_keyState[SDL_GetScancodeFromKey(bc->ButtonNum)]) + bool ignoreKB = false; + bool fkbActv = g_fkbEnabled && (CurInputType[2] == SIFC_FKB); + + if (fkbActv) + { + ignoreKB = !isFKB; + } + if (!ignoreKB && g_keyState[SDL_GetScancodeFromKey(bc->ButtonNum)]) { bc->state = 1; return 1; @@ -1753,6 +1759,10 @@ void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, CurInputType[1] = port1; CurInputType[2] = fcexp; } + if (CurInputType[2] != SIFC_FKB) + { + g_fkbEnabled = false; + } replaceP2StartWithMicrophone = microphone; @@ -1880,7 +1890,7 @@ static void UpdateFKB(void) vkeyDown = getFamilyKeyboardVirtualKey(50); - leftShiftDown = DTestButton(&fkbmap[50]) || vkeyDown; + leftShiftDown = DTestButton(&fkbmap[50], true) || vkeyDown; for (x = 0; x < FAMILYKEYBOARD_NUM_BUTTONS; x++) { @@ -1896,7 +1906,7 @@ static void UpdateFKB(void) vkeyDown = getFamilyKeyboardVirtualKey(x); - if (DTestButton(&fkbmap[x]) || vkeyDown) + if (DTestButton(&fkbmap[x], true) || vkeyDown) { fkbkeys[x] = 1;