summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp34
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()