Skip to content

Automatic controller mappings are not overwritten by manual mappings without CRC #13127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ThadHouse opened this issue May 26, 2025 · 2 comments
Milestone

Comments

@ThadHouse
Copy link

ThadHouse commented May 26, 2025

I'm not sure if this is a bug or a feature, but it's confusing behavior, so likely more towards the bug category.

When automatic gamepad mappings are generated, the CRC is included in the GUID used. This means that if a mapping for that gamepad is added after the automatic mapping is generated, the added mapping will be ignored, unless the added mapping includes the CRC. This essentially means you have to add mappings before calling SDL_Init, as if any gamepads are plugged in during SDL_Init, they'll have automatically generated mappings created, and any mappings added later will not be used.

What makes me think this is a bug is SDL_PrivateMatchGamepadMappingForGUID has the following comment in it.

// Clear the CRC from the GUID for matching, the mappings never include it in the GUID
SDL_SetJoystickGUIDCRC(&guid, 0);

Which makes me think adding a mapping with a GUID included is a bug.

@slouken
Copy link
Collaborator

slouken commented May 29, 2025

Can you provide a specific example of a controller and the mapping you're trying to use?

@slouken slouken added this to the 3.2.16 milestone May 29, 2025
@ThadHouse
Copy link
Author

ThadHouse commented May 29, 2025

I'm using this as the controller, on a linux platform (Although I suspect I could get a similar result on Windows and macOS).

https://www.revrobotics.com/rev-31-2983/

With the following as the mapping string I created (Because the autogenerated mapping is incorrect).

03000000120c0000182e000011010000,REV USB PS4 Compatible Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,

The autogenerated mapping is being created for GUID 0300288e120c0000182e000011010000, with the difference being the CRC.

In general, it seems like any automatically generated mapping includes the CRC in the generated mapping string GUID. I think the fix would be to strip the CRC from the GUID in SDL_PrivateGenerateAutomaticGamepadMapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants