Make sure we completely unlock joysticks when opening HIDAPI devices
Also lock the joysticks when adding and removing Android joysticks
This commit is contained in:
parent
47ba997f06
commit
333935ff3f
4 changed files with 47 additions and 16 deletions
|
@ -368,15 +368,21 @@ HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *removed)
|
|||
*
|
||||
* See https://github.com/libsdl-org/SDL/issues/6347 for details
|
||||
*/
|
||||
int lock_count = 0;
|
||||
SDL_HIDAPI_Device *curr;
|
||||
SDL_hid_device *dev;
|
||||
char *path;
|
||||
char *path = SDL_strdup(device->path);
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
path = SDL_strdup(device->path);
|
||||
SDL_UnlockJoysticks();
|
||||
while (SDL_JoysticksLocked()) {
|
||||
++lock_count;
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
dev = SDL_hid_open_path(path, 0);
|
||||
SDL_LockJoysticks();
|
||||
while (lock_count > 0) {
|
||||
--lock_count;
|
||||
SDL_LockJoysticks();
|
||||
}
|
||||
SDL_free(path);
|
||||
|
||||
/* Make sure the device didn't get removed while opening the HID path */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue