summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2015-03-28 11:38:14 +1100
committerskidau <skidau@gmail.com>2015-03-28 11:38:14 +1100
commit9947324296d942897b5248bd5651cddbd9078751 (patch)
tree56b5775a3c2e7167e5b492a34a245ffc7e933382 /Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
parent4f965da4f185e654d20838f75321c5a3fe68356f (diff)
Track the co-ordinates of the mouse relative to the pointed window instead of the original hwnd.
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