diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 402b3dd91d..0b904eb7b8 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -523,6 +523,21 @@ void GSEndCapture() g_gs_renderer->EndCapture(); } +void GSToggleVideoCapture() +{ + if (!g_gs_renderer) + return; + + if (GSCapture::IsCapturing()) + { + g_gs_renderer->EndCapture(); + return; + } + + std::string filename(fmt::format("{}.{}", GSGetBaseVideoFilename(), GSConfig.CaptureContainer)); + g_gs_renderer->BeginCapture(std::move(filename)); +} + void GSPresentCurrentFrame() { g_gs_renderer->PresentCurrentFrame(); @@ -1217,17 +1232,7 @@ BEGIN_HOTKEY_LIST(g_gs_hotkeys){"Screenshot", TRANSLATE_NOOP("Hotkeys", "Graphic [](s32 pressed) { if (!pressed) { - if (GSCapture::IsCapturing()) - { - MTGS::RunOnGSThread([]() { g_gs_renderer->EndCapture(); }); - MTGS::WaitGS(false, false, false); - return; - } - - MTGS::RunOnGSThread([]() { - std::string filename(fmt::format("{}.{}", GSGetBaseVideoFilename(), GSConfig.CaptureContainer)); - g_gs_renderer->BeginCapture(std::move(filename)); - }); + MTGS::RunOnGSThread(&GSToggleVideoCapture); // Sync GS thread. We want to start adding audio at the same time as video. MTGS::WaitGS(false, false, false); diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index ab311c3c39..f931d749ea 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -81,6 +81,7 @@ void GSDumpSavedMetrics(); bool GSIsSavingMetrics(); bool GSBeginCapture(std::string filename); void GSEndCapture(); +void GSToggleVideoCapture(); void GSPresentCurrentFrame(); void GSThrottlePresentation(); void GSGameChanged(); diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index 9ecb7690f5..21567ccadd 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -5,6 +5,7 @@ #include "CDVD/CDVDcommon.h" #include "GS/Renderers/Common/GSDevice.h" #include "GS/Renderers/Common/GSTexture.h" +#include "GS/GSCapture.h" #include "Achievements.h" #include "CDVD/CDVDdiscReader.h" #include "GameList.h" @@ -1668,7 +1669,7 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type) ImVec2(10.0f, 10.0f), ImGuiWindowFlags_NoBackground)) { static constexpr u32 submenu_item_count[] = { - 11, // None + 12, // None 4, // Exit 3, // Achievements }; @@ -1769,6 +1770,16 @@ void FullscreenUI::DrawPauseMenu(MainWindowType type) ClosePauseMenu(); } + const bool is_capturing = GSCapture::IsCapturing(); + const bool can_start_capture = GSConfig.EnableVideoCapture || GSConfig.EnableAudioCapture; + if (ActiveButton(is_capturing ? FSUI_ICONSTR(ICON_FA_VIDEO_SLASH, "Stop Recording") : + FSUI_ICONSTR(ICON_FA_VIDEO, "Start Recording"), + false, is_capturing || can_start_capture)) + { + GSToggleVideoCapture(); + ClosePauseMenu(); + } + if (ActiveButton(GSIsHardwareRenderer() ? (FSUI_ICONSTR(ICON_FA_PAINTBRUSH, "Switch To Software Renderer")) : (FSUI_ICONSTR(ICON_FA_PAINTBRUSH, "Switch To Hardware Renderer")), false))