Playstation controllers analog sticks don't work properly on SDL2

This wasn’t a problem a year ago, but all of a sudden my Sixaxis, Dualshock 4, & Dualsense controllers all have the same problem with analog sticks; where even slightly touching them will have them poll indefinitely. This is a disaster! This is not a problem when using my Logitech F310 Gamepad (XInput), or Logitech Dual Action. I’m really not sure what the problem is. I’m running on Arch Linux. I’m testing this on the testgamecontroller.c test program distributed with SDL2-2.0.16’s in the tests directory.

This a screenshot of the test. It is doing this without any interaction outside of the initial touch of the left analog stick!

Dualshock joystick are not very accurate nor stable. However 1 year ago, deadzone were removed on Linux ( SDL on Linux needs a way to turn deadzones off · Issue #3781 · libsdl-org/SDL · GitHub ) mainly for consistency with other platform. Before that, all the shaking in the deadzone was filtered by SDL before reaching your app. You can re-enable deadzone with an hint: SDL_HINT_LINUX_JOYSTICK_DEADZONES, or implement your own.

1 Like

Thank you so much for the response! You’re a lifesaver! After setting the hint, I still have issues with the PS5 controller, but now the PS3 & PS4 controllers work like a charm! I suppose my only solution for the PS5 controller is to implement deadzones for that specific one as you also suggested.