summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-03-19 15:54:36 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2019-03-19 16:05:49 -0500
commitb53636827b2f37b0398c03eb630c1d70fcc6a046 (patch)
tree191f2200341098e1478b9ae2fbb0415f89d0aa8d /Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
parent1fead4ffb6c17a526185113b1192816ffafd5c49 (diff)
ControllerInterface: Unbreak DirectInput POV Hats having bad values on init.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index 400f9b078c..3bb8dd64a3 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -153,8 +153,10 @@ Joystick::Joystick(/*const LPCDIDEVICEINSTANCE lpddi, */ const LPDIRECTINPUTDEVI
// Zero inputs:
m_state_in = {};
+
// Set hats to center:
- std::fill(std::begin(m_state_in.rgdwPOV), std::end(m_state_in.rgdwPOV), 0xFF);
+ // "The center position is normally reported as -1" -MSDN
+ std::fill(std::begin(m_state_in.rgdwPOV), std::end(m_state_in.rgdwPOV), -1);
}
Joystick::~Joystick()
@@ -269,9 +271,11 @@ ControlState Joystick::Button::GetState() const
ControlState Joystick::Hat::GetState() const
{
- // can this func be simplified ?
- // hat centered code from MSDN
- if (0xFFFF == LOWORD(m_hat))
+ // "Some drivers report the centered position of the POV indicator as 65,535.
+ // Determine whether the indicator is centered as follows" -MSDN
+ const bool is_centered = (0xffff == LOWORD(m_hat));
+
+ if (is_centered)
return 0;
return (abs((int)(m_hat / 4500 - m_direction * 2 + 8) % 8 - 4) > 2);