From 5919d664eeb1ad08fc356cf0d26d027f4d1cc486 Mon Sep 17 00:00:00 2001 From: gocha Date: Sat, 18 Sep 2010 04:51:50 +0000 Subject: [PATCH] 0.9.6: backport "background input" from trunk --- desmume/src/lua-engine.cpp | 4 ++-- desmume/src/windows/inputdx.cpp | 5 +++-- desmume/src/windows/main.cpp | 11 +++++++++++ desmume/src/windows/resource.h | 1 + desmume/src/windows/resources.rc | Bin 932394 -> 933086 bytes 5 files changed, 17 insertions(+), 4 deletions(-) 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 bbb9e7e042f63b8fa09aa9f034ef753f8d4448f7..31217b426f09de8de6084acbd2cf152c60d6fffc 100644 GIT binary patch delta 247 zcmZ4W#p2#ii-s1)EllfHOT|rJWU$`gn89L$YX(kfc?PM0vx6oX7=~E+t;mT`L=Vqp9Z(s^d)zAjV6D{WI-rxpODH5#BAFq zq_PWrf~aC~;ZU3WK!F3H3T)u?8yeg>(*@F4#oAROIDnXQyGjJtmJ4__wF5N)G0*lJ a8oW6ta4DU}1a#bqJKTKRLq76e^8f%r3tvP4 delta 75 zcmccj(_+;Zi-s1)EllfHw;Qct0%GRvMr&BU?QGwb#tOu2+jph0|NGeP6v+X^oZFou bxy&xMGih@JG0%1;ZQh&{+kbrKedYlG78)RM