SDL2: Haptics methods behaving not as expected

658 Views Asked by At

I am experiencing some strange behaviors of the SDL2's Haptics methods. I have tested this under Linux 64bit with libsdl2-dev and libsdl2-2.0-0 (both in version v2.0.10) and Windows 10 64bit (latest SDL binary build). As controllers I used the 8Bitdo SF30 Pro Gamepad and a Nintendo Switch Pro Controller - both connected via USB.

  1. The Nintendo Switch Pro Controller is not marked as haptic as all.
  2. Only when started in PlayStation or XBox Mode, the 8Bitdo controller is marked as haptic - but both SDL_HapticRumblePlay and SDL_HapticRunEffect are driving the rumble motor at a quite low frequency (I assume 2-5 Hz) with a resulting small magnitude. Any changes in the effect struct (such as wave-type, magnitute, directions, period, and so on..) do not show any improvements. It also seems that on each SDL_HapticRunEffect call, the vibrations vary a bit. The SDL_HapticsSetGain method does not seem to have any effect either.

Do you have any suggestions on these behaviors?

  1. Why does the Nintendo Pro Controller not be recognized as a haptic device?
  2. What to do with the strange rumble behavior of the 8Bitdo controller? The rumble feature of the controller semms to be intact though (as it vibrites on some Windows games).
1

There are 1 best solutions below

0
On

Although not exactly the answer you might be looking for if you must use the SDL2 haptic methods for any reason, but this comment on a similar issue with haptics in SDL2 states the following:

For gamepads the haptic interfaces are deprecated in favor of SDL_GameControllerRumble(), which is implemented on more platforms for game controllers. The haptic API in general is moving towards just supporting wheels and flightsticks. (Aug. 2021)

So the answer to both of your questions may be that SDL2 haptics is deprecated for gamepads, especially newer ones like the Nintendo Pro Controller, and thus it cannot be guaranteed to work properly (or to work at all).

However, if you simply want to get your gamepad to rumble (which is why I stumbled across this question), using SDL_GameControllerRumble() should do the job. It worked for me with a Nintendo Pro Controller.

Have a look at the SDL_GameControllerRumble - SDL Wiki for more info on how to use it.

Required version to use this function is SDL 2.0.9.