diff --git a/Core/Config.cpp b/Core/Config.cpp index 64d8b28519..11c108ad97 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -341,6 +341,8 @@ static const ConfigSetting generalSettings[] = { ConfigSetting("RunBehindPauseMenu", &g_Config.bRunBehindPauseMenu, false, CfgFlag::DEFAULT), ConfigSetting("ShowGPOLEDs", &g_Config.bShowGPOLEDs, false, CfgFlag::PER_GAME), + + ConfigSetting("UIScaleFactor", &g_Config.iUIScaleFactor, false, CfgFlag::DEFAULT), }; static bool DefaultSasThread() { @@ -2151,3 +2153,7 @@ int MultiplierToVolume100(float multiplier) { } return (int)(powf(multiplier, 1.0f / 1.75f) * 100.f + 0.5f); } + +float UIScaleFactorToMultiplier(int factor) { + return powf(2.0f, (float)factor / 8.0f); +} diff --git a/Core/Config.h b/Core/Config.h index 01fbe5143f..686df1df71 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -138,6 +138,7 @@ public: int iMemStickSizeGB; bool bLoadPlugins; int iAskForExitConfirmationAfterSeconds; + int iUIScaleFactor; // In 8ths of powers of two. int iScreenRotation; // The rotation angle of the PPSSPP UI. Only supported on Android and possibly other mobile platforms. int iInternalScreenRotation; // The internal screen rotation angle. Useful for vertical SHMUPs and similar. diff --git a/Core/ConfigValues.h b/Core/ConfigValues.h index 1dd1fc88b4..5033606d89 100644 --- a/Core/ConfigValues.h +++ b/Core/ConfigValues.h @@ -43,6 +43,8 @@ float Volume100ToMultiplier(int volume); // Used for migration from the old settings. int MultiplierToVolume100(float multiplier); +float UIScaleFactorToMultiplier(int factor); + struct ConfigTouchPos { float x; float y; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9252c3c795..bbc1b0cc14 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1128,6 +1128,8 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { }); #endif + PopupSliderChoice *uiScale = systemSettings->Add(new PopupSliderChoice(&g_Config.iUIScaleFactor, -8, 8, 0, "UI scale factor (DPI adjustment)", screenManager())); + const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; if (File::Exists(bgPng) || File::Exists(bgJpg)) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 8dca521881..4b6b32e5ee 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1518,6 +1518,7 @@ static bool IsWindowSmall(int pixelWidth, int pixelHeight) { } bool Native_UpdateScreenScale(int pixel_width, int pixel_height, float customScale) { + _dbg_assert_(customScale > 0.1f); float g_logical_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_LOGICAL_DPI); float dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI); @@ -1531,6 +1532,8 @@ bool Native_UpdateScreenScale(int pixel_width, int pixel_height, float customSca bool smallWindow = IsWindowSmall(pixel_width, pixel_height); if (smallWindow) { customScale *= 0.5f; + } else { + customScale = UIScaleFactorToMultiplier(g_Config.iUIScaleFactor); } if (g_display.Recalculate(pixel_width, pixel_height, g_logical_dpi / dpi, customScale)) { diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index f0dc681c5c..82ebcb33f0 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -298,7 +298,7 @@ namespace MainWindow DEBUG_LOG(Log::System, "Pixel width/height: %dx%d", PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); - if (Native_UpdateScreenScale(width, height, 1.0f)) { + if (Native_UpdateScreenScale(width, height, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor))) { System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED); System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); }