diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..7f5fa93 Binary files /dev/null and b/.DS_Store differ diff --git a/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate b/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate index 7745554..65f74fb 100644 Binary files a/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate and b/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist b/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist index 968f09a..18522ef 100644 --- a/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,11 @@ SchemeUserState + RyujinxHelper.xcscheme_^#shared#^_ + + orderHint + 0 + RyujinxKeyboard.xcscheme_^#shared#^_ orderHint diff --git a/RyujinxHelper/main.mm b/RyujinxHelper/main.mm index a3de801..2df9d8e 100644 --- a/RyujinxHelper/main.mm +++ b/RyujinxHelper/main.mm @@ -13,6 +13,24 @@ extern "C" { #endif static char *keyboardInput = NULL; + +UIWindowScene *getMainDeviceWindowScene() { + for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) { + if ([scene isKindOfClass:[UIWindowScene class]]) { + if (scene.screen == UIScreen.mainScreen) { + return scene; + } + } + } + + for (UIWindowScene *scene in UIApplication.sharedApplication.connectedScenes) { + if ([scene isKindOfClass:[UIWindowScene class]]) { + return scene; + } + } + + return nil; +} void showKeyboardAlert(const char *title, const char *message, const char *placeholder) { NSString *alertTitle = [NSString stringWithUTF8String:title]; @@ -20,8 +38,8 @@ void showKeyboardAlert(const char *title, const char *message, const char *place NSString *alertPlaceholder = [NSString stringWithUTF8String:placeholder]; dispatch_async(dispatch_get_main_queue(), ^{ - UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; - if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { + UIWindowScene *activeScene = getMainDeviceWindowScene(); + if (!activeScene) { return; } @@ -63,7 +81,9 @@ void showKeyboardAlert(const char *title, const char *message, const char *place UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { - free(keyboardInput); + if (keyboardInput) { + free(keyboardInput); + } keyboardInput = strdup(""); popupWindow.hidden = YES; @@ -82,8 +102,8 @@ void showAlert(const char *title, const char *message, bool showCancel) { NSString *alertMessage = [NSString stringWithUTF8String:message]; dispatch_async(dispatch_get_main_queue(), ^{ - UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; - if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { + UIWindowScene *activeScene = getMainDeviceWindowScene(); + if (!activeScene) { return; }