summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2019-01-16 18:52:11 +0100
committerGitHub <noreply@github.com>2019-01-16 18:52:11 +0100
commitb2de98cad168dee08a5299bd1220d88a0a6c09eb (patch)
tree3b1138b6746d2280833f4b6ffa6e7f006cb19c21 /Source/Core/InputCommon/ControllerInterface/DInput
parent634ef78a261b2a36f4f1ec6841e8211db5107148 (diff)
parenta7c45fb49e7a8f11b71fe5a539148e81746998cc (diff)
Merge pull request #7680 from jordan-woyak/dinput-axis-range
DirectInput: Use more than 8 bits of precision on axis inputs.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index a01ae6c75a..21e39bc416 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
+#include <limits>
#include <map>
#include <sstream>
@@ -121,13 +122,13 @@ Joystick::Joystick(/*const LPCDIDEVICEINSTANCE lpddi, */ const LPDIRECTINPUTDEVI
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0) / sizeof(LONG); ++offset)
{
range.diph.dwObj = offset * sizeof(LONG);
- // try to set some nice power of 2 values (128) to match the GameCube controls
- range.lMin = -(1 << 7);
- range.lMax = (1 << 7);
+ // Try to set a range with 16 bits of precision:
+ range.lMin = std::numeric_limits<s16>::min();
+ range.lMax = std::numeric_limits<s16>::max();
m_device->SetProperty(DIPROP_RANGE, &range.diph);
- // but I guess not all devices support setting range
- // so I getproperty right afterward incase it didn't set.
- // This also checks that the axis is present
+ // Not all devices support setting DIPROP_RANGE so we must GetProperty right back.
+ // This also checks that the axis is present.
+ // Note: Even though not all devices support setting DIPROP_RANGE, some require it.
if (SUCCEEDED(m_device->GetProperty(DIPROP_RANGE, &range.diph)))
{
const LONG base = (range.lMin + range.lMax) / 2;