2.0.14 haptic rumble issues

Hi,

I’ve been working on our game which uses SDL and when I updated from 2.0.12 to 2.0.14 rumble stopped working. I use SDL_HAPTIC_LEFTRIGHT but I logged out the return value of SDL_HapticQuery and it was 0. I tested this using both an Xbox 360 and an Xbox One controller on Windows 10. I debugged into SDL a bit and I found that if I call SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT,“0”) then rumble is working again. Is this intended behaviour or a bug? And is this a good workaround or is it problematic to turn off rawinput?

I also tested a PS4 controller but there is no rumble at all, not even with rawinput turned off. I also tried to enable SDL_HINT_JOYSTICK_HIDAPI_PS4 and SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE but nothing worked. Is there a way to enable Ps4 rumble?

Thank you

There appears to be an issue with SDL_HapticOpenFromJoystick() in SDL 2.0.14 (which I vaguely recall has been fixed ready for the next version of SDL). In my project, I’ve found the way around this is to use SDL_HapticOpen() instead. Hope this helps.

Thank you for your help. First I tried to recompile SDL from the latest source but unfortunately this didn’t fix any issues. Then I tried using SDL_HapticOpen (without disabling rawinput) and this fixed Xbox controller rumble but didn’t fix Ps4 rumble. I think joystick indices and haptic indices are different so if I iterate over joysticks and I open the Nth then I can’t just open the Nth haptic, I might get a haptic for a different joystick. So most probably I’ll keep using SDL_HapticOpenFromJoystick with rawinput disabled.

(I looked into SDL source again and I guess the bug in SDL_HapticOpenFromJoystick comes from SDL_SYS_JoystickSameHaptic which returns 0 immediately if the joystick driver is not SDL_WINDOWS_JoystickDriver but I might be totally wrong about this.)

I’ve opened an issue on GitHub

1 Like