Browse Source

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.
Sam Lantinga 1 year ago
parent
commit
f61c0f3dc1
1 changed files with 5 additions and 9 deletions
  1. 5 9
      src/joystick/apple/SDL_mfijoystick.m

+ 5 - 9
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;