mirror of
https://github.com/yawut/SDL.git
synced 2026-07-01 00:39:58 -05:00
Fixed setting the GUID for Bluetooth joysticks
This commit is contained in:
parent
4897e7608e
commit
4a43f4e918
|
|
@ -217,16 +217,27 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_JOYSTICK
|
||||
printf("Joystick: %s, bustype = %d, vendor = 0x%x, product = 0x%x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
||||
#endif
|
||||
|
||||
SDL_memset(guid->data, 0, sizeof(guid->data));
|
||||
|
||||
/* We only need 16 bits for each of these; space them out to fill 128. */
|
||||
/* Byteswap so devices get same GUID on little/big endian platforms. */
|
||||
*(guid16++) = SDL_SwapLE16(inpid.bustype);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.vendor);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.product);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.version);
|
||||
*(guid16++) = 0;
|
||||
|
||||
if (inpid.vendor && inpid.product && inpid.version) {
|
||||
*(guid16++) = SDL_SwapLE16(inpid.vendor);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.product);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.version);
|
||||
*(guid16++) = 0;
|
||||
} else {
|
||||
SDL_strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user