mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
Frontend: Add frame step hotkey (SPACE)/menu item
This commit is contained in:
parent
21f555cf8f
commit
2b419fcb08
|
@ -579,12 +579,19 @@ void SDLInterface::HandleSDLKeyEvent(const SDL_Event* event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_SPACE:
|
case SDL_SCANCODE_PAUSE:
|
||||||
{
|
{
|
||||||
if (pressed)
|
if (pressed)
|
||||||
DoTogglePause();
|
DoTogglePause();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_SPACE:
|
||||||
|
{
|
||||||
|
if (pressed)
|
||||||
|
DoFrameStep();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,6 +712,13 @@ void SDLInterface::DrawMainMenuBar()
|
||||||
|
|
||||||
if (ImGui::BeginMenu("System"))
|
if (ImGui::BeginMenu("System"))
|
||||||
{
|
{
|
||||||
|
if (ImGui::MenuItem("Start Disc", nullptr, false, !system_enabled))
|
||||||
|
DoStartDisc();
|
||||||
|
if (ImGui::MenuItem("Start BIOS", nullptr, false, !system_enabled))
|
||||||
|
DoStartBIOS();
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::MenuItem("Power Off", nullptr, false, system_enabled))
|
if (ImGui::MenuItem("Power Off", nullptr, false, system_enabled))
|
||||||
DoPowerOff();
|
DoPowerOff();
|
||||||
|
|
||||||
|
@ -714,14 +728,12 @@ void SDLInterface::DrawMainMenuBar()
|
||||||
if (ImGui::MenuItem("Pause", nullptr, m_paused, system_enabled))
|
if (ImGui::MenuItem("Pause", nullptr, m_paused, system_enabled))
|
||||||
DoTogglePause();
|
DoTogglePause();
|
||||||
|
|
||||||
ImGui::MenuItem("Change Disc", nullptr, false, system_enabled);
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::MenuItem("Start Disc"))
|
ImGui::MenuItem("Change Disc", nullptr, false, system_enabled);
|
||||||
DoStartDisc();
|
|
||||||
if (ImGui::MenuItem("Start BIOS"))
|
if (ImGui::MenuItem("Frame Step", nullptr, false, system_enabled))
|
||||||
DoStartBIOS();
|
DoFrameStep();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
@ -1154,11 +1166,23 @@ void SDLInterface::DoSaveState(u32 index)
|
||||||
|
|
||||||
void SDLInterface::DoTogglePause()
|
void SDLInterface::DoTogglePause()
|
||||||
{
|
{
|
||||||
|
if (!m_system)
|
||||||
|
return;
|
||||||
|
|
||||||
m_paused = !m_paused;
|
m_paused = !m_paused;
|
||||||
if (!m_paused)
|
if (!m_paused)
|
||||||
m_fps_timer.Reset();
|
m_fps_timer.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLInterface::DoFrameStep()
|
||||||
|
{
|
||||||
|
if (!m_system)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_frame_step_request = true;
|
||||||
|
m_paused = false;
|
||||||
|
}
|
||||||
|
|
||||||
void SDLInterface::Run()
|
void SDLInterface::Run()
|
||||||
{
|
{
|
||||||
m_audio_stream->PauseOutput(false);
|
m_audio_stream->PauseOutput(false);
|
||||||
|
@ -1175,7 +1199,14 @@ void SDLInterface::Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_system && !m_paused)
|
if (m_system && !m_paused)
|
||||||
|
{
|
||||||
m_system->RunFrame();
|
m_system->RunFrame();
|
||||||
|
if (m_frame_step_request)
|
||||||
|
{
|
||||||
|
m_frame_step_request = false;
|
||||||
|
m_paused = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Render();
|
Render();
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ private:
|
||||||
void DoLoadState(u32 index);
|
void DoLoadState(u32 index);
|
||||||
void DoSaveState(u32 index);
|
void DoSaveState(u32 index);
|
||||||
void DoTogglePause();
|
void DoTogglePause();
|
||||||
|
void DoFrameStep();
|
||||||
|
|
||||||
void HandleSDLEvent(const SDL_Event* event);
|
void HandleSDLEvent(const SDL_Event* event);
|
||||||
void HandleSDLKeyEvent(const SDL_Event* event);
|
void HandleSDLKeyEvent(const SDL_Event* event);
|
||||||
|
@ -123,6 +124,7 @@ private:
|
||||||
|
|
||||||
bool m_paused = false;
|
bool m_paused = false;
|
||||||
bool m_quit_request = false;
|
bool m_quit_request = false;
|
||||||
|
bool m_frame_step_request = false;
|
||||||
bool m_focus_main_menu_bar = false;
|
bool m_focus_main_menu_bar = false;
|
||||||
bool m_about_window_open = false;
|
bool m_about_window_open = false;
|
||||||
bool m_speed_limiter_enabled = true;
|
bool m_speed_limiter_enabled = true;
|
||||||
|
|
Loading…
Reference in a new issue