summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
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
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')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp7
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.h3
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp9
3 files changed, 6 insertions, 13 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index a3c14a0ab5..1330cb1e0a 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -44,7 +44,7 @@ ControllerInterface g_controller_interface;
void ControllerInterface::Initialize(void* const hwnd)
{
if (m_is_init)
- DeInit();
+ return;
m_hwnd = hwnd;
@@ -102,11 +102,6 @@ void ControllerInterface::Shutdown()
delete d;
}
- DeInit();
-}
-
-void ControllerInterface::DeInit()
-{
m_devices.clear();
#ifdef CIFACE_USE_XINPUT
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
index 1b2c93951f..9ab8427ad2 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h
@@ -117,9 +117,6 @@ public:
void Initialize(void* const hwnd);
void Reinitialize();
void Shutdown();
-
- void DeInit();
-
bool IsInit() const { return m_is_init; }
void UpdateReference(ControlReference* control, const ciface::Core::DeviceQualifier& default_device) const;
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