diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 79d4051f..0bd7a497 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -577,6 +577,7 @@ void consoleWin_t::initHotKeys(void) connect( Hotkeys[ HK_TOGGLE_INPUT_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleInputDisplay(void)) ); connect( Hotkeys[ HK_TOGGLE_BG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleBackground(void)) ); connect( Hotkeys[ HK_TOGGLE_FG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleForeground(void)) ); + connect( Hotkeys[ HK_FKB_ENABLE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleFamKeyBrdEnable(void)) ); connect( Hotkeys[ HK_SAVE_STATE_0 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState0(void)) ); connect( Hotkeys[ HK_SAVE_STATE_1 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState1(void)) ); @@ -2375,6 +2376,11 @@ void consoleWin_t::toggleFullscreen(void) } } +void consoleWin_t::toggleFamKeyBrdEnable(void) +{ + toggleFamilyKeyboardFunc(); +} + void consoleWin_t::powerConsoleCB(void) { fceuWrapperLock(); diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index b9fe1ae4..896a62b5 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -317,6 +317,7 @@ class consoleWin_t : public QMainWindow void toggleTurboMode(void); void toggleBackground(void); void toggleForeground(void); + void toggleFamKeyBrdEnable(void); void saveState0(void); void saveState1(void); void saveState2(void); diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index 1ca013f8..af2b8ac3 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -195,7 +195,7 @@ _keyonly (int a) #define keyonly(__a) _keyonly(MKK(__a)) -static int g_fkbEnabled = 0; +static bool g_fkbEnabled = false; // this function loads the sdl hotkeys from the config file into the // global scope. this elimates the need for accessing the config file @@ -670,24 +670,66 @@ unsigned int *GetKeyboard(void) return (unsigned int*)(keystate); } +static void FKB_CheckShortcutConflicts(void) +{ + bool fkbActv; + QShortcut *shortcut; + + fkbActv = g_fkbEnabled && (CurInputType[2] == SIFC_FKB); + + for (int i=0; isetEnabled(true); + } + continue; + } + + if ( shortcut ) + { + shortcut->setEnabled( !fkbActv ); + } + } + +} + +void toggleFamilyKeyboardFunc(void) +{ + if (CurInputType[2] == SIFC_FKB) + { + g_fkbEnabled = !g_fkbEnabled; + + FCEUI_DispMessage ("Family Keyboard %sabled.", 0, + g_fkbEnabled ? "En" : "Dis"); + } + else + { + FCEUI_DispMessage ("Family Keyboard Not Active", 0); + g_fkbEnabled = false; + } + FKB_CheckShortcutConflicts(); +} + +bool isFamilyKeyboardActv(void) +{ + return ( (CurInputType[2] == SIFC_FKB) && g_fkbEnabled ); +} + /** * Parse keyboard commands and execute accordingly. */ static void KeyboardCommands (void) { - //int is_shift, is_alt; - // get the keyboard input // check if the family keyboard is enabled if (CurInputType[2] == SIFC_FKB) { - if ( Hotkeys[HK_FKB_ENABLE].getRisingEdge() ) - { - g_fkbEnabled ^= 1; - FCEUI_DispMessage ("Family Keyboard %sabled.", 0, - g_fkbEnabled ? "en" : "dis"); - } if (g_fkbEnabled) { return; diff --git a/src/drivers/Qt/input.h b/src/drivers/Qt/input.h index 3f5a8d86..e2d92d77 100644 --- a/src/drivers/Qt/input.h +++ b/src/drivers/Qt/input.h @@ -137,6 +137,8 @@ const char* ButtonName(const ButtConfig* bc); int getInputSelection( int port, int *cur, int *usr ); int saveInputSettingsToFile( const char *fileBase = NULL ); int loadInputSettingsFromFile( const char *filename = NULL ); +void toggleFamilyKeyboardFunc(void); +bool isFamilyKeyboardActv(void); #endif