GUI: Fix recording related hang when PAD plugin is open/closed while game is paused (#3299)

* recording: Resolve hang when opening PAD plugin with the game paused

* pcsx2-gui: Forbid editing the PAD settings while emulation is paused by recording tools

* pcsx2-gui: Resume emulation before configuring PAD plugin, resume on return
This commit is contained in:
Tyler Wilding 2020-09-10 18:05:54 -04:00 committed by GitHub
parent fe872b5caa
commit 79cd8d2190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 7 deletions

View File

@ -32,9 +32,11 @@
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h" # include "Recording/InputRecording.h"
# include "Recording/RecordingControls.h"
# include "Recording/VirtualPad.h" # include "Recording/VirtualPad.h"
#endif #endif
using namespace Dialogs; using namespace Dialogs;
void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent &event) void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent &event)
@ -471,7 +473,7 @@ void MainEmuFrame::Menu_EnableBackupStates_Click( wxCommandEvent& )
// (1st save after the toggle keeps the old pre-toggle value).. // (1st save after the toggle keeps the old pre-toggle value)..
// wonder what that means for all the other menu checkboxes which only use AppSaveSettings... (avih) // wonder what that means for all the other menu checkboxes which only use AppSaveSettings... (avih)
AppApplySettings(); AppApplySettings();
AppSaveSettings(); AppSaveSettings();
} }
@ -553,7 +555,7 @@ void MainEmuFrame::Menu_EnableRecordingTools_Click(wxCommandEvent&)
void MainEmuFrame::Menu_EnableHostFs_Click( wxCommandEvent& ) void MainEmuFrame::Menu_EnableHostFs_Click( wxCommandEvent& )
{ {
g_Conf->EmuOptions.HostFs = GetMenuBar()->IsChecked( MenuId_EnableHostFs ); g_Conf->EmuOptions.HostFs = GetMenuBar()->IsChecked( MenuId_EnableHostFs );
AppSaveSettings(); AppSaveSettings();
} }
void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&) void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent&)
@ -655,20 +657,47 @@ void MainEmuFrame::Menu_SysShutdown_Click(wxCommandEvent &event)
CoreThread.Reset(); CoreThread.Reset();
} }
void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent &event) void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent& event)
{ {
const int eventId = event.GetId() - MenuId_PluginBase_Settings; const int eventId = event.GetId() - MenuId_PluginBase_Settings;
PluginsEnum_t pid = (PluginsEnum_t)(eventId / PluginMenuId_Interval); PluginsEnum_t pid = (PluginsEnum_t)(eventId / PluginMenuId_Interval);
// Don't try to call the Patches config dialog until we write one. // Don't try to call the Patches config dialog until we write one.
if (event.GetId() == MenuId_Config_Patches) return; if (event.GetId() == MenuId_Config_Patches)
return;
if( !pxAssertDev( (eventId >= 0) || (pid < PluginId_Count), "Invalid plugin identifier passed to ConfigPlugin event handler." ) ) return; if (!pxAssertDev((eventId >= 0) || (pid < PluginId_Count), "Invalid plugin identifier passed to ConfigPlugin event handler."))
return;
wxWindowDisabler disabler; wxWindowDisabler disabler;
ScopedCoreThreadPause paused_core( new SysExecEvent_SaveSinglePlugin(pid) ); ScopedCoreThreadPause paused_core(new SysExecEvent_SaveSinglePlugin(pid));
GetCorePlugins().Configure( pid );
#ifndef DISABLE_RECORDING
if (pid == PluginId_PAD)
{
// The recording features involve pausing emulation, and can be resumed ideally via key-bindings.
//
// However, since the PAD plugin is used to do so, if it's closed then there is nothing to read
// the keybind resulting producing an unrecovable state.
//
// If the CoreThread is paused prior to opening the PAD plugin settings then when the settings
// are closed the PAD will not re-open. To avoid this, we resume emulation prior to the plugins
// configuration handler doing so.
if (g_Conf->EmuOptions.EnableRecordingTools && g_RecordingControls.IsEmulationAndRecordingPaused())
{
g_RecordingControls.Unpause();
GetCorePlugins().Configure(pid);
g_RecordingControls.Pause();
}
else
GetCorePlugins().Configure(pid);
}
else
GetCorePlugins().Configure(pid);
#else
GetCorePlugins().Configure(pid);
#endif
} }
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event) void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)