You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Joystick implementation does not "re-recognize" any devices that have disconnected and then reconnect. Instead, a new ALLEGRO_JOYSTICK* is created for that device, and the old pointer remains active but dead. In addition to that, there is no data that is exposed by Allegro that can be used to correlate known, reconnecting devices.
This presents some limitations for Joystick usability, mostly in multiplayer contexts. Specifically, if one player's device disconnects, a new joystick setup may need to be walked through again when the "new" device reconnects. This presents challenges for custom mapping of buttons, correlating players to devices, usability of device lists. etc.
On macOS, the recommendation seems to be to obtain the serial number, e.g. ask for the kIOHIDSerialNumberKey on the IOHIDDeviceRef device, which can be used to map unique devices. If privacy is a concern, we could consider creating a hash consisting of serial number, manufacturer id, and device id. Device info and configurations with this info could even be stored in config files, allowing a smooth experience when restarting a program.
Discussion/Proposal
I see there has been some discussion about adding an ALLEGRO_JOYSTICK_GUID as well as a database of known joystick types (which would be great to have), but this issue is slightly different and may collide with the one I describe.
Originally I though to suggest a al_get_joystick_uid() to obtain a unique id specific to the device itself (hash composed of manufacturer id, device id, serial number), but the concept of a "GUID" already appears to be taken in the previous discussions to represent a joystick's make/model. Maybe a more formal ALLEGRO_JOYSTICK_KIND_GUID could be used there instead? And ALLEGRO_JOYSTICK_GUID could be used to represent a specific device?
For making the unique id, this would also open the door for other properties to be exposed such as al_get_joystick_manufacturer_id, al_get_joystick_device_id, al_get_joystick_serial_number, but these may be redundant if really all we're after is just information about a joystick's make and persistence status.
In addition to kIOHIDSerialNumberKey, I also stumbled across a kIOHIDUniqueIDKey which appears to be exactly as it describes, a unique id representing the device.
I can't seem to find robust documentation on the thing, but there was a discussion here about using it to resolve re-connections. It was was also mentioned however that "kIOHIDUniqueIDKey is unsupported on older systems and wasn't a great solution because of this."
Issue
Currently, the Joystick implementation does not "re-recognize" any devices that have disconnected and then reconnect. Instead, a new
ALLEGRO_JOYSTICK*
is created for that device, and the old pointer remains active but dead. In addition to that, there is no data that is exposed by Allegro that can be used to correlate known, reconnecting devices.This presents some limitations for Joystick usability, mostly in multiplayer contexts. Specifically, if one player's device disconnects, a new joystick setup may need to be walked through again when the "new" device reconnects. This presents challenges for custom mapping of buttons, correlating players to devices, usability of device lists. etc.
On macOS, the recommendation seems to be to obtain the serial number, e.g. ask for the
kIOHIDSerialNumberKey
on theIOHIDDeviceRef
device, which can be used to map unique devices. If privacy is a concern, we could consider creating a hash consisting of serial number, manufacturer id, and device id. Device info and configurations with this info could even be stored in config files, allowing a smooth experience when restarting a program.Discussion/Proposal
I see there has been some discussion about adding an
ALLEGRO_JOYSTICK_GUID
as well as a database of known joystick types (which would be great to have), but this issue is slightly different and may collide with the one I describe.Originally I though to suggest a
al_get_joystick_uid()
to obtain a unique id specific to the device itself (hash composed of manufacturer id, device id, serial number), but the concept of a "GUID" already appears to be taken in the previous discussions to represent a joystick's make/model. Maybe a more formalALLEGRO_JOYSTICK_KIND_GUID
could be used there instead? AndALLEGRO_JOYSTICK_GUID
could be used to represent a specific device?For making the unique id, this would also open the door for other properties to be exposed such as
al_get_joystick_manufacturer_id
,al_get_joystick_device_id
,al_get_joystick_serial_number
, but these may be redundant if really all we're after is just information about a joystick's make and persistence status.Relates Issues
The text was updated successfully, but these errors were encountered: