diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 094df16173..337098568c 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -253,7 +253,6 @@ private: void DoFullscreen(bool enable_fullscreen); void DoExclusiveFullscreen(bool enable_fullscreen); void ToggleDisplayMode(bool bFullscreen); - bool TriggerSTMPowerEvent(); void OnStopped(); void OnRenderWindowSizeRequest(int width, int height); void UpdateTitle(const wxString& str); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 007c6595db..2caa8bc45b 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -85,6 +85,7 @@ #include "InputCommon/ControllerInterface/ControllerInterface.h" +#include "UICommon/UICommon.h" #include "UICommon/WiiUtils.h" #include "VideoCommon/RenderBase.h" @@ -879,36 +880,24 @@ void CFrame::DoStop() if (NetPlayDialog::GetNetPlayClient()) NetPlayDialog::GetNetPlayClient()->Stop(); - if (!m_tried_graceful_shutdown && TriggerSTMPowerEvent()) + if (!m_tried_graceful_shutdown && UICommon::TriggerSTMPowerEvent()) { m_tried_graceful_shutdown = true; + m_confirm_stop = false; + + // Unpause because gracefully shutting down needs the game to actually request a shutdown. + // Do not unpause in debug mode to allow debugging until the complete shutdown. + if (Core::GetState() == Core::State::Paused && !m_use_debugger) + Core::SetState(Core::State::Running); + return; } + Core::Stop(); UpdateGUI(); } } -bool CFrame::TriggerSTMPowerEvent() -{ - const auto ios = IOS::HLE::GetIOS(); - if (!ios) - return false; - - const auto stm = ios->GetDeviceByName("/dev/stm/eventhook"); - if (!stm || !std::static_pointer_cast(stm)->HasHookInstalled()) - return false; - - Core::DisplayMessage("Shutting down", 30000); - // Unpause because gracefully shutting down needs the game to actually request a shutdown. - // Do not unpause in debug mode to allow debugging until the complete shutdown. - if (Core::GetState() == Core::State::Paused && !m_use_debugger) - DoPause(); - ProcessorInterface::PowerButton_Tap(); - m_confirm_stop = false; - return true; -} - void CFrame::OnStopped() { m_confirm_stop = false; diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index ba4aa4a390..9c45a5c0d9 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #ifdef _WIN32 #include // for SHGetFolderPath #endif @@ -14,7 +15,11 @@ #include "Core/ConfigLoaders/BaseConfigLoader.h" #include "Core/ConfigManager.h" +#include "Core/Core.h" +#include "Core/HW/ProcessorInterface.h" #include "Core/HW/Wiimote.h" +#include "Core/IOS/IOS.h" +#include "Core/IOS/STM/STM.h" #include "InputCommon/GCAdapter.h" @@ -225,4 +230,20 @@ void SaveWiimoteSources() inifile.Save(ini_filename); } +bool TriggerSTMPowerEvent() +{ + const auto ios = IOS::HLE::GetIOS(); + if (!ios) + return false; + + const auto stm = ios->GetDeviceByName("/dev/stm/eventhook"); + if (!stm || !std::static_pointer_cast(stm)->HasHookInstalled()) + return false; + + Core::DisplayMessage("Shutting down", 30000); + ProcessorInterface::PowerButton_Tap(); + + return true; +} + } // namespace UICommon diff --git a/Source/Core/UICommon/UICommon.h b/Source/Core/UICommon/UICommon.h index 20c8ba0bcb..3781c2c58f 100644 --- a/Source/Core/UICommon/UICommon.h +++ b/Source/Core/UICommon/UICommon.h @@ -12,5 +12,7 @@ void Shutdown(); void CreateDirectories(); void SetUserDirectory(const std::string& custom_path); +bool TriggerSTMPowerEvent(); + void SaveWiimoteSources(); } // namespace UICommon