diff --git a/desmume/src/lua-engine.cpp b/desmume/src/lua-engine.cpp index 901c13966..df74d1647 100644 --- a/desmume/src/lua-engine.cpp +++ b/desmume/src/lua-engine.cpp @@ -3655,10 +3655,10 @@ DEFINE_LUA_FUNCTION(input_getcurrentinputstatus, "") #if defined(_WIN32) && !defined(WXPORT) // keyboard and mouse button status { - int BackgroundInput = 0;//TODO + extern bool allowBackgroundInput; unsigned char keys [256]; - if(!BackgroundInput) + if(!allowBackgroundInput) { if(GetKeyboardState(keys)) { diff --git a/desmume/src/windows/inputdx.cpp b/desmume/src/windows/inputdx.cpp index da5567ed8..46ab8eaf7 100644 --- a/desmume/src/windows/inputdx.cpp +++ b/desmume/src/windows/inputdx.cpp @@ -252,6 +252,7 @@ SGuitar Guitar; u8 guitarState = 0; bool allowUpAndDown = false; +bool allowBackgroundInput = false; extern volatile bool paused; @@ -415,6 +416,7 @@ static void LoadInputConfig() #undef DO allowUpAndDown = GetPrivateProfileInt("Controls","AllowUpAndDown",0,IniName) != 0; + allowBackgroundInput = GetPrivateProfileInt("Controls","AllowBackgroundInput",0,IniName) != 0; } static void WriteControl(char* name, WORD val) @@ -2142,8 +2144,7 @@ bool S9xGetState (WORD KeyIdent) if(KeyIdent == 0 || KeyIdent == 0xFF || KeyIdent == VK_ESCAPE) // if it's the 'disabled' key, it's never pressed return true; - //TODO - option for background game keys - if(MainWindow->getHWnd() != GetForegroundWindow()) + if(!allowBackgroundInput && MainWindow->getHWnd() != GetForegroundWindow()) return true; if (KeyIdent & 0x8000) // if it's a joystick 'key': diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index f66ab5400..6648c03d2 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -277,6 +277,7 @@ extern HWND RamSearchHWnd; static bool lostFocusPause = true; static bool lastPauseFromLostFocus = false; static bool FrameLimit = true; +extern bool allowBackgroundInput; std::vector LuaScriptHWnds; LRESULT CALLBACK LuaScriptProc(HWND, UINT, WPARAM, LPARAM); @@ -3663,6 +3664,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM DesEnableMenuItem(mainMenu, ID_RAM_WATCH, romloaded); DesEnableMenuItem(mainMenu, ID_RAM_SEARCH, romloaded); + DesEnableMenuItem(mainMenu, IDC_BACKGROUNDINPUT, !lostFocusPause); + //Update savestate slot items based on ROM loaded for (int x = 0; x < 10; x++) { @@ -3779,6 +3782,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(ID_DISPLAYMETHOD_DIRECTDRAWSW, (GetStyle()&DWS_DDRAW_SW)!=0); MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, lostFocusPause); + MainWindow->checkMenu(IDC_BACKGROUNDINPUT, allowBackgroundInput); MainWindow->checkMenu(IDM_CHEATS_DISABLE, CommonSettings.cheatsDisable == true); @@ -4921,7 +4925,14 @@ DOKEYDOWN: case IDC_BACKGROUNDPAUSE: lostFocusPause = !lostFocusPause; + allowBackgroundInput &= !lostFocusPause; WritePrivateProfileInt("Focus", "BackgroundPause", (int)lostFocusPause, IniName); + WritePrivateProfileInt("Controls", "AllowBackgroundInput", (int)allowBackgroundInput, IniName); + return 0; + + case IDC_BACKGROUNDINPUT: + allowBackgroundInput = !allowBackgroundInput; + WritePrivateProfileInt("Controls", "AllowBackgroundInput", (int)allowBackgroundInput, IniName); return 0; case ID_DISPLAYMETHOD_DIRECTDRAWHW: diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 99fd44246..49c868a41 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -106,6 +106,7 @@ #define IDC_16_BIT 303 #define IDC_32_BIT 304 #define IDC_BACKGROUNDPAUSE 305 +#define IDC_BACKGROUNDINPUT 306 #define IDC_LUACONSOLE 309 #define IDC_EDIT_LUAPATH 310 #define IDC_BUTTON_LUARUN 311 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index bbb9e7e04..31217b426 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