Fixed building on Mac OS X on the command line and with an older macOS SDK

This commit is contained in:
Sam Lantinga
2020-11-21 14:13:26 -08:00
parent 1df593fb16
commit fd89446782
9 changed files with 104 additions and 86 deletions

View File

@@ -28,7 +28,7 @@
#include "../SDL_syshaptic.h"
#include "SDL_joystick.h"
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
#include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */
#include "../../joystick/darwin/SDL_iokitjoystick_c.h" /* For joystick hwdata */
#include "SDL_syshaptic_c.h"
#include <IOKit/IOKitLib.h>

View File

@@ -26,7 +26,7 @@
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
#include "SDL_sysjoystick_c.h"
#include "SDL_iokitjoystick_c.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
#include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */

View File

@@ -21,7 +21,7 @@
#include "../../SDL_internal.h"
/* This is the iOS implementation of the SDL joystick API */
#include "SDL_sysjoystick_c.h"
#include "SDL_mfijoystick_c.h"
#if !TARGET_OS_OSX
/* needed for SDL_IPHONE_MAX_GFORCE macro */
@@ -46,6 +46,10 @@
#import <CoreMotion/CoreMotion.h>
#endif
#if TARGET_OS_OSX
#include <IOKit/hid/IOHIDManager.h>
#endif
#ifdef SDL_JOYSTICK_MFI
#import <GameController/GameController.h>
@@ -58,6 +62,11 @@ static id disconnectObserver = nil;
/* remove compilation warnings for strict builds by defining these selectors, even though
* they are only ever used indirectly through objc_msgSend
*/
@interface GCController (SDL)
#if TARGET_OS_OSX && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600)
+ (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device;
#endif
@end
@interface GCExtendedGamepad (SDL)
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 121000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 121000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1401000))
@property (nonatomic, readonly, nullable) GCControllerButtonInput *leftThumbstickButton;
@@ -1359,7 +1368,7 @@ extern SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device);
SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
{
if (@available(macOS 11.0, *)) {
return [GCController supportsHIDDevice:device] ? SDL_TRUE: SDL_FALSE;
return [GCController supportsHIDDevice:device] ? SDL_TRUE : SDL_FALSE;
} else {
return SDL_FALSE;
}