Skip to content

Commit

Permalink
Disable system gestures on MFi controllers while they're open, so we …
Browse files Browse the repository at this point in the history
…get access to the back button, etc.
  • Loading branch information
slouken committed Mar 23, 2021
1 parent 1133ea0 commit 0bdf4f9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/joystick/iphoneos/SDL_mfijoystick.m
Expand Up @@ -89,6 +89,7 @@ @interface GCMicroGamepad (SDL)
#define ENABLE_MFI_RUMBLE
#define ENABLE_MFI_LIGHT
#define ENABLE_MFI_SENSORS
#define ENABLE_MFI_SYSTEM_GESTURE_STATE
#define ENABLE_PHYSICAL_INPUT_PROFILE
#endif

Expand Down Expand Up @@ -656,6 +657,18 @@ static int is_macos11(void)
}
#endif /* ENABLE_MFI_SENSORS */

#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
GCController *controller = joystick->hwdata->controller;
if (controller.extendedGamepad) {
GCExtendedGamepad *gamepad = controller.extendedGamepad;
if ([gamepad.buttonOptions isBoundToSystemGesture]) {
gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateDisabled;
}
}
}
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */

#endif /* SDL_JOYSTICK_MFI */
}
}
Expand Down Expand Up @@ -1331,7 +1344,18 @@ -(void)cleanup
GCController *controller = device->controller;
controller.controllerPausedHandler = nil;
controller.playerIndex = -1;
#endif

#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
GCController *controller = joystick->hwdata->controller;
if (controller.extendedGamepad) {
GCExtendedGamepad *gamepad = controller.extendedGamepad;
gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateEnabled;
}
}
#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */

#endif /* SDL_JOYSTICK_MFI */
}
}
if (device->remote) {
Expand Down

0 comments on commit 0bdf4f9

Please sign in to comment.