diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index bade8b421..91f487f53 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -28,13 +28,7 @@ bool GPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_co void GPU::UpdateResolutionScale() { - const u32 new_scale = std::min(m_system->GetSettings().gpu_resolution_scale, m_max_resolution_scale); - if (m_resolution_scale == new_scale) - return; - - m_resolution_scale = new_scale; - m_system->GetHostInterface()->AddOSDMessage(TinyString::FromFormat( - "Changed internal resolution to %ux (%ux%u)", m_resolution_scale, VRAM_WIDTH * new_scale, VRAM_HEIGHT * new_scale)); + m_resolution_scale = std::clamp(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale); } void GPU::Reset() diff --git a/src/duckstation/sdl_interface.cpp b/src/duckstation/sdl_interface.cpp index 4330f4c64..c5e7a7f93 100644 --- a/src/duckstation/sdl_interface.cpp +++ b/src/duckstation/sdl_interface.cpp @@ -597,11 +597,21 @@ void SDLInterface::HandleSDLKeyEvent(const SDL_Event* event) } break; + case SDL_SCANCODE_HOME: + case SDL_SCANCODE_END: + { + if (pressed) + DoToggleSoftwareRendering(); + } + break; + case SDL_SCANCODE_PAGEUP: case SDL_SCANCODE_PAGEDOWN: { if (pressed) - DoToggleSoftwareRendering(); + { + DoModifyInternalResolution(event->key.keysym.scancode == SDL_SCANCODE_PAGEUP ? 1 : -1); + } } break; } @@ -1215,6 +1225,26 @@ void SDLInterface::DoToggleSoftwareRendering() m_system->RecreateGPU(); } +void SDLInterface::DoModifyInternalResolution(s32 increment) +{ + if (!m_system) + return; + + auto& settings = m_system->GetSettings(); + const u32 new_resolution_scale = + std::clamp(static_cast(static_cast(settings.gpu_resolution_scale) + increment), 1, + settings.max_gpu_resolution_scale); + if (new_resolution_scale == settings.gpu_resolution_scale) + return; + + settings.gpu_resolution_scale = new_resolution_scale; + m_system->GetGPU()->UpdateResolutionScale(); + + AddOSDMessage(TinyString::FromFormat("Resolution scale set to %ux (%ux%u)", settings.gpu_resolution_scale, + GPU::VRAM_WIDTH * settings.gpu_resolution_scale, + GPU::VRAM_HEIGHT * settings.gpu_resolution_scale)); +} + void SDLInterface::Run() { m_audio_stream->PauseOutput(false); diff --git a/src/duckstation/sdl_interface.h b/src/duckstation/sdl_interface.h index ce6298a14..a45674892 100644 --- a/src/duckstation/sdl_interface.h +++ b/src/duckstation/sdl_interface.h @@ -75,6 +75,7 @@ private: void DoTogglePause(); void DoFrameStep(); void DoToggleSoftwareRendering(); + void DoModifyInternalResolution(s32 increment); void HandleSDLEvent(const SDL_Event* event); void HandleSDLKeyEvent(const SDL_Event* event);