diff --git a/win32/rsrc/resource.h b/win32/rsrc/resource.h index 07389e60..2f46d864 100644 --- a/win32/rsrc/resource.h +++ b/win32/rsrc/resource.h @@ -485,6 +485,7 @@ #define ID_DEBUG_APU_TRACE 40173 #define ID_EMULATION_BACKGROUNDINPUT 40174 #define ID_SAVEMEMPACK 40175 +#define ID_INPUT_BACKGROUNDKEYBOARDHOTKEYS 40176 #define ID_FILE_SAVE0 44000 #define ID_FILE_SAVE1 44001 #define ID_FILE_SAVE2 44002 @@ -513,8 +514,8 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 154 -#define _APS_NEXT_COMMAND_VALUE 40176 +#define _APS_NEXT_RESOURCE_VALUE 155 +#define _APS_NEXT_COMMAND_VALUE 40178 #define _APS_NEXT_CONTROL_VALUE 3022 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/win32/rsrc/snes9x.rc b/win32/rsrc/snes9x.rc index 90ccdaec..33b0801f 100644 --- a/win32/rsrc/snes9x.rc +++ b/win32/rsrc/snes9x.rc @@ -880,6 +880,7 @@ BEGIN MENUITEM "&Customize Hotkeys...\tAlt+F9", ID_OPTIONS_KEYCUSTOM MENUITEM SEPARATOR MENUITEM "Enable Background Input", ID_EMULATION_BACKGROUNDINPUT + MENUITEM "Background Keyboard Hotkeys", ID_INPUT_BACKGROUNDKEYBOARDHOTKEYS MENUITEM SEPARATOR MENUITEM "Use SNES Joypad(s)", IDM_SNES_JOYPAD MENUITEM "Use SNES Mouse", IDM_MOUSE_TOGGLE diff --git a/win32/wconfig.cpp b/win32/wconfig.cpp index 0646a97b..707b6a64 100644 --- a/win32/wconfig.cpp +++ b/win32/wconfig.cpp @@ -1042,6 +1042,7 @@ void WinRegisterConfigItems() #undef ADDTN #undef ADD2T2 AddBool2C("Input:Background", GUI.BackgroundInput, false, "on to detect game keypresses and hotkeys while window is inactive, if PauseWhenInactive = FALSE."); + AddBool2C("Input:BackgroundKeyHotkeys", GUI.BackgroundKeyHotkeys, true, "on to also detect keyboard hotkeys when backgroundinput is active"); #undef CATEGORY #define CATEGORY "Controls\\Win\\Hotkeys" AddBool2C("Handler:Joystick", GUI.JoystickHotkeys, true, "on to detect game controller buttons assigned to hotkeys. May impact performance."); diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index b2251d38..84d55242 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -971,6 +971,12 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam) bool hitHotKey = false; + // if this is not a gamepad press and background hotkeys are disabled, skip it if we do not have focus + if (!GUI.BackgroundKeyHotkeys && !(wParam & 0x8000) && GUI.hWnd != GetForegroundWindow()) + { + return 0; + } + if(!(wParam == 0 || wParam == VK_ESCAPE)) // if it's the 'disabled' key, it's never pressed as a hotkey { int modifiers = 0; @@ -1934,6 +1940,10 @@ LRESULT CALLBACK WinProc( GUI.hHotkeyTimer = timeSetEvent (32, 0, (LPTIMECALLBACK)HotkeyTimer, 0, TIME_PERIODIC); break; + case ID_INPUT_BACKGROUNDKEYBOARDHOTKEYS: + GUI.BackgroundKeyHotkeys = !GUI.BackgroundKeyHotkeys; + break; + case ID_FILE_LOADMULTICART: { RestoreGUIDisplay (); @@ -4018,6 +4028,11 @@ static void CheckMenuStates () mii.fState = GUI.BackgroundInput ? MFS_CHECKED : MFS_UNCHECKED; SetMenuItemInfo (GUI.hMenu, ID_EMULATION_BACKGROUNDINPUT, FALSE, &mii); + mii.fState = GUI.BackgroundKeyHotkeys ? MFS_CHECKED : MFS_UNCHECKED; + if (!GUI.BackgroundInput) + mii.fState |= MFS_DISABLED; + SetMenuItemInfo(GUI.hMenu, ID_INPUT_BACKGROUNDKEYBOARDHOTKEYS, FALSE, &mii); + UINT validFlag; ControllerOptionsFromControllers(); diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h index 05c2dada..66a9a067 100644 --- a/win32/wsnes9x.h +++ b/win32/wsnes9x.h @@ -374,6 +374,7 @@ struct sGUI { int ValidControllerOptions; int SoundChannelEnable; bool BackgroundInput; + bool BackgroundKeyHotkeys; bool JoystickHotkeys; bool MovieClearSRAM; bool MovieStartFromReset;