Refactor joystick GUID creation
This commit is contained in:
parent
aae566e196
commit
277b033e78
19 changed files with 78 additions and 221 deletions
|
@ -496,26 +496,11 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
|
|||
#ifdef SDL_JOYSTICK_HIDAPI
|
||||
if (HIDAPI_IsDevicePresent(vendor, product, version, pDevice->product)) {
|
||||
/* The HIDAPI driver is taking care of this device */
|
||||
return 0;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_memset(pDevice->guid.data, 0, sizeof(pDevice->guid.data));
|
||||
|
||||
if (vendor && product) {
|
||||
*guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB);
|
||||
*guid16++ = SDL_SwapLE16(SDL_crc16(0, pDevice->product, SDL_strlen(pDevice->product)));
|
||||
*guid16++ = SDL_SwapLE16((Uint16)vendor);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)product);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)version);
|
||||
*guid16++ = 0;
|
||||
} else {
|
||||
*guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH);
|
||||
*guid16++ = SDL_SwapLE16(SDL_crc16(0, pDevice->product, SDL_strlen(pDevice->product)));
|
||||
SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
|
||||
}
|
||||
pDevice->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, (Uint16)vendor, (Uint16)product, (Uint16)version, pDevice->product, 0, 0);
|
||||
|
||||
array = IOHIDDeviceCopyMatchingElements(hidDevice, NULL, kIOHIDOptionsTypeNone);
|
||||
if (array) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue