Disable system gesture state for all GCControllers

Technically we only want to do this for controllers that are opened, but we don't have a way to match up controllers using other APIs with individual GCControllers.
This commit is contained in:
Sam Lantinga
2026-03-12 08:34:34 -07:00
parent b80b466423
commit 11adfd2008

View File

@@ -301,6 +301,21 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
Uint8 subtype = 0;
const char *name = NULL;
// Technically we only want to do this when the controller is opened, but we ALSO
// want to do this when the controller is opened via HIDAPI or IOKit, and we don't
// have an easy way to know if those devices correspond to a specific GCController.
//
// Since the fact that we're initializing means that the application is likely to
// be opening available controllers, this is probably the right thing to do for now.
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
for (id key in controller.physicalInputProfile.buttons) {
GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
if ([button isBoundToSystemGesture]) {
button.preferredSystemGestureState = GCSystemGestureStateDisabled;
}
}
}
if (@available(macOS 11.3, iOS 14.5, tvOS 14.5, *)) {
if (!GCController.shouldMonitorBackgroundEvents) {
GCController.shouldMonitorBackgroundEvents = YES;