summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2015-03-28 22:55:39 +1100
committerskidau <skidau@gmail.com>2015-03-28 22:55:39 +1100
commitc45ffa937eb79848002a29948eade27065a03ad2 (patch)
tree56b5775a3c2e7167e5b492a34a245ffc7e933382 /Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
parent74f25ad8ecef9315add7983f7c98b182a7771e45 (diff)
parent9947324296d942897b5248bd5651cddbd9078751 (diff)
Merge pull request #2246 from skidau/sdl-init-crash
Use WindowFromPoint to track the mouse in DInput
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
index c96e51a830..af4e3f0981 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
@@ -31,11 +31,11 @@ static const struct
};
// lil silly
-static HWND hwnd;
+static HWND m_hwnd;
void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, HWND _hwnd)
{
- hwnd = _hwnd;
+ m_hwnd = _hwnd;
// mouse and keyboard are a combined device, to allow shift+click and stuff
// if that's dumb, I will make a VirtualDevice class that just uses ranges of inputs/outputs from other devices
@@ -124,10 +124,11 @@ void GetMousePos(ControlState* const x, ControlState* const y)
{
POINT point = { 1, 1 };
GetCursorPos(&point);
- // Get the cursor position relative to the upper left corner of the rendering window
+ // 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 rendering window. (In my case Rect.top and Rect.left was zero.)
+ // 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