Skip to content
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

Fix GameController interface on Switch #54

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

rsn8887
Copy link

@rsn8887 rsn8887 commented Feb 8, 2024

This fixes Switch controllers not being recognized as SDL_GameControllers because of missing mappings.

The GUID struct was changed at some point in recent SDL2.

The GUID is not simply the first 16 characters of the joystick name anymore as it used to be. The first four bytes now contain a number related to the hardware bus and a crc16 of the name, see here:

*guid16++ = SDL_SwapLE16(bus);
To be correct, the GUID must be constructed from the joystick name via the function SDL_CreateJoystickGUIDForName(). Compare this also to upstreamed platforms like Vita and PS2 where that function is now also used. I then checked the resulting GUID string via SDL_JoystickGetGUIDString(), and used it to fix the mapping line.

Tested with DevilutionX, where controls now work again.

@WinterMute WinterMute merged commit fd37636 into devkitPro:switch-sdl-2.28.5 Feb 8, 2024
1 of 2 checks passed
@rsn8887 rsn8887 deleted the switch-sdl-2.28.5 branch February 15, 2024 11:48
rsn8887 pushed a commit to rsn8887/DevkitPro-SDL that referenced this pull request Feb 15, 2024
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

Successfully merging this pull request may close these issues.

2 participants