From 72ec865f7e57db9f940db9908fc12e7140af4387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 27 Nov 2022 21:55:22 +0100 Subject: [PATCH] Fix for the aspect ratio plugin variable. Disable aspect ratio control in stretch mode. --- Core/HLE/sceIo.cpp | 14 +++++++++++--- UI/DisplayLayoutScreen.cpp | 7 ++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 943ba37721..7425ec2603 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2046,15 +2046,23 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o return 0; case EMULATOR_DEVCTL__GET_ASPECT_RATIO: if (Memory::IsValidAddress(outPtr)) { - float ar = g_Config.fDisplayAspectRatio * (480.0f / 272.0f); - Memory::Write_U32(*(reinterpret_cast(&ar)), outPtr); + // TODO: Share code with CenterDisplayOutputRect to take a few more things into account. + // I have a planned further refactoring. + float ar; + if (g_Config.bDisplayStretch) { + ar = (float)dp_xres / (float)dp_yres; + } else { + ar = g_Config.fDisplayAspectRatio * (480.0f / 272.0f); + } + Memory::Write_Float(ar, outPtr); } return 0; case EMULATOR_DEVCTL__GET_SCALE: if (Memory::IsValidAddress(outPtr)) { // TODO: Maybe do something more sophisticated taking the longest side and screen rotation // into account, etc. - Memory::Write_U32(static_cast(dp_xres) * g_Config.fDisplayScale / 480.0f, outPtr); + float scale = float(dp_xres) * g_Config.fDisplayScale / 480.0f; + Memory::Write_Float(scale, outPtr); } return 0; case EMULATOR_DEVCTL__GET_LTRIGGER: diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 9e95b76e1c..9b295c3305 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -204,12 +204,13 @@ void DisplayLayoutScreen::CreateViews() { rightScrollView->Add(rightColumn); root_->Add(rightScrollView); - PopupSliderChoiceFloat *aspectRatio = new PopupSliderChoiceFloat(&g_Config.fDisplayAspectRatio, 0.5f, 2.0f, di->T("Aspect Ratio"), screenManager()); - leftColumn->Add(aspectRatio); - auto stretch = new CheckBox(&g_Config.bDisplayStretch, gr->T("Stretch")); leftColumn->Add(stretch); + PopupSliderChoiceFloat *aspectRatio = new PopupSliderChoiceFloat(&g_Config.fDisplayAspectRatio, 0.5f, 2.0f, di->T("Aspect Ratio"), screenManager()); + leftColumn->Add(aspectRatio); + aspectRatio->SetDisabledPtr(&g_Config.bDisplayStretch); + mode_ = new ChoiceStrip(ORIENT_VERTICAL); mode_->AddChoice(di->T("Move")); mode_->AddChoice(di->T("Resize"));