summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2021-05-15 12:21:43 +0300
committerFiloppi <filippotarpini@hotmail.it>2021-06-07 11:07:06 +0300
commit8b53af9cbc8aabdd5db349c17a8912c0fec723a8 (patch)
tree995ad40ed5efcf6b5f1517376db6d0e5b02f4f95 /Source/Core/InputCommon/ControllerInterface/DInput
parent038b57feccb098a338342f6542bb97d74f9cf7e1 (diff)
ControllerInterface: polish DInput Keyboard and Mouse (add comments and logs)
Also fix the cursor axis not being updated when the mouse device had failed aquiring, despite them being completely unrelated
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
index e952da6660..aaa723849e 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.cpp
@@ -123,8 +123,10 @@ KeyboardMouse::KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device,
{
s_keyboard_mouse_exists = true;
- m_kb_device->Acquire();
- m_mo_device->Acquire();
+ if (FAILED(m_kb_device->Acquire()))
+ WARN_LOG_FMT(CONTROLLERINTERFACE, "Keyboard device failed to acquire. We'll retry later");
+ if (FAILED(m_mo_device->Acquire()))
+ WARN_LOG_FMT(CONTROLLERINTERFACE, "Mouse device failed to acquire. We'll retry later");
// KEYBOARD
// add keys
@@ -191,6 +193,8 @@ void KeyboardMouse::UpdateCursorInput()
void KeyboardMouse::UpdateInput()
{
+ UpdateCursorInput();
+
DIMOUSESTATE2 tmp_mouse;
// if mouse position hasn't been updated in a short while, skip a dev state
@@ -207,16 +211,14 @@ void KeyboardMouse::UpdateInput()
m_last_update = cur_time;
- HRESULT kb_hr = m_kb_device->GetDeviceState(sizeof(m_state_in.keyboard), &m_state_in.keyboard);
HRESULT mo_hr = m_mo_device->GetDeviceState(sizeof(tmp_mouse), &tmp_mouse);
-
- if (DIERR_INPUTLOST == kb_hr || DIERR_NOTACQUIRED == kb_hr)
- m_kb_device->Acquire();
-
if (DIERR_INPUTLOST == mo_hr || DIERR_NOTACQUIRED == mo_hr)
- m_mo_device->Acquire();
-
- if (SUCCEEDED(mo_hr))
+ {
+ INFO_LOG_FMT(CONTROLLERINTERFACE, "Mouse device failed to get state");
+ if (FAILED(m_mo_device->Acquire()))
+ INFO_LOG_FMT(CONTROLLERINTERFACE, "Mouse device failed to re-acquire, we'll retry later");
+ }
+ else if (SUCCEEDED(mo_hr))
{
m_state_in.relative_mouse.Move({tmp_mouse.lX, tmp_mouse.lY, tmp_mouse.lZ});
m_state_in.relative_mouse.Update();
@@ -227,8 +229,16 @@ void KeyboardMouse::UpdateInput()
// copy over the buttons
std::copy_n(tmp_mouse.rgbButtons, std::size(tmp_mouse.rgbButtons), m_state_in.mouse.rgbButtons);
+ }
- UpdateCursorInput();
+ HRESULT kb_hr = m_kb_device->GetDeviceState(sizeof(m_state_in.keyboard), &m_state_in.keyboard);
+ if (kb_hr == DIERR_INPUTLOST || kb_hr == DIERR_NOTACQUIRED)
+ {
+ INFO_LOG_FMT(CONTROLLERINTERFACE, "Keyboard device failed to get state");
+ if (SUCCEEDED(m_kb_device->Acquire()))
+ m_kb_device->GetDeviceState(sizeof(m_state_in.keyboard), &m_state_in.keyboard);
+ else
+ INFO_LOG_FMT(CONTROLLERINTERFACE, "Keyboard device failed to re-acquire, we'll retry later");
}
}