From f96f90b334e8bf4801162c19412356581e102395 Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 24 Dec 2015 09:44:26 +1100 Subject: [PATCH] Ignored the mouse position unless the cursor is over the Dolphin window. Fixes issue 8673. --- .../DInput/DInputKeyboardMouse.cpp | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp index 6db8a86a3a..2111f24d62 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp @@ -126,18 +126,28 @@ void GetMousePos(ControlState* const x, ControlState* const y) GetCursorPos(&point); // Get the cursor position relative to the upper left corner of the current window (separate or render to main) HWND hwnd = WindowFromPoint(point); - ScreenToClient(hwnd, &point); + DWORD processId; + GetWindowThreadProcessId(hwnd, &processId); + if (processId == GetCurrentProcessId()) + { + ScreenToClient(hwnd, &point); - // Get the size of the current window. (In my case Rect.top and Rect.left was zero.) - RECT rect; - GetClientRect(hwnd, &rect); - // Width and height is the size of the rendering window - unsigned int win_width = rect.right - rect.left; - unsigned int win_height = rect.bottom - rect.top; + // Get the size of the current window. (In my case Rect.top and Rect.left was zero.) + RECT rect; + GetClientRect(hwnd, &rect); + // Width and height is the size of the rendering window + unsigned int win_width = rect.right - rect.left; + unsigned int win_height = rect.bottom - rect.top; - // Return the mouse position as a range from -1 to 1 - *x = (ControlState)point.x / (ControlState)win_width * 2 - 1; - *y = (ControlState)point.y / (ControlState)win_height * 2 - 1; + // Return the mouse position as a range from -1 to 1 + *x = (ControlState)point.x / (ControlState)win_width * 2 - 1; + *y = (ControlState)point.y / (ControlState)win_height * 2 - 1; + } + else + { + *x = (ControlState)1; + *y = (ControlState)1; + } } void KeyboardMouse::UpdateInput()