On Fri Dec 5 11:34:57 2025 +0000, Rémi Bernon wrote:
As I understand this should only generate a unique serial number if we found another device with the same serial, so it should not make much difference for cases where the device has already a proper serial? I'm not very confident that only SDL lacks serial numbers and this seems like a good fallback? The change in get_device_index() takes care of duplicate serial numbers - it'll increase the index, which is used later to generate an instance_id. The logic in get_instance_id() will use the serial number only if the index is 0, ensuring that there is no duplicate serial numbers with other devices of the same model. Otherwise it'll use bus_num/port_path or index to make the instance_id unique for this device interface.
I'm not very confident that only SDL lacks serial numbers and this seems like a good fallback?
I think only old SDL versions lack SDL_JoystickGetSerial(). Newer Linuxes/Androids should be using more recent versions in my opinion. Maybe it'll be a problem for older Android versions. Bus_iohid retrieves it, as well as bus_udev (once via hid and twice via usb_device), so IMO we cover most cases. I tested Windows hid drivers specifically for SN retrieval, and they only return real serial numbers. Otherwise return an error. Since most joystick devices don't have serial numbers, I think the apps are prepared for this situation. Since we always had a serial number in Wine (mostly default zeroes), IMO this caused some of the problems that forced us to generate unique serial numbers. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9687#note_124944