From 764aa147ade0d72a963611f7f81bdc99c66c5b33 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Mar 2014 12:29:38 -0700 Subject: [PATCH] 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 | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index b320e9ddb..c5a901149 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/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. */ }