Rotation on iOS fixes: Make sure the setting is saved, etc.

This commit is contained in:
Henrik Rydgård committed 2025-10-22 15:54:00 +02:00
1 parent c5dcb0009c
commit e2b21d26bf
5 files changed
+39 -5

No files matched your search

+11 -2
View File
@@ -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),
+17 -1
View File
@@ -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
+2 -2
View File
@@ -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");
}
+1
View File
@@ -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 {
+8
View File
@@ -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;
}