From f61c0f3dc1a8c63c83129a1c3176e00bdbecff87 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 16 Nov 2023 09:19:27 -0800
Subject: [PATCH] SDL_HINT_TV_REMOTE_AS_JOYSTICK should only affect Siri
Remotes on Apple TV
Other gamepads like the iBuffalo Classic USB Gamepad will not have a standard profile, but shouldn't be ignored when this hint is enabled.
---
src/joystick/apple/SDL_mfijoystick.m | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m
index 591da67e290f..1bdc9e17872a 100644
--- a/src/joystick/apple/SDL_mfijoystick.m
+++ b/src/joystick/apple/SDL_mfijoystick.m
@@ -407,6 +407,11 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
#endif
CheckControllerSiriRemote(controller, &device->is_siri_remote);
+ if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) {
+ /* Ignore remotes, they'll be handled as keyboard input */
+ return SDL_FALSE;
+ }
+
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
if ([controller respondsToSelector:@selector(physicalInputProfile)]) {
if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) {
@@ -718,15 +723,6 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet
{
SDL_JoystickDeviceItem *device = deviceList;
-#if TARGET_OS_TV
- if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) {
- /* Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input */
- if (controller && !controller.extendedGamepad && !controller.gamepad && controller.microGamepad) {
- return;
- }
- }
-#endif
-
while (device != NULL) {
if (device->controller == controller) {
return;