mirror of
https://github.com/encounter/SDL.git
synced 2025-12-10 05:57:44 +00:00
Re-added the CRC to the joystick guid
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL. Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings. sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings. Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
This commit is contained in:
@@ -558,6 +558,8 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
}
|
||||
|
||||
if (s_bBindingComplete) {
|
||||
SDL_JoystickGUID guid;
|
||||
Uint16 crc;
|
||||
char mapping[1024];
|
||||
char trimmed_name[128];
|
||||
char *spot;
|
||||
@@ -576,13 +578,28 @@ WatchJoystick(SDL_Joystick * joystick)
|
||||
}
|
||||
|
||||
/* Initialize mapping with GUID and name */
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), mapping, SDL_arraysize(mapping));
|
||||
guid = SDL_JoystickGetGUID(joystick);
|
||||
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc);
|
||||
if (crc) {
|
||||
/* Clear the CRC from the GUID for the mapping */
|
||||
guid.data[2] = 0;
|
||||
guid.data[3] = 0;
|
||||
}
|
||||
SDL_JoystickGetGUIDString(guid, mapping, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, trimmed_name, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "platform:", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, SDL_GetPlatform(), SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
if (crc) {
|
||||
char crc_string[5];
|
||||
|
||||
SDL_strlcat(mapping, "crc:", SDL_arraysize(mapping));
|
||||
SDL_snprintf(crc_string, sizeof(crc_string), "%.4x", crc);
|
||||
SDL_strlcat(mapping, crc_string, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
}
|
||||
|
||||
for (iIndex = 0; iIndex < SDL_arraysize(s_arrBindings); ++iIndex) {
|
||||
SDL_GameControllerExtendedBind *pBinding = &s_arrBindings[iIndex];
|
||||
|
||||
Reference in New Issue
Block a user