diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index 437f2227f9..c360e38b08 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -208,6 +208,9 @@ void FillReportInfo(wm_core& _core) // These keys are reserved for the recording if ( GetAsyncKeyState(VK_SHIFT) || GetAsyncKeyState(VK_CONTROL) ) return; + // Check that Dolphin is in focus + if (!IsFocus()) return; + // Check the mouse position. Don't allow mouse clicks from outside the window. float x, y; GetMousePos(x, y); bool InsideScreen = !(x < 0 || x > 1 || y < 0 || y > 1); @@ -287,6 +290,15 @@ void FillReportAcc(wm_accel& _acc) // --------------------- + // Check that Dolphin is in focus + if (!IsFocus()) + { + _acc.x = X; + _acc.y = y; + _acc.z = z; + return; + } + // ------------------------------------ // Wiimote to Gamepad translations // ---------- @@ -768,6 +780,13 @@ void FillReportClassicExtension(wm_classic_extension& _ext) _ext.b2.bB = 0x01; _ext.b2.bZL = 0x01; + + // -------------------------------------- + // Check that Dolphin is in focus + if (!IsFocus()) return; + // -------------------------------------- + + // -------------------------------------- /* Left and right analog sticks diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 50dd8d323c..92d7354634 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -336,6 +336,18 @@ extern "C" unsigned int Wiimote_GetAttachedControllers() // Supporting functions //****************************************************************************** +// Check if Dolphin is in focus +bool IsFocus() +{ + HWND Parent = GetParent(g_WiimoteInitialize.hWnd); + HWND TopLevel = GetParent(Parent); + // Support both rendering to main window and not + if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == g_WiimoteInitialize.hWnd) + return true; + else + return false; +} + void ReadDebugging(bool Emu, const void* _pData) { // diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index 1374cc2e57..3706ae8cf3 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -42,6 +42,7 @@ double GetDoubleTime(); int GetUpdateRate(); void InterruptDebugging(bool Emu, const void* _pData); void ReadDebugging(bool Emu, const void* _pData); +bool IsFocus(); // Movement recording #define RECORDING_ROWS 15