From 389bbdabe5baf9bd085ba1b2ed21586b7f23cb66 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 666c1c1cdcb..baaecbb24c5 100644
--- a/src/joystick/iphoneos/SDL_mfijoystick.m
+++ b/src/joystick/iphoneos/SDL_mfijoystick.m
@@ -739,7 +739,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) {
@@ -752,7 +752,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];
@@ -964,7 +964,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];
@@ -1057,7 +1057,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;
@@ -1098,8 +1098,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
@@ -1109,7 +1109,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;
@@ -1125,7 +1125,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) {
@@ -1171,7 +1171,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];
@@ -1271,7 +1271,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];
@@ -1299,7 +1299,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) {
@@ -1329,7 +1329,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) {
@@ -1362,7 +1362,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) {
@@ -1399,7 +1399,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) {
@@ -1432,7 +1432,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) {
@@ -1495,7 +1495,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]) {
@@ -1593,7 +1593,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];
}
@@ -1627,7 +1627,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;
@@ -1740,7 +1740,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;