From 9b72b5f144da14be215554efd2938097086becc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 19 Sep 2016 00:49:15 +0200 Subject: 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. --- Source/Core/DolphinWX/FrameTools.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Source/Core/DolphinWX/FrameTools.cpp') diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 2b690c0e5a..e20cc15411 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -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) -- cgit v1.2.3