From e8b653ddf312e6511b46708e2f547f1e354abdd3 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sun, 3 Jan 2016 21:13:20 +0200 Subject: [PATCH] KB commands: change Sys_Suspend to Sys_SuspendResume (toggle) It's now possible to press ESC once to pause, and ESC again to resume (or assign any other key via PCSX2_keys.ini, e.g. to SPACE). Note that resume only works if the GS window is NOT set to hide on pause (Emu options -> GS Window), and if the key is pressed while the GS window is focused. This includes two related changes: - The command name at PCSX2_keys.ini is now changed to Sys_SuspendResume. - If the GS window is NOT set to hide on pause, then it stays focused on pause. --nogui also gains this behavior, so it's now possible to launch without a GUI and still suspend/resume if the GS window is not set to hide on pause. If it is set to hide on pause, then the behavior remains as it was: exit PCSX2 on pause, or prompt to exit/resume if --noguiprompt is provided. --- bin/PCSX2_keys.ini.default | 4 +++- pcsx2/gui/FrameForGS.cpp | 2 +- pcsx2/gui/GlobalCommands.cpp | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bin/PCSX2_keys.ini.default b/bin/PCSX2_keys.ini.default index 00ba3836be..dd43aa6a6e 100644 --- a/bin/PCSX2_keys.ini.default +++ b/bin/PCSX2_keys.ini.default @@ -46,7 +46,9 @@ Framelimiter_MasterToggle = F4 FullscreenToggle = Alt-ENTER -Sys_Suspend = ESC +# Note: toggles suspend, but can resume only if the GS window is not set to hide +# when paused (Emu options -> GS window), and when the GS window is focused. +Sys_SuspendResume = ESC # Screenshot. Note: must not include shift or ctrl. With these held - it will # create debug GS dump. The two other shortcuts will be added automatically. diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 68df27a745..0cde33a89f 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -66,7 +66,7 @@ void GSPanel::InitDefaultAccelerators() m_Accels->Map( AAC( WXK_RIGHT ).Cmd().Alt(), "GSwindow_OffsetXplus" ); m_Accels->Map( AAC( WXK_NUMPAD_DIVIDE ).Cmd().Alt(), "GSwindow_OffsetReset" ); - m_Accels->Map( AAC( WXK_ESCAPE ), "Sys_Suspend" ); + m_Accels->Map( AAC( WXK_ESCAPE ), "Sys_SuspendResume" ); m_Accels->Map( AAC( WXK_F8 ), "Sys_TakeSnapshot" ); // also shift and ctrl-shift will be added automatically m_Accels->Map( AAC( WXK_F9 ), "Sys_RenderswitchToggle"); diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index 551ec38bf0..389591c11b 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -327,7 +327,8 @@ namespace Implementations } } - sMainFrame.SetFocus(); + if (g_Conf->GSWindow.CloseOnEsc) + sMainFrame.SetFocus(); } void Sys_Resume() @@ -335,6 +336,17 @@ namespace Implementations CoreThread.Resume(); } + void Sys_SuspendResume() + { + if (CoreThread.HasPendingStateChangeRequest()) + return; + + if (CoreThread.IsPaused()) + Sys_Resume(); + else + Sys_Suspend(); + } + void Sys_TakeSnapshot() { GSmakeSnapshot( g_Conf->Folders.Snapshots.ToAscii() ); @@ -546,8 +558,8 @@ static const GlobalCommandDescriptor CommandDeclarations[] = { "GSwindow_OffsetXplus", Implementations::GSwindow_OffsetXplus, NULL, NULL, }, { "GSwindow_OffsetReset", Implementations::GSwindow_OffsetReset, NULL, NULL, }, - { "Sys_Suspend", - Implementations::Sys_Suspend, + { "Sys_SuspendResume", + Implementations::Sys_SuspendResume, NULL, NULL, },