mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-16 06:45:59 +00:00
Bumped deployment requirements for Apple platforms
We require at least Xcode 12.2 and macOS SDK 11 to build. We support deploying to macOS 10.13, iOS 11.0, and tvOS 11.0. This cleans up the code significantly
This commit is contained in:
@@ -48,66 +48,18 @@
|
||||
static id connectObserver = nil;
|
||||
static id disconnectObserver = nil;
|
||||
|
||||
#include <Availability.h>
|
||||
#include <objc/message.h>
|
||||
|
||||
#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
#define __IPHONE_OS_VERSION_MAX_ALLOWED 0
|
||||
#endif
|
||||
|
||||
#ifndef __APPLETV_OS_VERSION_MAX_ALLOWED
|
||||
#define __APPLETV_OS_VERSION_MAX_ALLOWED 0
|
||||
#endif
|
||||
|
||||
#ifndef __MAC_OS_VERSION_MAX_ALLOWED
|
||||
#define __MAC_OS_VERSION_MAX_ALLOWED 0
|
||||
#endif
|
||||
|
||||
/* 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 defined(SDL_PLATFORM_MACOS) && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600)
|
||||
+ (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device;
|
||||
#endif
|
||||
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000))
|
||||
@property(nonatomic, readonly) NSString *productCategory;
|
||||
#endif
|
||||
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140500) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140500) || (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110300))
|
||||
@property(class, nonatomic, readwrite) BOOL shouldMonitorBackgroundEvents;
|
||||
#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;
|
||||
@property(nonatomic, readonly, nullable) GCControllerButtonInput *rightThumbstickButton;
|
||||
#endif
|
||||
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000))
|
||||
@property(nonatomic, readonly) GCControllerButtonInput *buttonMenu;
|
||||
@property(nonatomic, readonly, nullable) GCControllerButtonInput *buttonOptions;
|
||||
#endif
|
||||
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140000) || (__MAC_OS_VERSION_MAX_ALLOWED > 1500000))
|
||||
@property(nonatomic, readonly, nullable) GCControllerButtonInput *buttonHome;
|
||||
#endif
|
||||
@end
|
||||
@interface GCMicroGamepad (SDL)
|
||||
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000))
|
||||
@property(nonatomic, readonly) GCControllerButtonInput *buttonMenu;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140000) || (__MAC_OS_VERSION_MAX_ALLOWED > 1500000) || (__MAC_OS_X_VERSION_MAX_ALLOWED > 101600)
|
||||
#define ENABLE_MFI_BATTERY
|
||||
#define ENABLE_MFI_RUMBLE
|
||||
#define ENABLE_MFI_LIGHT
|
||||
#define ENABLE_MFI_SENSORS
|
||||
#define ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||
#define ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
#import <CoreHaptics/CoreHaptics.h>
|
||||
#endif
|
||||
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
|
||||
@@ -234,7 +186,6 @@ static void CheckControllerSiriRemote(GCController *controller, int *is_siri_rem
|
||||
*is_siri_remote = 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
static bool ElementAlreadyHandled(SDL_JoystickDeviceItem *device, NSString *element, NSDictionary<NSString *, GCControllerElement *> *elements)
|
||||
{
|
||||
if ([element isEqualToString:@"Left Thumbstick Left"] ||
|
||||
@@ -333,7 +284,6 @@ static bool ElementAlreadyHandled(SDL_JoystickDeviceItem *device, NSString *elem
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
|
||||
static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller)
|
||||
{
|
||||
@@ -366,7 +316,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
NSLog(@"Product name: %@\n", controller.vendorName);
|
||||
NSLog(@"Product category: %@\n", controller.productCategory);
|
||||
NSLog(@"Elements available:\n");
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
for (id key in controller.physicalInputProfile.buttons) {
|
||||
@@ -379,8 +328,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
NSLog(@"\tHat: %@\n", key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // DEBUG_CONTROLLER_PROFILE
|
||||
|
||||
device->is_xbox = IsControllerXbox(controller);
|
||||
device->is_ps4 = IsControllerPS4(controller);
|
||||
@@ -416,7 +364,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) {
|
||||
device->has_dualshock_touchpad = TRUE;
|
||||
@@ -428,7 +375,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
device->has_xbox_share_button = TRUE;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
|
||||
if (device->is_backbone_one) {
|
||||
vendor = USB_VENDOR_BACKBONE;
|
||||
@@ -473,20 +419,14 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
} else if (device->is_switch_joyconR) {
|
||||
vendor = USB_VENDOR_NINTENDO;
|
||||
product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT;
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
} else if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
vendor = USB_VENDOR_APPLE;
|
||||
product = 4;
|
||||
subtype = 4;
|
||||
#endif
|
||||
} else if (controller.extendedGamepad) {
|
||||
vendor = USB_VENDOR_APPLE;
|
||||
product = 1;
|
||||
subtype = 1;
|
||||
} else if (controller.gamepad) {
|
||||
vendor = USB_VENDOR_APPLE;
|
||||
product = 2;
|
||||
subtype = 2;
|
||||
#ifdef SDL_PLATFORM_TVOS
|
||||
} else if (controller.microGamepad) {
|
||||
vendor = USB_VENDOR_APPLE;
|
||||
@@ -502,7 +442,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
|
||||
@@ -558,9 +497,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
device->pause_button_index = (int)[device->buttons indexOfObject:GCInputButtonMenu];
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
if (controller.extendedGamepad) {
|
||||
} else if (controller.extendedGamepad) {
|
||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||
int nbuttons = 0;
|
||||
BOOL has_direct_menu = FALSE;
|
||||
@@ -612,24 +549,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
device->naxes = 6; // 2 thumbsticks and 2 triggers
|
||||
device->nhats = 1; // d-pad
|
||||
device->nbuttons = nbuttons;
|
||||
|
||||
} else if (controller.gamepad) {
|
||||
int nbuttons = 0;
|
||||
|
||||
// These buttons are part of the original MFi spec
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_SOUTH);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_EAST);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_WEST);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_NORTH);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
||||
device->button_mask |= (1 << SDL_GAMEPAD_BUTTON_START);
|
||||
nbuttons += 7;
|
||||
device->pause_button_index = (nbuttons - 1);
|
||||
|
||||
device->naxes = 0; // no traditional analog inputs
|
||||
device->nhats = 1; // d-pad
|
||||
device->nbuttons = nbuttons;
|
||||
}
|
||||
#ifdef SDL_PLATFORM_TVOS
|
||||
else if (controller.microGamepad) {
|
||||
@@ -677,7 +596,7 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
}
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
|
||||
#if defined(SDL_JOYSTICK_MFI)
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
static void IOS_AddJoystickDevice(GCController *controller)
|
||||
{
|
||||
SDL_JoystickDeviceItem *device = deviceList;
|
||||
@@ -975,7 +894,6 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MFI_SENSORS
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = joystick->hwdata->controller;
|
||||
GCMotion *motion = controller.motion;
|
||||
@@ -986,9 +904,7 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_SENSORS
|
||||
|
||||
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = joystick->hwdata->controller;
|
||||
for (id key in controller.physicalInputProfile.buttons) {
|
||||
@@ -998,17 +914,13 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = device->controller;
|
||||
#ifdef ENABLE_MFI_LIGHT
|
||||
if (controller.light) {
|
||||
SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
if (controller.haptics) {
|
||||
for (GCHapticsLocality locality in controller.haptics.supportedLocalities) {
|
||||
if ([locality isEqualToString:GCHapticsLocalityHandles]) {
|
||||
@@ -1018,7 +930,6 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
}
|
||||
@@ -1064,7 +975,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
int i;
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
#if defined(DEBUG_CONTROLLER_STATE) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
||||
#ifdef DEBUG_CONTROLLER_STATE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
if (controller.physicalInputProfile) {
|
||||
for (id key in controller.physicalInputProfile.buttons) {
|
||||
@@ -1091,7 +1002,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
#endif // DEBUG_CONTROLLER_STATE
|
||||
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
NSDictionary<NSString *, GCControllerButtonInput *> *buttons = controller.physicalInputProfile.buttons;
|
||||
@@ -1118,9 +1028,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
SDL_SendJoystickButton(timestamp, joystick, button++, down);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (controller.extendedGamepad) {
|
||||
} else if (controller.extendedGamepad) {
|
||||
bool isstack;
|
||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||
|
||||
@@ -1185,33 +1093,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
}
|
||||
|
||||
SDL_small_free(buttons, isstack);
|
||||
} else if (controller.gamepad) {
|
||||
bool isstack;
|
||||
GCGamepad *gamepad = controller.gamepad;
|
||||
|
||||
// Button order matches the XInput Windows mappings.
|
||||
bool *buttons = SDL_small_alloc(bool, joystick->nbuttons, &isstack);
|
||||
int button_count = 0;
|
||||
|
||||
if (buttons == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
buttons[button_count++] = gamepad.buttonA.isPressed;
|
||||
buttons[button_count++] = gamepad.buttonB.isPressed;
|
||||
buttons[button_count++] = gamepad.buttonX.isPressed;
|
||||
buttons[button_count++] = gamepad.buttonY.isPressed;
|
||||
buttons[button_count++] = gamepad.leftShoulder.isPressed;
|
||||
buttons[button_count++] = gamepad.rightShoulder.isPressed;
|
||||
buttons[button_count++] = (device->pause_button_pressed > 0);
|
||||
|
||||
hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad);
|
||||
|
||||
for (i = 0; i < button_count; i++) {
|
||||
SDL_SendJoystickButton(timestamp, joystick, i, buttons[i]);
|
||||
}
|
||||
|
||||
SDL_small_free(buttons, isstack);
|
||||
}
|
||||
#ifdef SDL_PLATFORM_TVOS
|
||||
@@ -1251,7 +1132,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
if (device->has_dualshock_touchpad) {
|
||||
GCControllerDirectionPad *dpad;
|
||||
@@ -1271,33 +1151,29 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
|
||||
#ifdef ENABLE_MFI_SENSORS
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCMotion *motion = controller.motion;
|
||||
if (motion && motion.sensorsActive) {
|
||||
float data[3];
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCMotion *motion = controller.motion;
|
||||
if (motion && motion.sensorsActive) {
|
||||
float data[3];
|
||||
|
||||
if (motion.hasRotationRate) {
|
||||
GCRotationRate rate = motion.rotationRate;
|
||||
data[0] = rate.x;
|
||||
data[1] = rate.z;
|
||||
data[2] = -rate.y;
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
|
||||
}
|
||||
if (motion.hasGravityAndUserAcceleration) {
|
||||
GCAcceleration accel = motion.acceleration;
|
||||
data[0] = -accel.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = -accel.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = -accel.z * SDL_STANDARD_GRAVITY;
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
|
||||
}
|
||||
if (motion.hasRotationRate) {
|
||||
GCRotationRate rate = motion.rotationRate;
|
||||
data[0] = rate.x;
|
||||
data[1] = rate.z;
|
||||
data[2] = -rate.y;
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, timestamp, data, 3);
|
||||
}
|
||||
if (motion.hasGravityAndUserAcceleration) {
|
||||
GCAcceleration accel = motion.acceleration;
|
||||
data[0] = -accel.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = -accel.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = -accel.z * SDL_STANDARD_GRAVITY;
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, data, 3);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_SENSORS
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MFI_BATTERY
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCDeviceBattery *battery = controller.battery;
|
||||
if (battery) {
|
||||
@@ -1321,13 +1197,10 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||
SDL_SendJoystickPowerInfo(joystick, state, percent);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_BATTERY
|
||||
}
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
|
||||
@interface SDL3_RumbleMotor : NSObject
|
||||
@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));
|
||||
@@ -1522,11 +1395,8 @@ static SDL3_RumbleContext *IOS_JoystickInitRumble(GCController *controller)
|
||||
return nil;
|
||||
}
|
||||
|
||||
#endif // ENABLE_MFI_RUMBLE
|
||||
|
||||
static bool IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
{
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
SDL_JoystickDeviceItem *device = joystick->hwdata;
|
||||
|
||||
if (device == NULL) {
|
||||
@@ -1548,14 +1418,10 @@ static bool IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumb
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
#else
|
||||
return SDL_Unsupported();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
{
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
SDL_JoystickDeviceItem *device = joystick->hwdata;
|
||||
|
||||
if (device == NULL) {
|
||||
@@ -1577,14 +1443,10 @@ static bool IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumbl
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
#else
|
||||
return SDL_Unsupported();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
#ifdef ENABLE_MFI_LIGHT
|
||||
@autoreleasepool {
|
||||
SDL_JoystickDeviceItem *device = joystick->hwdata;
|
||||
|
||||
@@ -1603,7 +1465,6 @@ static bool IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, U
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_LIGHT
|
||||
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -1615,7 +1476,6 @@ static bool IOS_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int
|
||||
|
||||
static bool IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled)
|
||||
{
|
||||
#ifdef ENABLE_MFI_SENSORS
|
||||
@autoreleasepool {
|
||||
SDL_JoystickDeviceItem *device = joystick->hwdata;
|
||||
|
||||
@@ -1632,7 +1492,6 @@ static bool IOS_JoystickSetSensorsEnabled(SDL_Joystick *joystick, bool enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_SENSORS
|
||||
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -1661,7 +1520,6 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
|
||||
device->joystick = NULL;
|
||||
|
||||
@autoreleasepool {
|
||||
#ifdef ENABLE_MFI_RUMBLE
|
||||
if (device->rumble) {
|
||||
SDL3_RumbleContext *rumble = (__bridge SDL3_RumbleContext *)device->rumble;
|
||||
|
||||
@@ -1669,7 +1527,6 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
|
||||
CFRelease(device->rumble);
|
||||
device->rumble = NULL;
|
||||
}
|
||||
#endif // ENABLE_MFI_RUMBLE
|
||||
|
||||
if (device->controller) {
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
@@ -1677,7 +1534,6 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
|
||||
controller.controllerPausedHandler = nil;
|
||||
controller.playerIndex = -1;
|
||||
|
||||
#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
for (id key in controller.physicalInputProfile.buttons) {
|
||||
GCControllerButtonInput *button = controller.physicalInputProfile.buttons[key];
|
||||
@@ -1686,8 +1542,6 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MFI_SYSTEM_GESTURE_STATE
|
||||
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
}
|
||||
}
|
||||
@@ -1728,7 +1582,6 @@ static void IOS_JoystickQuit(void)
|
||||
|
||||
static bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
{
|
||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
|
||||
if (device == NULL) {
|
||||
return false;
|
||||
@@ -1861,8 +1714,6 @@ static bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1888,7 +1739,7 @@ bool IOS_SupportedHIDDevice(IOHIDDeviceRef device)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
/* NOLINTNEXTLINE(readability-non-const-parameter): getCString takes a non-const char* */
|
||||
static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char *name)
|
||||
{
|
||||
@@ -1909,132 +1760,126 @@ static GCControllerDirectionPad *GetDirectionalPadForController(GCController *co
|
||||
return controller.extendedGamepad.dpad;
|
||||
}
|
||||
|
||||
if (controller.gamepad) {
|
||||
return controller.gamepad.dpad;
|
||||
}
|
||||
|
||||
if (controller.microGamepad) {
|
||||
return controller.microGamepad.dpad;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
#endif // SDL_JOYSTICK_MFI && ENABLE_PHYSICAL_INPUT_PROFILE
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
|
||||
const char *IOS_GetAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
|
||||
{
|
||||
char elementName[256];
|
||||
elementName[0] = '\0';
|
||||
|
||||
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
|
||||
if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonA], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_EAST:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonB], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_WEST:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonX], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_NORTH:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonY], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_BACK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonOptions], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_GUIDE:
|
||||
GetAppleSFSymbolsNameForElement(elements[@"Button Home"], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_START:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonMenu], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_STICK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstickButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_STICK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstickButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftShoulder], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightShoulder], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_UP:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.up, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.up.fill", sizeof(elementName));
|
||||
}
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonA], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_EAST:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonB], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_WEST:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonX], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_NORTH:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonY], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_BACK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonOptions], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_GUIDE:
|
||||
GetAppleSFSymbolsNameForElement(elements[@"Button Home"], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_START:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputButtonMenu], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_STICK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstickButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_STICK:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstickButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftShoulder], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightShoulder], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_UP:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.up, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.up.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_DOWN:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.down, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.down.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_DOWN:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.down, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.down.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_LEFT:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.left, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.left.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_LEFT:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.left, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.left.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.right, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.right.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
|
||||
{
|
||||
GCControllerDirectionPad *dpad = GetDirectionalPadForController(controller);
|
||||
if (dpad) {
|
||||
GetAppleSFSymbolsNameForElement(dpad.right, elementName);
|
||||
if (SDL_strlen(elementName) == 0) {
|
||||
SDL_strlcpy(elementName, "dpad.right.fill", sizeof(elementName));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_MISC1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputDualShockTouchpadButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleOne], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleThree], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleTwo], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE2:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleFour], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputDualShockTouchpadButton], elementName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_MISC1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputDualShockTouchpadButton], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleOne], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE1:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleThree], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleTwo], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_PADDLE2:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputXboxPaddleFour], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputDualShockTouchpadButton], elementName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
|
||||
return *elementName ? SDL_GetPersistentString(elementName) : NULL;
|
||||
}
|
||||
@@ -2044,38 +1889,37 @@ const char *IOS_GetAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAx
|
||||
char elementName[256];
|
||||
elementName[0] = '\0';
|
||||
|
||||
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
|
||||
#ifdef SDL_JOYSTICK_MFI
|
||||
if (gamepad && SDL_GetGamepadJoystick(gamepad)->driver == &SDL_IOS_JoystickDriver) {
|
||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||
GCController *controller = SDL_GetGamepadJoystick(gamepad)->hwdata->controller;
|
||||
if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
switch (axis) {
|
||||
case SDL_GAMEPAD_AXIS_LEFTX:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_LEFTY:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHTX:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHTY:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_LEFT_TRIGGER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftTrigger], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightTrigger], elementName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||
switch (axis) {
|
||||
case SDL_GAMEPAD_AXIS_LEFTX:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_LEFTY:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHTX:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHTY:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightThumbstick], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_LEFT_TRIGGER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputLeftTrigger], elementName);
|
||||
break;
|
||||
case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER:
|
||||
GetAppleSFSymbolsNameForElement(elements[GCInputRightTrigger], elementName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // SDL_JOYSTICK_MFI
|
||||
|
||||
return *elementName ? SDL_GetPersistentString(elementName) : NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user