Explorar o código

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.

Sam Lantinga %!s(int64=11) %!d(string=hai) anos
pai
achega
764aa147ad
Modificáronse 1 ficheiros con 3 adicións e 9 borrados
  1. 3 9
      src/haptic/windows/SDL_syshaptic.c

+ 3 - 9
src/haptic/windows/SDL_syshaptic.c

@@ -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;
@@ -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. */
     }