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 5445 - Incorrect Switch Pro Controller face buttons when SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS disabled
Summary: Incorrect Switch Pro Controller face buttons when SDL_HINT_GAMECONTROLLER_USE...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.14
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-04 13:37 UTC by jibb
Modified: 2021-01-14 23:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jibb 2021-01-04 13:37:55 UTC
I'm testing with DualShock 4, DualSense, Switch Pro Controller, and PowerA Switch Controller.

I'm using the standard mapping file from here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

With SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS turned off (set to "0") I expect the button positions to be the same on all devices, based on Xbox controller button naming (eg SDL_GameControllerGetButton(g, SDL_CONTROLLER_BUTTON_Y) gives me whether the North face button is pressed).

However, the Switch Pro Controller layout is wrong (matching labels rather than positions, so X and Y are swapped and A and B are swapped). And with the PowerA controller the East and West buttons are correct, but the North and South buttons are swapped instead.
Comment 1 Sam Lantinga 2021-01-04 21:40:07 UTC
Does it work correctly with the built-in SDL mappings, if you don't use gamecontrollerdb.txt? That mapping file doesn't support the hint.
Comment 2 jibb 2021-01-05 01:12:47 UTC
(In reply to Sam Lantinga from comment #1)
> Does it work correctly with the built-in SDL mappings, if you don't use
> gamecontrollerdb.txt? That mapping file doesn't support the hint.

I've just tested it out without loading gamecontrollerdb.txt, and it still behaves incorrectly as described.
Comment 3 Mathias Kaerlev 2021-01-12 17:31:19 UTC
Also seeing this on 2.0.14. This is most likely a regression, since we weren't seeing this on an earlier SDL version.

I suspect it might be caused by this commit:
https://github.com/spurious/SDL-mirror/commit/a569b211881c6d4c73f3f1019e9f66e754ca546b#diff-da9344d94c66b8c702a45e7649f412039f08bba83bd82de33f5c80ea9c8c39d5

It seems like both the HIDAPI driver and SDL_gamecontroller.c will try to swap the buttons if the hint is set to 0, causing the button remap to cancel out.
Comment 4 Sam Lantinga 2021-01-14 23:16:45 UTC
Fixed, thanks guys!
https://hg.libsdl.org/SDL/rev/abc272ee7adf