Detect screen size and choose resolution defaults accordingly.

Also prevent recreate on older Android versions where it doesn't seem reliable.
This commit is contained in:
Henrik Rydgard 2014-07-21 00:35:36 +02:00
parent b03460c169
commit 0986f27f33
4 changed files with 42 additions and 7 deletions

View file

@ -360,6 +360,28 @@ static bool DefaultTimerHack() {
#endif
}
static int DefaultAndroidHwScale() {
#ifdef ANDROID
// Get the real resolution as passed in during startup, not dp_xres and stuff
int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);
if (xres < 960) {
// Smaller than the PSP*2, let's go native.
return 0;
} else if (xres <= 480 * 3) { // 720p xres
// Small-ish screen, we should default to 2x
return 2 + 1;
} else {
// Large or very large screen. Default to 3x psp resolution.
return 3 + 1;
}
return 0;
#else
return 1;
#endif
}
static ConfigSetting graphicsSettings[] = {
ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0),
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode),
@ -368,7 +390,7 @@ static ConfigSetting graphicsSettings[] = {
ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true),
ReportedConfigSetting("TextureFiltering", &g_Config.iTexFiltering, 1),
ReportedConfigSetting("InternalResolution", &g_Config.iInternalResolution, &DefaultInternalResolution),
ReportedConfigSetting("AndroidHwScale", &g_Config.iAndroidHwScale, 1),
ReportedConfigSetting("AndroidHwScale", &g_Config.iAndroidHwScale, &DefaultAndroidHwScale),
ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0),
ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false),
ReportedConfigSetting("FrameRate", &g_Config.iFpsLimit, 0),

View file

@ -443,10 +443,23 @@ UI::EventReturn GameSettingsScreen::OnScreenRotation(UI::EventParams &e) {
return UI::EVENT_DONE;
}
static void RecreateActivity() {
const int SYSTEM_JELLYBEAN = 16;
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= SYSTEM_JELLYBEAN) {
System_SendMessage("recreate", "");
} else {
I18NCategory *gs = GetI18NCategory("Graphics");
System_SendMessage("toast", gs->T("Must Restart", "You must restart PPSSPP for this change to take effect"));
}
}
UI::EventReturn GameSettingsScreen::OnImmersiveModeChange(UI::EventParams &e) {
System_SendMessage("immersive", "");
if (g_Config.iAndroidHwScale != 0)
System_SendMessage("recreate", "");
const int SYSTEM_JELLYBEAN = 16;
// recreate doesn't seem reliable on earlier versions.
if (g_Config.iAndroidHwScale != 0) {
RecreateActivity();
}
return UI::EVENT_DONE;
}
@ -500,14 +513,14 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
gpu->Resized();
}
if (g_Config.iAndroidHwScale == 1) {
System_SendMessage("recreate", "");
RecreateActivity();
}
Reporting::UpdateConfig();
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnHwScaleChange(UI::EventParams &e) {
System_SendMessage("recreate", "");
RecreateActivity();
return UI::EVENT_DONE;
}

View file

@ -91,4 +91,4 @@ public class PpssppActivity extends NativeActivity {
}
correctRatio(sz, (float)scale);
}
}
}

2
native

@ -1 +1 @@
Subproject commit 1d77b9435562e67d2814db99c89a752febd6dbe4
Subproject commit a4a17415a7f12d15eb37f57181df97d46e239531