We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2327

Summary: SDL_JoystickGetGUID() not unique on Linux
Product: SDL Reporter: grumbel
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: bradhugh
Version: 2.0.1   
Hardware: x86   
OS: Linux   

Description grumbel 2013-12-24 16:19:29 UTC
The joystick GUIDs are currently generated from the USB bustype, vendor, product and version:

http://hg.libsdl.org/SDL/file/a9d1c47bb1aa/src/joystick/linux/SDL_sysjoystick.c#l117

However this only gives a GUID that is unique for the type of controller, not for the controller itself. Two controllers of the same type will generate the same GUID and cause issues with games that rely on the GUID being unique. See for example:

http://askubuntu.com/questions/394627/two-ps3-controllers-connected-via-usb-identified-as-one/395253#395253
Comment 1 Sam Lantinga 2013-12-24 20:25:01 UTC
That is correct, the GUID is used to identify the type of controller (and what game controller mapping should be used)

As far as I know there is no way to uniquely identify a specific device.
Comment 2 Brad Hughes 2016-07-22 14:07:37 UTC
(In reply to Sam Lantinga from comment #1)
> That is correct, the GUID is used to identify the type of controller (and
> what game controller mapping should be used)
> 
> As far as I know there is no way to uniquely identify a specific device.

So the GUID values provided by SDL for joysticks are not intended to be unique per-device? There is no way at all to get unique ID's per device? There is unique information provided by most USB devices that could be obtained. For instance, most devices expose a SerialNumber as well as LocationID which further identify devices.

MAME needs a way to uniquely identify two devices of the same type to support multiple controllers of the same type.
Comment 3 grumbel 2016-07-26 08:46:20 UTC
One way to fix this issue would be to add an id into the GUID. So the first controller of a given type gets the regular GUID, if a second controller of the same type is discovered it gets GUID+1, third one gets GUID+2, etc.