Skip to content

Commit

Permalink
Check for macOS 10.16 to support apps built with older macOS SDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlfriess authored and sezero committed May 19, 2022
1 parent fd75065 commit 389bbda
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/joystick/iphoneos/SDL_mfijoystick.m
Expand Up @@ -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) {
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 389bbda

Please sign in to comment.