diff --git a/configure.ac b/configure.ac index 5b357a0bb..843cc171d 100644 --- a/configure.ac +++ b/configure.ac @@ -2823,7 +2823,7 @@ AS_HELP_STRING([--enable-joystick-mfi], [include macOS MFI joystick support [[de AC_MSG_RESULT($enable_joystick_mfi) if test x$enable_joystick_mfi = xyes; then AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ]) - EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-weak" + EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-weak -Wno-unused-command-line-argument" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" fi fi diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m index df5edc303..c7b432489 100644 --- a/src/joystick/iphoneos/SDL_mfijoystick.m +++ b/src/joystick/iphoneos/SDL_mfijoystick.m @@ -39,10 +39,12 @@ #if TARGET_OS_IOS #define SDL_JOYSTICK_iOS_ACCELEROMETER #import -#endif - -#if TARGET_OS_OSX +#else /* TARGET_OS_OSX */ #include +#include +#ifndef NSAppKitVersionNumber10_15 +#define NSAppKitVersionNumber10_15 1894 +#endif #endif #ifdef SDL_JOYSTICK_MFI @@ -464,10 +466,22 @@ SDL_AppleTVRemoteRotationHintChanged(void *udata, const char *name, const char * } #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 */ @@ -1368,7 +1382,7 @@ IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) 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