Browse Source

Update references to macOS 10.16 to macOS 11.0

Fixes api availability compiler warnings when building the joystick subsystem for macOS versions older than 11.0. The compiler expects the version number passed into @available and API_AVAILABLE macros to be greater than or equal to 11.0, which 10.16 is not. (Even though 10.16 and 11.0 are semantically equivalent, the compiler doesn't know this.)
Dan Andrus 5 months ago
parent
commit
6d0fdb627e
1 changed files with 31 additions and 31 deletions
  1. 31 31
      src/joystick/apple/SDL_mfijoystick.m

+ 31 - 31
src/joystick/apple/SDL_mfijoystick.m

@@ -320,7 +320,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
     NSLog(@"Product name: %@\n", controller.vendorName);
     NSLog(@"Product name: %@\n", controller.vendorName);
     NSLog(@"Product category: %@\n", controller.productCategory);
     NSLog(@"Product category: %@\n", controller.productCategory);
     NSLog(@"Elements available:\n");
     NSLog(@"Elements available:\n");
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
         NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
         for (id key in controller.physicalInputProfile.buttons) {
         for (id key in controller.physicalInputProfile.buttons) {
             NSLog(@"\tButton: %@ (%s)\n", key, elements[key].analog ? "analog" : "digital");
             NSLog(@"\tButton: %@ (%s)\n", key, elements[key].analog ? "analog" : "digital");
@@ -370,7 +370,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
         return false;
         return false;
     }
     }
 
 
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) {
         if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) {
             device->has_dualshock_touchpad = TRUE;
             device->has_dualshock_touchpad = TRUE;
         }
         }
@@ -425,7 +425,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
     } else if (device->is_switch_joyconR) {
     } else if (device->is_switch_joyconR) {
         vendor = USB_VENDOR_NINTENDO;
         vendor = USB_VENDOR_NINTENDO;
         product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT;
         product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT;
-    } else if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    } else if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         vendor = USB_VENDOR_APPLE;
         vendor = USB_VENDOR_APPLE;
         product = 4;
         product = 4;
         subtype = 4;
         subtype = 4;
@@ -448,7 +448,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
         return false;
         return false;
     }
     }
 
 
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
         NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
 
 
         // Provide both axes and analog buttons as SDL axes
         // Provide both axes and analog buttons as SDL axes
@@ -579,7 +579,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
     }
     }
 
 
     Uint16 signature;
     Uint16 signature;
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         signature = 0;
         signature = 0;
         signature = SDL_crc16(signature, device->name, SDL_strlen(device->name));
         signature = SDL_crc16(signature, device->name, SDL_strlen(device->name));
         for (id key in device->axes) {
         for (id key in device->axes) {
@@ -733,7 +733,7 @@ static bool IOS_JoystickInit(void)
     }
     }
 
 
 #ifdef SDL_PLATFORM_MACOS
 #ifdef SDL_PLATFORM_MACOS
-    if (@available(macOS 10.16, *)) {
+    if (@available(macOS 11.0, *)) {
         // Continue with initialization on macOS 11+
         // Continue with initialization on macOS 11+
     } else {
     } else {
         return true;
         return true;
@@ -895,7 +895,7 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
             };
             };
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = joystick->hwdata->controller;
             GCController *controller = joystick->hwdata->controller;
             GCMotion *motion = controller.motion;
             GCMotion *motion = controller.motion;
             if (motion && motion.hasRotationRate) {
             if (motion && motion.hasRotationRate) {
@@ -906,7 +906,7 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
             }
             }
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = joystick->hwdata->controller;
             GCController *controller = joystick->hwdata->controller;
             for (id key in controller.physicalInputProfile.buttons) {
             for (id key in controller.physicalInputProfile.buttons) {
                 GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
                 GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
@@ -916,7 +916,7 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
             }
             }
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             GCController *controller = device->controller;
             if (controller.light) {
             if (controller.light) {
                 SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true);
                 SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true);
