Game Controller gyro readings and compatibility

Hello, my apologies if this question doesn’t belong here.
I’ve implemented gyro aiming in Yamagi Quake 2, using the awesome sensor reading capabilities of SDL2. It was something natural to add, since Yamagi already used SDL2 Game Controller for input. The meat of the implementation is in this file: sdl.c
Yet, I have a couple of issues on how it behaves in different plaforms:

  1. In Ubuntu 20.04, the DualShock 4 controller works wired and wireless without problems. However, in Windows 7 and Mac OS High Sierra, the controller’s gyro is only detected when wired. Funnily enough, if Steam is started, closed, and then yquake2 is run, the gyro is recognized and works perfectly; this happens in both platforms. Surely, I have something missing from my initialization, but shouldn’t code on all platforms be and work the same? (Line 1535 in the link above).

  2. The Switch Pro Controller works wired and wireless on all platforms, but readings are inconsistent: while on Windows it gives the same readings as the DualShock 4, in Linux and Mac numbers are bigger, which forces me to decrease sensitivity to keep consistency of movement. I’m not an expert on rotational movement, but surely one of the versions is wrong. (Line 1540 on the link above).

Any help with either one is appreciated.

1 Like

On Windows, you need to set some hints for the DualShock 4 and DualSense to work:


For the Switch Pro Controller, there was a fix recently to read sensor scale: Read motion sensor scale from Switch controllers (#5555) · libsdl-org/SDL@d7c07d6 · GitHub . You need at least SDL 2.23.1 pre-release if you want to test it.


Thank you for the answer! Those hints made the DS4 work. Names are confusing, thankfully include/SDL_hints.c is more verbose about what they do.

Regarding the Switch Pro Controller, I’ve used the “main” git branch of SDL, which includes that change, and unfortunately it didn’t made any difference in either Linux or Mac. We’ll have to keep waiting…

Just for the record, as of SDL 2.26.0 the second issue (with the Switch controllers) no longer happens; readings are the same in all platforms.
Thanks to everyone working in this wonderful project.