| Summary: | Linux controller support, libusb vs libudev | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Anthony Pesch <inolen> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
|
Description
Anthony Pesch
2020-01-15 05:01:09 UTC
Actually, never mind most of what I wrote - I misread some of the code at 1 AM and went down the wrong path. The issue here was defining SDL_JOYSTICK_HIDAPI at all. Doing this causes the PS4 controller to end up going through SDL_hidapijoystick.c (vs linux/SDL_sysjoystick.c) which ultimately fails when SDL_LIBUSB_DYNAMIC is defined on this RPI4. I'll debug this more tomorrow, but if you have some high-level info on what's the ideal setup here I'd love to hear it. Last note for the night, adding the udev rules from https://steamcommunity.com/app/221410/discussions/0/1693795812304458372/ causes /dev/hidraw0 to show up which fixes this issue. However, I would expect this to fallback to the support that is provided by linux/SDL_sysjoystick.c (which was working) in the event the HIDAPI path fails. It seems that doesn't work because of this line: https://github.com/spurious/SDL-mirror/blob/master/src/joystick/linux/SDL_sysjoystick.c#L153 This seems to assume that the device can be opened by the HIDAPI code if the HIDAPI code says it exists, and therefor doesn't bother with it. I wonder if HIDAPI_IsDevicePresent can be modified to, somewhere down the line, not register the device if the device path can't be stat'd or some such. FYI, here are the udev rules from the Steam Link app, which are recommended for use with SDL: --- 55-steamlink.rules -- # USB devices SUBSYSTEM=="usb", GROUP="plugdev" # HID devices KERNEL=="hidraw*", GROUP="input", MODE:="0660" -- Then do: sudo usermod -a -G input,plugdev $(id -un) I looked at the libusb code but I didn't see a way to test to see if the device could be opened without trying to open it. This is actually why the hidapi code isn't built by default. You can't just deploy it to a random target system and assume it will work. However, if you find a way to properly check whether a USB device can be opened, please let me know! Hey Sam, just updated last night and can confirm that fixed the issue. Thanks a lot! Great, thanks! |