Browse Source

Set window controller interaction on all windows

We should update all windows, not just the ones in the active scene
Sam Lantinga 3 months ago
parent
commit
54b15532d3
1 changed files with 9 additions and 6 deletions
  1. 9 6
      src/video/uikit/SDL_uikitvideo.m

+ 9 - 6
src/video/uikit/SDL_uikitvideo.m

@@ -294,13 +294,16 @@ UIWindowScene *UIKit_GetActiveWindowScene(void)
 void UIKit_SetGameControllerInteraction(bool enabled)
 {
     if (@available(iOS 13.0, tvOS 13.0, *)) {
-        UIWindowScene *scene = UIKit_GetActiveWindowScene();
-        if (scene == nil) {
-            return;
-        }
+        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
+        for (UIScene *scene in connectedScenes) {
+            if (![scene isKindOfClass:[UIWindowScene class]]) {
+                continue;
+            }
 
-        for (UIWindow *window in scene.windows) {
-            UIKit_SetViewGameControllerInteraction(window, enabled);
+            UIWindowScene *windowScene = (UIWindowScene *)scene;
+            for (UIWindow *window in windowScene.windows) {
+                UIKit_SetViewGameControllerInteraction(window, enabled);
+            }
         }
     }
 }