Disable system gestures on MFi controllers while they're open, so we get access to the back button, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m
index 0930f62..dd70f5c 100644
--- a/src/joystick/iphoneos/SDL_mfijoystick.m
+++ b/src/joystick/iphoneos/SDL_mfijoystick.m
@@ -89,6 +89,7 @@ static id disconnectObserver = nil;
#define ENABLE_MFI_RUMBLE
#define ENABLE_MFI_LIGHT
#define ENABLE_MFI_SENSORS
+#define ENABLE_MFI_SYSTEM_GESTURE_STATE
#define ENABLE_PHYSICAL_INPUT_PROFILE
#endif
@@ -656,6 +657,18 @@ IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
}
#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 */
}
}
@@ -1331,7 +1344,18 @@ IOS_JoystickClose(SDL_Joystick *joystick)
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) {