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 5110 - Return value of SDL_GameControllerAddMappingsFromFile doesn't count mappings for certain GUIDs
Summary: Return value of SDL_GameControllerAddMappingsFromFile doesn't count mappings ...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.12
Hardware: x86 Windows 10
: P4 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-24 22:04 UTC by PkR
Modified: 2020-04-24 23:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PkR 2020-04-24 22:04:41 UTC
I'm calling SDL_GameControllerAddMappingsFromFile to load controller mappings from a text file. I found out that mappings for controllers with certain GUIDs are ignored despite existing in the .txt file. It seems to have something to do with a specific part of the GUID that is in the range between the 17th and 20th bytes. If this part doesn't contain letters, the mapping fails to load. One of my controllers has a GUID like this (as reported by SDL), so it always fails to load mappings from a file: 03000000790000000600000000000000. However, if I rewrite the GUID to make the byte range 17-20 contain letters, it loads (as indicated by the function's return value). For example this GUID doesn't fail: 030000007900000006AAAA0000000000.

Here's an example mapping string from the file that fails to load:
03000000790000000600000000000000,Default Controller,a:b0,b:b1,x:b2,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,-rightx:-a2,+rightx:+a3,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Windows,

If you try to load gamecontrollerdb.txt from here https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt a good chunk of controller mappings fails to load, with only 78 succeeding.
Comment 1 PkR 2020-04-24 22:16:36 UTC
I tested the project with different versions of SDL and it seems to work with versions 2.0.8 and below. 2.0.9 and above are affected by this issue.
Comment 2 PkR 2020-04-24 23:18:05 UTC
To add to the previous comment, it looks like the issue only affects the function's return value, the mappings themselves are actually loaded. It only doesn't count the mapping strings with such GUIDs. If there are such strings in the text file, the return value is lower than the number of loaded controller mappings. It returns 0 if all GUIDs in the text file are "wrong".
SDL 2.0.8 and below aren't affected by this.