-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Joysticks are enumerated in the opposite order on Linux #4430
Comments
I think this is the same issue: #2832 |
@slouken is it going to break anything if we change this? |
I'm developing a simple MAME frontend. |
No, I don't think so. The intent is for controllers to be listed in the order attached, which corresponds to js0..N on Linux. |
Hi there, all. I've been chasing some joystick jank down and finally made it here to this issue. It seems that if udev is used to enumerate controllers, they come out in the correct order, but if the filesystem is used--and it has to be in sandbox environments--it uses readdir and the event devices come back in arbitrary order. According to this stackoverflow page you can use My testing found that in SDL 2.0.10, the version in Ubuntu 20.04's repositories, the enumeration order is correct if SDL_JOYSTICK_DISABLE_UDEV is set, and incorrect if I install 2.0.14 from source and recompile sdl2-jstest against it. But I don't know if that's because that version does enumeration differently, or because that environment var didn't exist then (probably the more likely case). You can work around this with the SDL_JOYSTICK_DEVICE environment var. Its naming suggests you can only provide one, but you can actually delimit multiple devices with a colon. I have a script that enumerates joystick event devices in numerical order and sets the env var accordingly. |
Hey! |
Retroarch has the same issue with its "udev" joystick driver. |
Retroarch also has a SDL2 joystick driver; you can use that and the workaround to get our desired behavior, otherwise that's a problem for their issue tracker. |
Yes, using the SDL2 joystick driver and 'SDL_JOYSTICK_DEVICE' fixes it. Once this gets fixed in SDL, I will have an argument to ask there too. |
Sorry, @slouken . The fix doesn't seem to work. For example, running gamepad-tool:
But "X360 Controller" is /dev/input/js0, /dev/input/event20 |
@icculus ? |
On Linux, joysticks should by default be sorted by their device files (/dev/input/js*).
Joystick 1 should be "/dev/input/js0", joystick 2 should be "/dev/input/js1", and so on. This was the default behavior on SDL 1.2, and it simply worked.
Currently they are sorted in the opposite order. Last joystick always gets enumerated as "joystick 1", the last but one always gets enumerated as "joystick 2". This is super counterintuitive.
The text was updated successfully, but these errors were encountered: