Fixed XInput haptic support on Windows 8
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Mar 2014 12:29:38 -0700
changeset 86881543a7183f88
parent 8687 1d2ca48523a7
child 8689 671977fe0abd
Fixed XInput haptic support on Windows 8
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.
src/haptic/windows/SDL_syshaptic.c
     1.1 --- a/src/haptic/windows/SDL_syshaptic.c	Sat Mar 29 12:27:27 2014 -0700
     1.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Sat Mar 29 12:29:38 2014 -0700
     1.3 @@ -321,9 +321,8 @@
     1.4  XInputHaptic_MaybeAddDevice(const DWORD dwUserid)
     1.5  {
     1.6      const Uint8 userid = (Uint8) dwUserid;
     1.7 -    XINPUT_CAPABILITIES caps;
     1.8 -    const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4));
     1.9      SDL_hapticlist_item *item;
    1.10 +    XINPUT_VIBRATION state;
    1.11  
    1.12      if ((!loaded_xinput) || (dwUserid >= SDL_XINPUT_MAX_DEVICES)) {
    1.13          return -1;
    1.14 @@ -336,13 +335,8 @@
    1.15          }
    1.16      }
    1.17  
    1.18 -    if (XINPUTGETCAPABILITIES(dwUserid, XINPUT_FLAG_GAMEPAD, &caps) != ERROR_SUCCESS) {
    1.19 -        return -1;  /* maybe controller isn't plugged in. */
    1.20 -    }
    1.21 -
    1.22 -    /* XInput < 1.4 is probably only for original XBox360 controllers,
    1.23 -        which don't offer the flag, and always have force feedback */
    1.24 -    if ( (bIs14OrLater) && ((caps.Flags & XINPUT_CAPS_FFB_SUPPORTED) == 0) ) {
    1.25 +    SDL_zero(state);
    1.26 +    if (XINPUTSETSTATE(dwUserid, &state) != ERROR_SUCCESS) {
    1.27          return -1;  /* no force feedback on this device. */
    1.28      }
    1.29