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

@@ -252,14 +252,7 @@ extern "C"
{
/* the GUID is just the name for now */
const char *name = HAIKU_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 HAIKU_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)