Closed smcv closed 1 year ago
I hacked in some print()
debugging and confirmed that with a USB-connected PS3 gamepad, HID enumeration is indeed successful; but that's not really suitable for an automated test.
Nice, thanks for this!
Seems like an API oversight on SDL's part that there's no way to safely check whether an error happened while enumerating HID devices, but maybe that'll get changed in SDL3.
Seems like an API oversight on SDL's part that there's no way to safely check whether an error happened while enumerating HID devices
A lot of functions in SDL 3 have been changed so that they can indicate error, but apparently not that one.
How would an app or game behave differently between "successfully enumerated 0 HID devices" and "there might be HID devices but I can't access them"? Either way, there are no HID devices that your app/game can use... the only thing I can think of that would potentially be useful is to log a warning in the failure case.
If you want to be able to distinguish, the API would presumably have to change from:
SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id);
to something like:
int SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id, SDL_hid_device_info **devices);
Please open a SDL issue if this matters to your use-cases: SDL 3 is currently being developed and its API has not yet been frozen, so now is the time for that sort of change.
PR Description
On my Linux system, enumeration succeeds, but the error indicator gets set as a side-effect (which appears to be because the loader checks whether the symbol exists in SDL or a direct dependency before it dlopens libudev).
The API of SDL_hid_enumerate does not make it possible to distinguish between successfully returning an empty list of devices (returns NULL with the error indicator in an undefined state) and a failure (returns NULL with the error indicator set), and systems that run automated tests usually don't have any HID game controllers connected, so we can't make any meaningful use of the error indicator here.
Helps: https://github.com/py-sdl/py-sdl2/issues/257
Merge Checklist
closes #<issue-number>
to automatically close an issue