diff --git a/Common/System/System.h b/Common/System/System.h index 3668d8074e..78e954b7b5 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -231,6 +231,7 @@ enum class SystemNotification { ACTIVITY, UI_STATE_CHANGED, AUDIO_MODE_CHANGED, + APP_SWITCH_MODE_CHANGED, }; // I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of diff --git a/Core/Config.cpp b/Core/Config.cpp index 34f8da4c99..fe82d69655 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -644,6 +644,10 @@ static const ConfigSetting graphicsSettings[] = { ConfigSetting("FullScreenMulti", &g_Config.bFullScreenMulti, false, CfgFlag::DEFAULT), #endif +#if PPSSPP_PLATFORM(IOS) + ConfigSetting("AppSwitchMode", &g_Config.iAppSwitchMode, (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR, CfgFlag::DEFAULT), +#endif + ConfigSetting("BufferFiltering", &g_Config.iDisplayFilter, SCALE_LINEAR, CfgFlag::PER_GAME), ConfigSetting("DisplayOffsetX", &g_Config.fDisplayOffsetX, 0.5f, CfgFlag::PER_GAME), ConfigSetting("DisplayOffsetY", &g_Config.fDisplayOffsetY, 0.5f, CfgFlag::PER_GAME), diff --git a/Core/Config.h b/Core/Config.h index e414309cf3..fdacd88fc5 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -210,6 +210,7 @@ public: bool bTextureBackoffCache; bool bVertexDecoderJit; + int iAppSwitchMode; bool bFullScreen; bool bFullScreenMulti; int iForceFullScreen = -1; // -1 = nope, 0 = force off, 1 = force on (not saved.) diff --git a/Core/ConfigValues.h b/Core/ConfigValues.h index 3e762d632c..297681f022 100644 --- a/Core/ConfigValues.h +++ b/Core/ConfigValues.h @@ -126,6 +126,12 @@ enum class BackgroundAnimation { MOVING_BACKGROUND = 4, }; +// iOS only +enum class AppSwitchMode { + SINGLE_SWIPE_NO_INDICATOR = 0, + DOUBLE_SWIPE_INDICATOR = 1, +}; + // for Config.iShowStatusFlags enum class ShowStatusFlags { FPS_COUNTER = 1 << 1, diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 527815d548..4c1d301e61 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1048,6 +1048,17 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { screenManager()->push(langScreen); return UI::EVENT_DONE; }); + + static const char *indicator[] = { + "Swipe once to switch app (indicator auto-hides)", + "Swipe twice to switch app (indicator stays visible)" + }; + PopupMultiChoice *switchMode = systemSettings->Add(new PopupMultiChoice(&g_Config.iAppSwitchMode, sy->T("App switching mode"), indicator, 0, ARRAY_SIZE(indicator), I18NCat::SYSTEM, screenManager())); + switchMode->OnChoice.Add([](EventParams &e) { + System_Notify(SystemNotification::APP_SWITCH_MODE_CHANGED); + return UI::EVENT_DONE; + }); + systemSettings->Add(new CheckBox(&g_Config.bUISound, sy->T("UI Sound"))); const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; diff --git a/ios/ViewController.mm b/ios/ViewController.mm index d36c329606..a9b82dc749 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -134,8 +134,16 @@ id sharedViewController; } - (BOOL)prefersHomeIndicatorAutoHidden { - // Would love to hide it, but it prevents the double-swipe protection from working. - return NO; + if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) { + return NO; + } else { + return YES; + } +} + +- (void)appSwitchModeChanged +{ + [self setNeedsUpdateOfHomeIndicatorAutoHidden]; } - (void)shareText:(NSString *)text { diff --git a/ios/ViewControllerCommon.h b/ios/ViewControllerCommon.h index 1e955b66ce..47e2c03028 100644 --- a/ios/ViewControllerCommon.h +++ b/ios/ViewControllerCommon.h @@ -15,6 +15,7 @@ - (void)stopLocation; - (void)startVideo:(int)width height:(int)height; - (void)stopVideo; +- (void)appSwitchModeChanged; // Forwarded from the AppDelegate - (void)didBecomeActive; diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index f1288a6eaa..0fd0a45969 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -481,8 +481,16 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye } - (BOOL)prefersHomeIndicatorAutoHidden { - // Would love to hide it, but it prevents the double-swipe protection from working. - return NO; + if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) { + return NO; + } else { + return YES; + } +} + +- (void)appSwitchModeChanged +{ + [self setNeedsUpdateOfHomeIndicatorAutoHidden]; } - (void)shareText:(NSString *)text { diff --git a/ios/main.mm b/ios/main.mm index 034385a782..3ac7eda183 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -387,6 +387,13 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_Notify(SystemNotification notification) { switch (notification) { + case SystemNotification::APP_SWITCH_MODE_CHANGED: + dispatch_async(dispatch_get_main_queue(), ^{ + if (sharedViewController) { + [sharedViewController appSwitchModeChanged]; + } + }); + break; case SystemNotification::UI_STATE_CHANGED: dispatch_async(dispatch_get_main_queue(), ^{ if (sharedViewController) {