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 3079

Summary: Allow non destructive SDL_GameControllerAddMappingsFromFile
Product: SDL Reporter: x414e54
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: All   
OS: All   
Attachments: Mappings (DRAFT)

Description x414e54 2015-07-29 14:11:57 UTC
It is a bit of a pain to update the library or rely on whatever version the user has on their computer for default mappings. 

So providing an easily updatable text file via SDL_GameControllerAddMappingsFromFile is still currently the most viable way. However using this replaces all mappings provided by the SDL_HINT_GAMECONTROLLERCONFIG environment variable which may have come from the user's custom Steam mapping.

There should be an easy way for games to supply extra game controller mappings to fill in the differences between SDL versions without it clobbering the SDL_HINT_GAMECONTROLLERCONFIG environment variable.
Comment 1 Sam Lantinga 2016-10-01 22:08:24 UTC
Agreed. Do you have a candidate patch for this?
Comment 2 x414e54 2016-11-07 10:15:04 UTC
Created attachment 2607 [details]
Mappings (DRAFT)

Here is a quick idea I had (patch attached but I still need to test it). 

Internally the mappings could use a priority system and if the priority is lower then it will not overwrite the mappings. 

For now it just assumes SDL_HINT_GAMECONTROLLERCONFIG is the highest priority, the default hardcoded are the lowest and anything set via the API is medium.
Comment 3 Sam Lantinga 2016-11-11 21:17:14 UTC
This seems reasonable, have you tested your patch?
Comment 4 Sam Lantinga 2016-11-11 21:31:03 UTC
I turned the priority into an enum, but your patch looks good, thanks!
https://hg.libsdl.org/SDL/rev/8a059b7b01c4