diff options
| author | skidau <skidau@gmail.com> | 2015-12-24 09:44:26 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2015-12-24 09:44:26 +1100 |
| commit | f96f90b334e8bf4801162c19412356581e102395 (patch) | |
| tree | fe778793961e6f16e3e6a22c95bb3da02cdec181 /Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp | |
| parent | 81f379b4093a1e425c5c67ddc11034ffd84d5b2e (diff) | |
Ignored the mouse position unless the cursor is over the Dolphin window.
Fixes issue 8673.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp | 34 |
1 files changed, 22 insertions, 12 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); - - // 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; + 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; + + // 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() |
