Shut down Wii software gracefully

This adds support for triggering the power event (in the STM), so that
stopping emulation first triggers a shutdown event, which notably gives
emulated software time to save game data (issue 8979) and clean up
SYSCONF (to disconnect Wiimotes and update their state in the SYSCONF).

On the first press, the stop button/hotkey/whatever will trigger a STM
power event. On a second try, we will forcefully stop emulation, just
like how it was working before.
This commit is contained in:
Léo Lam
2016-09-19 00:49:15 +02:00
parent ae723f5251
commit 9b72b5f144
6 changed files with 69 additions and 5 deletions

View File

@ -1155,9 +1155,12 @@ void CFrame::DoStop()
Core::SetState(Core::CORE_PAUSE);
}
wxMessageDialog m_StopDlg(this, _("Do you want to stop the current emulation?"),
_("Please confirm..."),
wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);
wxMessageDialog m_StopDlg(
this, !m_tried_graceful_shutdown ? _("Do you want to stop the current emulation?") :
_("A shutdown is already in progress. Unsaved data "
"may be lost if you stop the current emulation "
"before it completes. Force stop?"),
_("Please confirm..."), wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);
HotkeyManagerEmu::Enable(false);
int Ret = m_StopDlg.ShowModal();
@ -1172,6 +1175,16 @@ void CFrame::DoStop()
}
}
if (SConfig::GetInstance().bWii && !m_tried_graceful_shutdown)
{
Core::DisplayMessage("Shutting down", 30000);
Core::SetState(Core::CORE_RUN);
ProcessorInterface::PowerButton_Tap();
m_confirmStop = false;
m_tried_graceful_shutdown = true;
return;
}
if (UseDebugger && g_pCodeWindow)
{
if (g_pCodeWindow->m_WatchWindow)
@ -1207,6 +1220,7 @@ void CFrame::DoStop()
void CFrame::OnStopped()
{
m_confirmStop = false;
m_tried_graceful_shutdown = false;
#if defined(HAVE_X11) && HAVE_X11
if (SConfig::GetInstance().bDisableScreenSaver)