summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
diff options
context:
space:
mode:
authorMichael Lelli <michael.lelli@steelseries.com>2017-08-09 22:51:01 -0500
committerMichael Lelli <michael.lelli@steelseries.com>2017-08-09 22:51:01 -0500
commit4fb2d1e361823667c261333ab7eaccd8079b2459 (patch)
tree7fa458d206043206d22d8abedf04fa2706b9a886 /Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
parent0f9ae6d361541a5917ae3b05dc7c667cdef81336 (diff)
Ignore capabilities reported by an XInput device
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
index 3d8650820e..0b5cbad358 100644
--- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp
@@ -109,46 +109,37 @@ void DeInit()
Device::Device(const XINPUT_CAPABILITIES& caps, u8 index) : m_subtype(caps.SubType), m_index(index)
{
- // XInputGetCaps seems to always claim all capabilities are supported
- // but I will leave all this stuff in, incase m$ fixes xinput up a bit
+ // XInputGetCaps can be broken on some devices, so we'll just ignore it
+ // and assume all gamepad + vibration capabilities are supported
// get supported buttons
for (int i = 0; i != sizeof(named_buttons) / sizeof(*named_buttons); ++i)
{
- // Guide button is never reported in caps
- if ((named_buttons[i].bitmask & caps.Gamepad.wButtons) ||
- ((named_buttons[i].bitmask & XINPUT_GAMEPAD_GUIDE) && haveGuideButton))
+ // Only add guide button if we have the 100 ordinal XInputGetState
+ if (!(named_buttons[i].bitmask & XINPUT_GAMEPAD_GUIDE) || haveGuideButton)
AddInput(new Button(i, m_state_in.Gamepad.wButtons));
}
// get supported triggers
for (int i = 0; i != sizeof(named_triggers) / sizeof(*named_triggers); ++i)
{
- // BYTE val = (&caps.Gamepad.bLeftTrigger)[i]; // should be max value / MSDN lies
- if ((&caps.Gamepad.bLeftTrigger)[i])
- AddInput(new Trigger(i, (&m_state_in.Gamepad.bLeftTrigger)[i], 255));
+ AddInput(new Trigger(i, (&m_state_in.Gamepad.bLeftTrigger)[i], 255));
}
// get supported axes
for (int i = 0; i != sizeof(named_axes) / sizeof(*named_axes); ++i)
{
- // SHORT val = (&caps.Gamepad.sThumbLX)[i]; // xinput doesn't give the range / MSDN is a liar
- if ((&caps.Gamepad.sThumbLX)[i])
- {
- const SHORT& ax = (&m_state_in.Gamepad.sThumbLX)[i];
+ const SHORT& ax = (&m_state_in.Gamepad.sThumbLX)[i];
- // each axis gets a negative and a positive input instance associated with it
- AddInput(new Axis(i, ax, -32768));
- AddInput(new Axis(i, ax, 32767));
- }
+ // each axis gets a negative and a positive input instance associated with it
+ AddInput(new Axis(i, ax, -32768));
+ AddInput(new Axis(i, ax, 32767));
}
// get supported motors
for (int i = 0; i != sizeof(named_motors) / sizeof(*named_motors); ++i)
{
- // WORD val = (&caps.Vibration.wLeftMotorSpeed)[i]; // should be max value / nope, more lies
- if ((&caps.Vibration.wLeftMotorSpeed)[i])
- AddOutput(new Motor(i, this, (&m_state_out.wLeftMotorSpeed)[i], 65535));
+ AddOutput(new Motor(i, this, (&m_state_out.wLeftMotorSpeed)[i], 65535));
}
ZeroMemory(&m_state_in, sizeof(m_state_in));