-
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
Rudder pedals "CH Pro Pedals" incorrectly detected as accelerometer on Linux without udev #7500
Comments
…r when udev is not used The CH Pro Pedals are incorrectly classified as accelerometer in SDL_EVDEV_GuessDeviceClass(), because it has three axes and no buttons. This introduces the new function IsExplicitlyKnwownAsJoystick() to check if a device is known to be a joystick by checking the vendor / product ID. For now, this functions checks for the CH Pro Pedals, and returns SDL_FALSE for all other devices, to proceed with the check via GuessIsJoystick() as before. Furthermore, the call to GuessIsJoystick() is now done after product id determination in IsJoystick(), to be able to perform the IsExplicitlyKnwownAsJoystick() before calling GuessIsJoystick(). Fixes libsdl-org#7500.
Unfortunately, there's a backwards-compatibility issue there. Before If there was a flag that positively identified a device as a gaming input device ( |
These devices have been reported in various places to be detected as either accelerometers or unknown devices, because they do not report any of the buttons that we use to identify a likely joystick. Resolves: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Helps: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Helps: libsdl-org#7500 Signed-off-by: Simon McVittie <[email protected]>
These simulation control devices are known to be joysticks, but don't all have enough information in their evdev capabilities for us to be able to distinguish them from an accelerometer by capabilities alone. If we look at the bus type, vendor ID and product ID as well, then that gives us enough information to distinguish. Resolves: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Read the explanation over on the proton issue. Got me thinking, maybe, even if you can't communicate with udev properly/reliably across the container boundary, you could use the hwdb. That is, instead of duplicating a chunk of the hwdb inside SDL, how about adding to SDL the ability to import and use the hwdb file? It shouldn't be too hard to get this into the container environment. If it isn't felt that the binary format is stable enough, you can go with a text dump
In the event the OS one cannot be had, it could use a static baked in one. |
To be clear, I am thinking essentially having two separate databases (udev one and SDL) is good to avoid. It is a pain to have to put overrides in two places, they inevitably windup disagreeing, and that leads to confusing results. |
Was just looking at the hwdb API and code. It just reads the hwdb.bin file, which is a trie for looking up the key strings. There isn't any fancy encoding beyond the trie, which would be expected given the API (it is all strings), and is evident from running It also is versioned with the API returning an error if it cannot load the file. From the actual code, it looks like there have been three versions, with the third being introduced over seven years ago (added a priority field to help resolve conflicts), and in a way that was actually still interoperable with the second. So that all seems pretty self contained, container friendly, and quite stable. Wine actually has some pretty succinct udev code to determine a device type. The udev code is just a tiny wrapper around the sd-device functions, which are now recommend to be used instead. Scanning over this code, it looks to just pokes /sys and pull udev assigned attributes by reading plain text key value pairs from associated /run/udev/data/<device> files. I know you mentioned there were problems with udev for device event notification across container boundaries due to different versions of udev. The sd-device (and even more so sd-hwdb) querying interface really doesn't seem to be doing that sort of thing though, so maybe there could be an option to just look up device type using sd-device or even just sd-hwdb between full udev and falling back to a baked in device ids? |
There are two related concerns, which I think you might be mixing up here:
|
Thanks very much for all the clarification. I think I have a pretty good understanding now, so I submitted a patch. 👍 |
If anyone want to try things with the patch, I rebuilt libSDL2 for all the current steam runtimes. You can get them here (see the README.txt file for how to install them). Note that this may not effect all programs. You can check what libSDL2 a program is using by running
where |
This patch has been merged, thanks! |
Helps: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Helps: libsdl-org#7500 Signed-off-by: Simon McVittie <[email protected]>
These simulation control devices are known to be joysticks, but don't all have enough information in their evdev capabilities for us to be able to distinguish them from an accelerometer by capabilities alone. If we look at the bus type, vendor ID and product ID as well, then that gives us enough information to distinguish. Resolves: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Helps: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
Helps: libsdl-org#7500 Signed-off-by: Simon McVittie <[email protected]>
These simulation control devices are known to be joysticks, but don't all have enough information in their evdev capabilities for us to be able to distinguish them from an accelerometer by capabilities alone. If we look at the bus type, vendor ID and product ID as well, then that gives us enough information to distinguish. Resolves: libsdl-org#7500 Co-authored-by: Felix Hädicke <[email protected]> Signed-off-by: Simon McVittie <[email protected]>
When using SDL2 on Linux without udev enabled (e. g. in the Steam container runtime), the CH Pro Pedals are incorrectly detected as accelerometer, and not listed as a joystick. The CH Pro Pedals are a rudder pedals product.
Because it has three axes and no buttons, it is classified as an accelerometer in
SDL_EVDEV_GuessDeviceClass()
(see src/core/linux/SDL_evdev_capabilities.c).Proposals for solution:
INPUT_PROP_ACCELEROMETER
being set by the Linux kernel (since 4.0) instead of checking the number of axes / existence of buttons to detect accelerometers.The algorithm systemd-udev uses to detect accelerometers is very similar to what SDL does. It also does not rely on the property
INPUT_PROP_ACCELEROMETER
, but also classifies devices with three axes and no buttons as accelerometers (see https://github.com/systemd/systemd/blob/v253/src/udev/udev-builtin-input_id.c#L185). However, for this particular product, there is a hwdb rule (see systemd/systemd@230ed4c).The text was updated successfully, but these errors were encountered: