Refactor joystick GUID creation

This commit is contained in:
Sam Lantinga
2022-08-22 19:28:21 -07:00
parent aae566e196
commit 277b033e78
19 changed files with 78 additions and 221 deletions

View File

@@ -704,14 +704,7 @@ BSD_JoystickGetDeviceGUID(int device_index)
{
/* the GUID is just the name for now */
const char *name = BSD_JoystickGetDeviceName(device_index);
SDL_JoystickGUID guid;
Uint16 *guid16 = (Uint16 *)guid.data;
SDL_zero(guid);
*guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_UNKNOWN);
*guid16++ = SDL_SwapLE16(SDL_crc16(0, name, SDL_strlen(name)));
SDL_strlcpy((char*)guid16, name, sizeof(guid.data) - 4);
return guid;
return SDL_CreateJoystickGUIDForName(name);
}
static int