# HG changeset patch # User Ozkan Sezer # Date 1606216230 -10800 # Node ID 03ed6ca81a74467456d9d9a09b58e6d6e0a5579f # Parent aab8e1ec22e4e81a198c4607a7e2a7800b53c563 SDL_mfijoystick.m: change TARGET_OS_OSX conditions to !TARGET_OS_IOS TARGET_OS_OSX is in 10.12 SDK and newer. Therefore, if building for Mac OS X against an older SDK (e.g. 10.8), unconditionally including SDL_config_iphoneos.h unconditionally defines SDL_JOYSTICK_MFI and the build fails. Also change the macOS version 11.0 checks to be more compatible with older OS targets. diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m --- a/src/joystick/iphoneos/SDL_mfijoystick.m +++ b/src/joystick/iphoneos/SDL_mfijoystick.m @@ -23,7 +23,7 @@ /* This is the iOS implementation of the SDL joystick API */ #include "SDL_mfijoystick_c.h" -#if !TARGET_OS_OSX +#if TARGET_OS_IOS /* needed for SDL_IPHONE_MAX_GFORCE macro */ #include "../../../include/SDL_config_iphoneos.h" #endif @@ -37,7 +37,6 @@ #include "../SDL_joystick_c.h" #include "../usb_ids.h" - #if !SDL_EVENTS_DISABLED #include "../../events/SDL_events_c.h" #endif @@ -45,10 +44,13 @@ #if TARGET_OS_IOS #define SDL_JOYSTICK_iOS_ACCELEROMETER #import + +#else /* TARGET_OS_OSX */ +#include +#include +#ifndef NSAppKitVersionNumber10_15 +#define NSAppKitVersionNumber10_15 1894 #endif - -#if TARGET_OS_OSX -#include #endif #ifdef SDL_JOYSTICK_MFI @@ -64,7 +66,7 @@ * they are only ever used indirectly through objc_msgSend */ @interface GCController (SDL) -#if TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600) +#if !TARGET_OS_IOS && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600) + (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device; #endif @end @@ -470,10 +472,20 @@ } #endif /* TARGET_OS_TV */ +#if TARGET_OS_IOS +static inline int is_macos11 (void) { + return (@available(macos 11.0, *)); +} +#else /* TARGET_OS_OSX */ +static inline int is_macos11 (void) { + return (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15); +} +#endif + static int IOS_JoystickInit(void) { - if (@available(macos 11.0, *)) @autoreleasepool { + if (is_macos11()) @autoreleasepool { #ifdef SDL_JOYSTICK_iOS_ACCELEROMETER if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { /* Default behavior, accelerometer as joystick */ @@ -1370,12 +1382,12 @@ return SDL_FALSE; } -#if TARGET_OS_OSX +#if !TARGET_OS_IOS extern SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device); SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) { #ifdef SDL_JOYSTICK_MFI - if (@available(macOS 11.0, *)) { + if (is_macos11()) { return [GCController supportsHIDDevice:device] ? SDL_TRUE : SDL_FALSE; } #endif