SDL: Check for macOS 10.16 to support apps built with older macOS SDKs

From 2ccb0dfd161aadc9bfb23a636e49f8ab80b8606d Mon Sep 17 00:00:00 2001
From: Carl Friess <[EMAIL REDACTED]>
Date: Wed, 13 Apr 2022 15:39:29 +0200
Subject: [PATCH] Check for macOS 10.16 to support apps built with older macOS
 SDKs

---
 src/joystick/iphoneos/SDL_mfijoystick.m | 38 ++++++++++++-------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m
index bf9163319ef..95e3309a224 100644
--- a/src/joystick/iphoneos/SDL_mfijoystick.m
+++ b/src/joystick/iphoneos/SDL_mfijoystick.m
@@ -745,7 +745,7 @@ static int is_macos11(void)
             }
 
 #ifdef ENABLE_MFI_SENSORS
-            if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
                 GCController *controller = joystick->hwdata->controller;
                 GCMotion *motion = controller.motion;
                 if (motion && motion.hasRotationRate) {
@@ -758,7 +758,7 @@ 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, *)) {
+            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
                 GCController *controller = joystick->hwdata->controller;
                 for (id key in controller.physicalInputProfile.buttons) {
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
@@ -970,7 +970,7 @@ static int is_macos11(void)
             }
 
 #ifdef ENABLE_MFI_SENSORS
-            if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
                 GCMotion *motion = controller.motion;
                 if (motion && motion.sensorsActive) {
                     float data[3];
@@ -1063,7 +1063,7 @@ static int is_macos11(void)
         }
 
 #ifdef ENABLE_MFI_BATTERY
-        if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCDeviceBattery *battery = controller.battery;
             if (battery) {
                 SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
@@ -1104,8 +1104,8 @@ static int is_macos11(void)
 #ifdef ENABLE_MFI_RUMBLE
 
 @interface SDL_RumbleMotor : NSObject
-    @property(nonatomic,strong) CHHapticEngine *engine API_AVAILABLE(macos(11.0), ios(13.0), tvos(14.0));
-    @property(nonatomic,strong) id<CHHapticPatternPlayer> player API_AVAILABLE(macos(11.0), ios(13.0), tvos(14.0));
+    @property(nonatomic,strong) CHHapticEngine *engine API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0));
+    @property(nonatomic,strong) id<CHHapticPatternPlayer> player API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0));
     @property bool active;
 @end
 
@@ -1115,7 +1115,7 @@ @implementation SDL_RumbleMotor {
 -(void)cleanup
 {
     @autoreleasepool {
-        if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             if (self.player != nil) {
                 [self.player cancelAndReturnError:nil];
                 self.player = nil;
@@ -1131,7 +1131,7 @@ -(void)cleanup
 -(int)setIntensity:(float)intensity
 {
     @autoreleasepool {
-        if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             NSError *error = nil;
 
             if (self.engine == nil) {
@@ -1177,7 +1177,7 @@ -(int)setIntensity:(float)intensity
     }
 }
 
--(id) initWithController:(GCController*)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
+-(id) initWithController:(GCController*)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0))
 {
     @autoreleasepool {
         self = [super init];
@@ -1277,7 +1277,7 @@ -(void)cleanup
 static SDL_RumbleContext *IOS_JoystickInitRumble(GCController *controller)
 {
     @autoreleasepool {
-        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             SDL_RumbleMotor *low_frequency_motor = [[SDL_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftHandle];
             SDL_RumbleMotor *high_frequency_motor = [[SDL_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityRightHandle];
             SDL_RumbleMotor *left_trigger_motor = [[SDL_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftTrigger];
@@ -1305,7 +1305,7 @@ -(void)cleanup
         return SDL_SetError("Controller is no longer connected");
     }
 
-    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
         if (!device->rumble && device->controller && device->controller.haptics) {
             SDL_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             if (rumble) {
@@ -1335,7 +1335,7 @@ -(void)cleanup
         return SDL_SetError("Controller is no longer connected");
     }
 
-    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
         if (!device->rumble && device->controller && device->controller.haptics) {
             SDL_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             if (rumble) {
@@ -1368,7 +1368,7 @@ -(void)cleanup
             return 0;
         }
 
-        if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             #ifdef ENABLE_MFI_LIGHT
             if (controller.light) {
@@ -1405,7 +1405,7 @@ -(void)cleanup
             return SDL_SetError("Controller is no longer connected");
         }
 
-        if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             GCDeviceLight *light = controller.light;
             if (light) {
@@ -1438,7 +1438,7 @@ -(void)cleanup
             return SDL_SetError("Controller is no longer connected");
         }
 
-        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             GCMotion *motion = controller.motion;
             if (motion) {
@@ -1501,7 +1501,7 @@ -(void)cleanup
             controller.playerIndex = -1;
 
 #ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
-            if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
+            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
                 for (id key in controller.physicalInputProfile.buttons) {
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
                     if ([button isBoundToSystemGesture]) {
@@ -1599,7 +1599,7 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
 static void
 GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
 {
-    if (@available(macos 11.0, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
         if (element) {
             [element.sfSymbolsName getCString: name maxLength: 255 encoding: NSASCIIStringEncoding];
         }
@@ -1633,7 +1633,7 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
     elementName[0] = '\0';
 #if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
     if (gamecontroller && SDL_GameControllerGetJoystick(gamecontroller)->driver == &SDL_IOS_JoystickDriver) {
-        if (@available(iOS 14.0, tvOS 14.0, macOS 11.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = SDL_GameControllerGetJoystick(gamecontroller)->hwdata->controller;
             if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
                 NSDictionary<NSString *,GCControllerElement *> *elements = controller.physicalInputProfile.elements;
@@ -1746,7 +1746,7 @@ SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
     elementName[0] = '\0';
 #if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
     if (gamecontroller && SDL_GameControllerGetJoystick(gamecontroller)->driver == &SDL_IOS_JoystickDriver) {
-        if (@available(iOS 14.0, tvOS 14.0, macOS 11.0, *)) {
+        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = SDL_GameControllerGetJoystick(gamecontroller)->hwdata->controller;
             if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
                 NSDictionary<NSString *,GCControllerElement *> *elements = controller.physicalInputProfile.elements;