fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

Upgrade SDL and add support for linux specific joystick settings

Open Kiloku opened this issue 3 years ago • 1 comments

In SDL 2.0.18, two new options were added that are relevant for Linux users:

  • Added the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to control whether /dev/input/js* or /dev/input/event* are used as joystick devices
  • Added the hint SDL_HINT_JOYSTICK_DEVICE to allow the user to specify devices that will be opened in addition to the normal joystick detection

The first added option uses the older input source for joysticks, which is compatible with external calibration, deadzoning, etc.
The second added option would allow specifying devices manually, and could allow mixing /dev/input/js* and /dev/input/event* based devices.

I made a local build with the upgraded SDL version and tested both of these options by adding a SDL_SetHint call to code/io/joy-sdl.cpp :: init() for each in two separate tests (one for SDL_HINT_JOYSTICK_DEVICE and one for SDL_HINT_LINUX_JOYSTICK_CLASSIC). Both functioned perfectly without requiring any other modification in the code. This allowed me to use calibrations set via the jstest-gtk software, giving me finer control over my input settings. This needs to be an opt-in, though, as it's possible that some devices won't be visible to this method of joystick detection, and this might also break plugging the joystick in or out while the game is already running.

I propose allowing users to enable SDL_HINT_LINUX_JOYSTICK_CLASSIC via command line, with a parameter like -linux_classic_joystick or something like that, and to use SDL_HINT_JOYSTICK_DEVICE by setting the device paths in the .ini similar to how we can set the GUID.

Note that despite only one of them having "LINUX" in the name, both of these settings only affect Linux.

Kiloku avatar Jul 09 '22 15:07 Kiloku

Tagging @z64555 as this is in his wheelhouse

Kiloku avatar Jul 09 '22 15:07 Kiloku