Skip to content

Commit c53c351

Browse files
jmrootslouken
authored andcommitted
Fix SDL_mfijoystick build issues
Add missing guards around use of physicalInputProfile. Add explicit import of Foundation which seems to be needed on some systems to get the NSArray definition. Add __unsafe_unretained to ObjC types in struct so the compiler doesn't complain about that not being allowed with ARC. Closes: #8979 (cherry picked from commit e0158f6)
1 parent fc787a4 commit c53c351

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/joystick/iphoneos/SDL_mfijoystick.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
378378
NSLog(@"Product name: %@\n", controller.vendorName);
379379
NSLog(@"Product category: %@\n", controller.productCategory);
380380
NSLog(@"Elements available:\n");
381+
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
381382
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
382383
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
383384
for (id key in controller.physicalInputProfile.buttons) {
@@ -390,6 +391,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
390391
NSLog(@"\tHat: %@\n", key);
391392
}
392393
}
394+
#endif
393395
#endif
394396

395397
device->is_xbox = IsControllerXbox(controller);
@@ -1109,7 +1111,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
11091111
Uint8 hatstate = SDL_HAT_CENTERED;
11101112
int i;
11111113

1112-
#ifdef DEBUG_CONTROLLER_STATE
1114+
#if defined(DEBUG_CONTROLLER_STATE) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
11131115
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
11141116
if (controller.physicalInputProfile) {
11151117
for (id key in controller.physicalInputProfile.buttons) {
@@ -1136,6 +1138,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
11361138
}
11371139
#endif /* DEBUG_CONTROLLER_STATE */
11381140

1141+
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
11391142
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
11401143
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
11411144
NSDictionary<NSString *, GCControllerButtonInput *> *buttons = controller.physicalInputProfile.buttons;
@@ -1162,7 +1165,9 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
11621165
}
11631166
SDL_PrivateJoystickButton(joystick, button++, value);
11641167
}
1165-
} else if (controller.extendedGamepad) {
1168+
} else
1169+
#endif
1170+
if (controller.extendedGamepad) {
11661171
SDL_bool isstack;
11671172
GCExtendedGamepad *gamepad = controller.extendedGamepad;
11681173

src/joystick/iphoneos/SDL_mfijoystick_c.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#include "SDL_stdinc.h"
2727
#include "../SDL_sysjoystick.h"
2828

29-
#include <CoreFoundation/CoreFoundation.h>
29+
#import <CoreFoundation/CoreFoundation.h>
30+
#import <Foundation/Foundation.h>
3031

3132
@class GCController;
3233

@@ -59,8 +60,8 @@ typedef struct joystick_hwdata
5960
SDL_bool is_backbone_one;
6061
int is_siri_remote;
6162

62-
NSArray *axes;
63-
NSArray *buttons;
63+
NSArray __unsafe_unretained *axes;
64+
NSArray __unsafe_unretained *buttons;
6465

6566
SDL_bool has_dualshock_touchpad;
6667
SDL_bool has_xbox_paddles;

0 commit comments

Comments
 (0)