Frontend: Add hotkey to adjust resolution scale
This commit is contained in:
parent
49be3efb35
commit
6e60991fd0
|
@ -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<u32>(m_system->GetSettings().gpu_resolution_scale, 1, m_max_resolution_scale);
|
||||
}
|
||||
|
||||
void GPU::Reset()
|
||||
|
|
|
@ -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<u32>(static_cast<u32>(static_cast<s32>(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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue