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: https://github.com/devkitPro/SDL/blob/ed13eea0aaca1caed8d2052a4db8ebb0b4a0f302/src/joystick/SDL_joystick.c#L2111 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.
This is a port of the same fix from branch switch-sdl2-2.28, adapted to use SDL_GAMECONTROLLER_USE_BUTTON_LABELS
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: https://github.com/devkitPro/SDL/blob/ed13eea0aaca1caed8d2052a4db8ebb0b4a0f302/src/joystick/SDL_joystick.c#L2111 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.
This is a port of the same fix from branch switch-sdl2-2.28, adapted to use SDL_GAMECONTROLLER_USE_BUTTON_LABELS