Skip to content

Commit

Permalink
Fixed XInput haptic support on Windows 8
Browse files Browse the repository at this point in the history
It turns out the XBox 360 controller driver never reports force feedback capability, so we'll try to set 0 state and see if that succeeds.
  • Loading branch information
slouken committed Mar 29, 2014
1 parent 229b438 commit 764aa14
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/haptic/windows/SDL_syshaptic.c
Expand Up @@ -321,9 +321,8 @@ int
XInputHaptic_MaybeAddDevice(const DWORD dwUserid)
{
const Uint8 userid = (Uint8) dwUserid;
XINPUT_CAPABILITIES caps;
const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4));
SDL_hapticlist_item *item;
XINPUT_VIBRATION state;

if ((!loaded_xinput) || (dwUserid >= SDL_XINPUT_MAX_DEVICES)) {
return -1;
Expand All @@ -336,13 +335,8 @@ XInputHaptic_MaybeAddDevice(const DWORD dwUserid)
}
}

if (XINPUTGETCAPABILITIES(dwUserid, XINPUT_FLAG_GAMEPAD, &caps) != ERROR_SUCCESS) {
return -1; /* maybe controller isn't plugged in. */
}

/* XInput < 1.4 is probably only for original XBox360 controllers,
which don't offer the flag, and always have force feedback */
if ( (bIs14OrLater) && ((caps.Flags & XINPUT_CAPS_FFB_SUPPORTED) == 0) ) {
SDL_zero(state);
if (XINPUTSETSTATE(dwUserid, &state) != ERROR_SUCCESS) {
return -1; /* no force feedback on this device. */
}

Expand Down

0 comments on commit 764aa14

Please sign in to comment.