Add option to control the iOS app switching mode

This commit is contained in:
Henrik Rydgård 2024-07-05 20:06:56 +02:00
parent 0b76d443e2
commit 305418813a
9 changed files with 51 additions and 4 deletions

View file

@ -231,6 +231,7 @@ enum class SystemNotification {
ACTIVITY, ACTIVITY,
UI_STATE_CHANGED, UI_STATE_CHANGED,
AUDIO_MODE_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 // I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of

View file

@ -644,6 +644,10 @@ static const ConfigSetting graphicsSettings[] = {
ConfigSetting("FullScreenMulti", &g_Config.bFullScreenMulti, false, CfgFlag::DEFAULT), ConfigSetting("FullScreenMulti", &g_Config.bFullScreenMulti, false, CfgFlag::DEFAULT),
#endif #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("BufferFiltering", &g_Config.iDisplayFilter, SCALE_LINEAR, CfgFlag::PER_GAME),
ConfigSetting("DisplayOffsetX", &g_Config.fDisplayOffsetX, 0.5f, CfgFlag::PER_GAME), ConfigSetting("DisplayOffsetX", &g_Config.fDisplayOffsetX, 0.5f, CfgFlag::PER_GAME),
ConfigSetting("DisplayOffsetY", &g_Config.fDisplayOffsetY, 0.5f, CfgFlag::PER_GAME), ConfigSetting("DisplayOffsetY", &g_Config.fDisplayOffsetY, 0.5f, CfgFlag::PER_GAME),

View file

@ -210,6 +210,7 @@ public:
bool bTextureBackoffCache; bool bTextureBackoffCache;
bool bVertexDecoderJit; bool bVertexDecoderJit;
int iAppSwitchMode;
bool bFullScreen; bool bFullScreen;
bool bFullScreenMulti; bool bFullScreenMulti;
int iForceFullScreen = -1; // -1 = nope, 0 = force off, 1 = force on (not saved.) int iForceFullScreen = -1; // -1 = nope, 0 = force off, 1 = force on (not saved.)

View file

@ -126,6 +126,12 @@ enum class BackgroundAnimation {
MOVING_BACKGROUND = 4, MOVING_BACKGROUND = 4,
}; };
// iOS only
enum class AppSwitchMode {
SINGLE_SWIPE_NO_INDICATOR = 0,
DOUBLE_SWIPE_INDICATOR = 1,
};
// for Config.iShowStatusFlags // for Config.iShowStatusFlags
enum class ShowStatusFlags { enum class ShowStatusFlags {
FPS_COUNTER = 1 << 1, FPS_COUNTER = 1 << 1,

View file

@ -1048,6 +1048,17 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
screenManager()->push(langScreen); screenManager()->push(langScreen);
return UI::EVENT_DONE; 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"))); systemSettings->Add(new CheckBox(&g_Config.bUISound, sy->T("UI Sound")));
const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png";
const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg";

View file

@ -134,8 +134,16 @@ id<PPSSPPViewController> sharedViewController;
} }
- (BOOL)prefersHomeIndicatorAutoHidden { - (BOOL)prefersHomeIndicatorAutoHidden {
// Would love to hide it, but it prevents the double-swipe protection from working. if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) {
return NO; return NO;
} else {
return YES;
}
}
- (void)appSwitchModeChanged
{
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
} }
- (void)shareText:(NSString *)text { - (void)shareText:(NSString *)text {

View file

@ -15,6 +15,7 @@
- (void)stopLocation; - (void)stopLocation;
- (void)startVideo:(int)width height:(int)height; - (void)startVideo:(int)width height:(int)height;
- (void)stopVideo; - (void)stopVideo;
- (void)appSwitchModeChanged;
// Forwarded from the AppDelegate // Forwarded from the AppDelegate
- (void)didBecomeActive; - (void)didBecomeActive;

View file

@ -481,8 +481,16 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
} }
- (BOOL)prefersHomeIndicatorAutoHidden { - (BOOL)prefersHomeIndicatorAutoHidden {
// Would love to hide it, but it prevents the double-swipe protection from working. if (g_Config.iAppSwitchMode == (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR) {
return NO; return NO;
} else {
return YES;
}
}
- (void)appSwitchModeChanged
{
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
} }
- (void)shareText:(NSString *)text { - (void)shareText:(NSString *)text {

View file

@ -387,6 +387,13 @@ bool System_GetPropertyBool(SystemProperty prop) {
void System_Notify(SystemNotification notification) { void System_Notify(SystemNotification notification) {
switch (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: case SystemNotification::UI_STATE_CHANGED:
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (sharedViewController) { if (sharedViewController) {