diff --git a/Core/Config.cpp b/Core/Config.cpp index dc9576cae2..ebac1e73a0 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -213,6 +213,14 @@ static int DefaultUIScaleFactor() { #endif } +static int DefaultScreenRotation() { +#if PPSSPP_PLATFORM(ANDROID) + return ROTATION_LOCKED_HORIZONTAL; +#else + return ROTATION_AUTO; +#endif +} + static const ConfigSetting generalSettings[] = { ConfigSetting("FirstRun", &g_Config.bFirstRun, true, CfgFlag::DEFAULT), ConfigSetting("RunCount", &g_Config.iRunCount, 0, CfgFlag::DEFAULT), @@ -297,9 +305,10 @@ static const ConfigSetting generalSettings[] = { ConfigSetting("RemoteISOShareType", &g_Config.iRemoteISOShareType, (int)RemoteISOShareType::RECENT, CfgFlag::DEFAULT), ConfigSetting("AskForExitConfirmationAfterSeconds", &g_Config.iAskForExitConfirmationAfterSeconds, 60, CfgFlag::PER_GAME), -#ifdef __ANDROID__ - ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, ROTATION_AUTO_HORIZONTAL), +#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) + ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, &DefaultScreenRotation, CfgFlag::DEFAULT), #endif + ConfigSetting("InternalScreenRotation", &g_Config.iInternalScreenRotation, ROTATION_LOCKED_HORIZONTAL, CfgFlag::PER_GAME), ConfigSetting("BackgroundAnimation", &g_Config.iBackgroundAnimation, 1, CfgFlag::DEFAULT), diff --git a/ios/AppDelegate.mm b/ios/AppDelegate.mm index f2c4e0b609..94634c1f39 100644 --- a/ios/AppDelegate.mm +++ b/ios/AppDelegate.mm @@ -108,7 +108,23 @@ __attribute__((used)) static Class _forceLinkSceneDelegate = [SceneDelegate clas } - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { - return UIInterfaceOrientationMaskAll; // or at least include Portrait + switch (g_Config.iScreenRotation) { + case ROTATION_LOCKED_HORIZONTAL: + return UIInterfaceOrientationMaskLandscapeRight; + case ROTATION_LOCKED_VERTICAL: + case ROTATION_LOCKED_VERTICAL180: + // We do not support reverse portrait on iOS. + return UIInterfaceOrientationMaskPortrait; + case ROTATION_LOCKED_HORIZONTAL180: + return UIInterfaceOrientationMaskLandscapeLeft; + case ROTATION_AUTO_HORIZONTAL: + return UIInterfaceOrientationMaskLandscape; + case ROTATION_AUTO: + default: + return UIInterfaceOrientationMaskAll; + } + + return UIInterfaceOrientationMaskAll; // or at least include Portrait } @end diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 57e04de1ab..b6b2b40e38 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -269,8 +269,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { [EAGLContext setCurrentContext:self.context]; self.preferredFramesPerSecond = 60; // NOTE: We don't yet take advantage of 120hz screens - [[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; - graphicsContext = new IOSGLESContext(); graphicsContext->GetDrawContext()->SetErrorCallback([](const char *shortDesc, const char *details, void *userdata) { @@ -336,6 +334,8 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { INFO_LOG(Log::G3D, "No accelerometer available, not starting updates."); } [self runGLRenderLoop]; + [[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; + INFO_LOG(Log::System, "didBecomeActive end"); } diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index cdf794dc79..f7ce3c38ef 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -343,6 +343,7 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye // Spin up the emu thread. It will in turn spin up the Vulkan render thread // on its own. [self runVulkanRenderLoop]; + [[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; } - (void)willResignActive { diff --git a/ios/main.mm b/ios/main.mm index 31a1fdd712..bfc64a3034 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -431,6 +431,14 @@ void System_Notify(SystemNotification notification) { iOSCoreAudioUpdateSession(); }); break; + case SystemNotification::ROTATE_UPDATED: + dispatch_async(dispatch_get_main_queue(), ^{ + if (sharedViewController) { + // [sharedViewController setNeedsUpdateOfSupportedInterfaceOrientations]; + INFO_LOG(Log::System, "Requesting device orientation update"); + [UIViewController attemptRotationToDeviceOrientation]; + } + }); default: break; }