mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-24 04:35:03 +00:00
Add joystick locking for controller notifications on iOS/tvOS
Fixes https://github.com/libsdl-org/SDL/issues/6288
This commit is contained in:
parent
18eb319adc
commit
7becbd7d42
|
@ -678,7 +678,9 @@ IOS_JoystickInit(void)
|
||||||
queue:nil
|
queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
GCController *controller = note.object;
|
GCController *controller = note.object;
|
||||||
|
SDL_LockJoysticks();
|
||||||
IOS_AddJoystickDevice(controller, SDL_FALSE);
|
IOS_AddJoystickDevice(controller, SDL_FALSE);
|
||||||
|
SDL_UnlockJoysticks();
|
||||||
}];
|
}];
|
||||||
|
|
||||||
disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification
|
disconnectObserver = [center addObserverForName:GCControllerDidDisconnectNotification
|
||||||
|
@ -686,14 +688,15 @@ IOS_JoystickInit(void)
|
||||||
queue:nil
|
queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
GCController *controller = note.object;
|
GCController *controller = note.object;
|
||||||
SDL_JoystickDeviceItem *device = deviceList;
|
SDL_JoystickDeviceItem *device;
|
||||||
while (device != NULL) {
|
SDL_LockJoysticks();
|
||||||
|
for (device = deviceList; device != NULL; device = device->next) {
|
||||||
if (device->controller == controller) {
|
if (device->controller == controller) {
|
||||||
IOS_RemoveJoystickDevice(device);
|
IOS_RemoveJoystickDevice(device);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
device = device->next;
|
|
||||||
}
|
}
|
||||||
|
SDL_UnlockJoysticks();
|
||||||
}];
|
}];
|
||||||
#endif /* SDL_JOYSTICK_MFI */
|
#endif /* SDL_JOYSTICK_MFI */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue