Skip to content

Commit ffe194c

Browse files
committed
Fixed build when SDL_JOYSTICK_MFI isn't enabled
1 parent a4547fe commit ffe194c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/joystick/apple/SDL_mfijoystick.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
#endif
4343
#endif // SDL_PLATFORM_MACOS
4444

45-
#ifdef SDL_JOYSTICK_MFI
4645
#import <GameController/GameController.h>
4746

47+
#ifdef SDL_JOYSTICK_MFI
4848
static id connectObserver = nil;
4949
static id disconnectObserver = nil;
5050

@@ -1201,6 +1201,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
12011201
#endif // SDL_JOYSTICK_MFI
12021202
}
12031203

1204+
#ifdef SDL_JOYSTICK_MFI
12041205
@interface SDL3_RumbleMotor : NSObject
12051206
@property(nonatomic, strong) CHHapticEngine *engine API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0));
12061207
@property(nonatomic, strong) id<CHHapticPatternPlayer> player API_AVAILABLE(macos(10.16), ios(13.0), tvos(14.0));
@@ -1395,8 +1396,11 @@ - (void)cleanup
13951396
return nil;
13961397
}
13971398

1399+
#endif // SDL_JOYSTICK_MFI
1400+
13981401
static bool IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
13991402
{
1403+
#ifdef SDL_JOYSTICK_MFI
14001404
SDL_JoystickDeviceItem *device = joystick->hwdata;
14011405

14021406
if (device == NULL) {
@@ -1415,13 +1419,14 @@ static bool IOS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumb
14151419
if (device->rumble) {
14161420
SDL3_RumbleContext *rumble = (__bridge SDL3_RumbleContext *)device->rumble;
14171421
return [rumble rumbleWithLowFrequency:low_frequency_rumble andHighFrequency:high_frequency_rumble];
1418-
} else {
1419-
return SDL_Unsupported();
14201422
}
1423+
#endif
1424+
return SDL_Unsupported();
14211425
}
14221426

14231427
static bool IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
14241428
{
1429+
#ifdef SDL_JOYSTICK_MFI
14251430
SDL_JoystickDeviceItem *device = joystick->hwdata;
14261431

14271432
if (device == NULL) {
@@ -1440,9 +1445,9 @@ static bool IOS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumbl
14401445
if (device->rumble) {
14411446
SDL3_RumbleContext *rumble = (__bridge SDL3_RumbleContext *)device->rumble;
14421447
return [rumble rumbleLeftTrigger:left_rumble andRightTrigger:right_rumble];
1443-
} else {
1444-
return SDL_Unsupported();
14451448
}
1449+
#endif
1450+
return SDL_Unsupported();
14461451
}
14471452

14481453
static bool IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
@@ -1465,7 +1470,6 @@ static bool IOS_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, U
14651470
}
14661471
}
14671472
}
1468-
14691473
return SDL_Unsupported();
14701474
}
14711475

@@ -1519,6 +1523,7 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
15191523

15201524
device->joystick = NULL;
15211525

1526+
#ifdef SDL_JOYSTICK_MFI
15221527
@autoreleasepool {
15231528
if (device->rumble) {
15241529
SDL3_RumbleContext *rumble = (__bridge SDL3_RumbleContext *)device->rumble;
@@ -1529,7 +1534,6 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
15291534
}
15301535

15311536
if (device->controller) {
1532-
#ifdef SDL_JOYSTICK_MFI
15331537
GCController *controller = device->controller;
15341538
controller.controllerPausedHandler = nil;
15351539
controller.playerIndex = -1;
@@ -1542,9 +1546,10 @@ static void IOS_JoystickClose(SDL_Joystick *joystick)
15421546
}
15431547
}
15441548
}
1545-
#endif // SDL_JOYSTICK_MFI
15461549
}
15471550
}
1551+
#endif // SDL_JOYSTICK_MFI
1552+
15481553
if (device->is_siri_remote) {
15491554
--SDL_AppleTVRemoteOpenedAsJoystick;
15501555
}

0 commit comments

Comments
 (0)