Fixed trying to use @available() on older SDK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
diff --git a/configure.ac b/configure.ac
index 5b357a0..843cc17 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 df5edc3..c7b4324 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 <CoreMotion/CoreMotion.h>
-#endif
-
-#if TARGET_OS_OSX
+#else /* TARGET_OS_OSX */
#include <IOKit/hid/IOHIDManager.h>
+#include <AppKit/NSApplication.h>
+#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