@@ -977,7 +977,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
         Uint64 timestamp = SDL_GetTicksNS();
         Uint64 timestamp = SDL_GetTicksNS();
 
 
 #ifdef DEBUG_CONTROLLER_STATE
 #ifdef DEBUG_CONTROLLER_STATE
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             if (controller.physicalInputProfile) {
             if (controller.physicalInputProfile) {
                 for (id key in controller.physicalInputProfile.buttons) {
                 for (id key in controller.physicalInputProfile.buttons) {
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
@@ -1003,7 +1003,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
         }
         }
 #endif // DEBUG_CONTROLLER_STATE
 #endif // DEBUG_CONTROLLER_STATE
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             NSDictionary<NSString *, GCControllerButtonInput *> *buttons = controller.physicalInputProfile.buttons;
             NSDictionary<NSString *, GCControllerButtonInput *> *buttons = controller.physicalInputProfile.buttons;
 
 
@@ -1133,7 +1133,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             }
             }
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             if (device->has_dualshock_touchpad) {
             if (device->has_dualshock_touchpad) {
                 GCControllerDirectionPad *dpad;
                 GCControllerDirectionPad *dpad;
 
 
@@ -1153,7 +1153,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             }
             }
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCMotion *motion = controller.motion;
             GCMotion *motion = controller.motion;
             if (motion && motion.sensorsActive) {
             if (motion && motion.sensorsActive) {
                 float data[3];
                 float data[3];
@@ -1175,7 +1175,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             }
             }
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCDeviceBattery *battery = controller.battery;
             GCDeviceBattery *battery = controller.battery;
             if (battery) {
             if (battery) {
                 SDL_PowerState state = SDL_POWERSTATE_UNKNOWN;
                 SDL_PowerState state = SDL_POWERSTATE_UNKNOWN;
@@ -1204,8 +1204,8 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
 
 
 #ifdef SDL_JOYSTICK_MFI
 #ifdef SDL_JOYSTICK_MFI
 @interface SDL3_RumbleMotor : NSObject
 @interface SDL3_RumbleMotor : NSObject
-@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(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 bool active;
 @property bool active;
 @end
 @end
 
 
@@ -1216,7 +1216,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
 - (void)cleanup
 - (void)cleanup
 {
 {
     @autoreleasepool {
     @autoreleasepool {
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             if (self.player != nil) {
             if (self.player != nil) {
                 [self.player cancelAndReturnError:nil];
                 [self.player cancelAndReturnError:nil];
                 self.player = nil;
                 self.player = nil;
@@ -1232,7 +1232,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
 - (bool)setIntensity:(float)intensity
 - (bool)setIntensity:(float)intensity
 {
 {
     @autoreleasepool {
     @autoreleasepool {
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             NSError *error = nil;
             NSError *error = nil;
             CHHapticDynamicParameter *param;
             CHHapticDynamicParameter *param;
 
 
@@ -1279,7 +1279,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
     }
     }
 }
 }
 
 
-- (id)initWithController:(GCController *)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0))
+- (id)initWithController:(GCController *)controller locality:(GCHapticsLocality)locality API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
 {
 {
     @autoreleasepool {
     @autoreleasepool {
         NSError *error;
         NSError *error;
@@ -1381,7 +1381,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
 static SDL3_RumbleContext *IOS_JoystickInitRumble(GCController *controller)
 static SDL3_RumbleContext *IOS_JoystickInitRumble(GCController *controller)
 {
 {
     @autoreleasepool {
     @autoreleasepool {
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             SDL3_RumbleMotor *low_frequency_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftHandle];
             SDL3_RumbleMotor *low_frequency_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftHandle];
             SDL3_RumbleMotor *high_frequency_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityRightHandle];
             SDL3_RumbleMotor *high_frequency_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityRightHandle];
             SDL3_RumbleMotor *left_trigger_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftTrigger];
             SDL3_RumbleMotor *left_trigger_motor = [[SDL3_RumbleMotor alloc] initWithController:controller locality:GCHapticsLocalityLeftTrigger];
@@ -1408,7 +1408,7 @@ static bool IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumb
         return SDL_SetError("Controller is no longer connected");
         return SDL_SetError("Controller is no longer connected");
     }
     }
 
 
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         if (!device->rumble && device->controller && device->controller.haptics) {
         if (!device->rumble && device->controller && device->controller.haptics) {
             SDL3_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             SDL3_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             if (rumble) {
             if (rumble) {
@@ -1434,7 +1434,7 @@ static bool IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumbl
         return SDL_SetError("Controller is no longer connected");
         return SDL_SetError("Controller is no longer connected");
     }
     }
 
 
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         if (!device->rumble && device->controller && device->controller.haptics) {
         if (!device->rumble && device->controller && device->controller.haptics) {
             SDL3_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             SDL3_RumbleContext *rumble = IOS_JoystickInitRumble(device->controller);
             if (rumble) {
             if (rumble) {
@@ -1460,7 +1460,7 @@ static bool IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, U
             return SDL_SetError("Controller is no longer connected");
             return SDL_SetError("Controller is no longer connected");
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             GCController *controller = device->controller;
             GCDeviceLight *light = controller.light;
             GCDeviceLight *light = controller.light;
             if (light) {
             if (light) {
@@ -1488,7 +1488,7 @@ static bool IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled)
             return SDL_SetError("Controller is no longer connected");
             return SDL_SetError("Controller is no longer connected");
         }
         }
 
 
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = device->controller;
             GCController *controller = device->controller;
             GCMotion *motion = controller.motion;
             GCMotion *motion = controller.motion;
             if (motion) {
             if (motion) {
@@ -1539,7 +1539,7 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
             controller.controllerPausedHandler = nil;
             controller.controllerPausedHandler = nil;
             controller.playerIndex = -1;
             controller.playerIndex = -1;
 
 
-            if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+            if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
                 for (id key in controller.physicalInputProfile.buttons) {
                 for (id key in controller.physicalInputProfile.buttons) {
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
                     GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
                     if ([button isBoundToSystemGesture]) {
                     if ([button isBoundToSystemGesture]) {
@@ -1593,7 +1593,7 @@ static bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *
         return false;
         return false;
     }
     }
 
 
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         int axis = 0;
         int axis = 0;
         for (id key in device->axes) {
         for (id key in device->axes) {
             if ([(NSString *)key isEqualToString:@"Left Thumbstick X Axis"] ||
             if ([(NSString *)key isEqualToString:@"Left Thumbstick X Axis"] ||
@@ -1730,7 +1730,7 @@ bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
         return false;
         return false;
     }
     }
 
 
-    if (@available(macOS 10.16, *)) {
+    if (@available(macOS 11.0, *)) {
         const int MAX_ATTEMPTS = 3;
         const int MAX_ATTEMPTS = 3;
         for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
         for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
             if ([GCController supportsHIDDevice:device]) {
             if ([GCController supportsHIDDevice:device]) {
@@ -1749,7 +1749,7 @@ bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
 /* NOLINTNEXTLINE(readability-non-const-parameter): getCString takes a non-const char* */
 /* NOLINTNEXTLINE(readability-non-const-parameter): getCString takes a non-const char* */
 static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
 static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
 {
 {
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         if (element) {
         if (element) {
             [element.sfSymbolsName getCString:name maxLength:255 encoding:NSASCIIStringEncoding];
             [element.sfSymbolsName getCString:name maxLength:255 encoding:NSASCIIStringEncoding];
         }
         }
@@ -1758,7 +1758,7 @@ static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *
 
 
 static GCControllerDirectionPad *GetDirectionalPadForController(GCController *controller)
 static GCControllerDirectionPad *GetDirectionalPadForController(GCController *controller)
 {
 {
-    if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+    if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
         return controller.physicalInputProfile.dpads[GCInputDirectionPad];
         return controller.physicalInputProfile.dpads[GCInputDirectionPad];
     }
     }
 
 
@@ -1781,7 +1781,7 @@ const char *IOS_GetAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_Gamepad
 
 
 #ifdef SDL_JOYSTICK_MFI
 #ifdef SDL_JOYSTICK_MFI
     if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
     if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
             GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             switch (button) {
             switch (button) {
@@ -1897,7 +1897,7 @@ const char *IOS_GetAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAx
 
 
 #ifdef SDL_JOYSTICK_MFI
 #ifdef SDL_JOYSTICK_MFI
     if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
     if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
-        if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
+        if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
             GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
             GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
             switch (axis) {
             switch (axis) {