libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.79k stars 1.82k forks source link

Implement SDL_Haptic wrapper around SDL_JoystickRumble() functionality #4970

Closed cgutman closed 9 months ago

cgutman commented 2 years ago

Many older SDL applications use SDL_Haptic instead of the newer SDL_JoystickRumble() and SDL_GameControllerRumble() APIs. Since most of the new joystick backends (WGI, RawInput, and HIDAPI) don't provide a corresponding SDL_Haptic implementation, this prevents force feedback from working in older games. In some cases, SDL will use one of the newer backends like RawInput where it would have previously used an older SDL_Haptic-capable backend (XInput) which has the effect of regressing force feedback when updating to a newer version of SDL.

We can use SDL_JoystickHasRumble() and a new SDL_SYS_Haptic implementation to provide emulation of SDL_Haptic on rumble-capable joysticks that lack associated haptic devices. It's not completely straightforward because the haptic subsystem assumes there will only be one haptic backend. It will take some refactoring to accomplish but should be doable.

slouken commented 2 years ago

Feel free to submit a PR whenever you want for this.

slouken commented 9 months ago

I've landed on removing gamepad rumble from the haptics API in favor of the much simpler SDL_RumbleGamepad()

slouken commented 9 months ago

If you have a use case where this isn't possible, please let me know and we can reopen this.