diff --git a/pcsx2/Recording/InputRecordingControls.cpp b/pcsx2/Recording/InputRecordingControls.cpp index 01293aef3b..5b2c3d585e 100644 --- a/pcsx2/Recording/InputRecordingControls.cpp +++ b/pcsx2/Recording/InputRecordingControls.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2020 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -142,6 +142,18 @@ void InputRecordingControls::Resume() resumeEmulation = true; } +void InputRecordingControls::ResumeImmediately() +{ + if (!CoreThread.IsPaused()) + return; + Resume(); + if (CoreThread.IsPaused() && CoreThread.IsRunning()) + { + emulationCurrentlyPaused = false; + CoreThread.Resume(); + } +} + void InputRecordingControls::TogglePause() { if (pauseEmulation && diff --git a/pcsx2/Recording/InputRecordingControls.h b/pcsx2/Recording/InputRecordingControls.h index e1dcea0bff..f12655e1f6 100644 --- a/pcsx2/Recording/InputRecordingControls.h +++ b/pcsx2/Recording/InputRecordingControls.h @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2020 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -38,19 +38,19 @@ public: // Called much more frequently than HandleFrameAdvanceAndPausing, instead of being per frame // this hooks into pcsx2's main App event handler as it has to be able to resume emulation // when drawing frames has compltely stopped - // + // // Resumes emulation if: // - CoreThread is currently open and paused // - We've signaled emulation to be resumed via TogglePause or FrameAdvancing void ResumeCoreThreadIfStarted(); - + // Resume emulation (incase the emulation is currently paused) and pause after a single frame has passed void FrameAdvance(); // Returns true if emulation is currently set up to frame advance. bool IsFrameAdvancing(); // Returns true if the input recording has been paused, which can occur: // - After a single frame has passed after InputRecordingControls::FrameAdvance - // - Explicitly paused via an InputRecordingControls function + // - Explicitly paused via an InputRecordingControls function bool IsPaused(); // Pause emulation at the next available Vsync void Pause(); @@ -58,6 +58,10 @@ public: void PauseImmediately(); // Resume emulation when the next pcsx2 App event is handled void Resume(); + /** + * @brief Resumes emulation immediately, don't wait until the next VSync + */ + void ResumeImmediately(); // Alternates emulation between a paused and unpaused state void TogglePause(); // Switches between recording and replaying the active input recording file diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 38a6b5934c..79d62b9bfb 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -1045,9 +1045,10 @@ void MainEmuFrame::Menu_Capture_Screenshot_Screenshot_As_Click(wxCommandEvent& e #ifndef DISABLE_RECORDING void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent& event) { - const bool initiallyPaused = g_InputRecordingControls.IsPaused(); + const bool emulation_initially_paused = CoreThread.IsPaused(); + const bool recording_initially_paused = g_InputRecordingControls.IsPaused(); - if (!initiallyPaused) + if (!emulation_initially_paused && !recording_initially_paused) g_InputRecordingControls.PauseImmediately(); NewRecordingFrame* newRecordingFrame = wxGetApp().GetNewRecordingFramePtr(); @@ -1063,8 +1064,8 @@ void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent& event) } } - if (!initiallyPaused) - g_InputRecordingControls.Resume(); + if (!emulation_initially_paused && !recording_initially_paused) + g_InputRecordingControls.ResumeImmediately(); } }