From fa009ab6f6bed28d3415df7d1dfc264a3996a0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 4 Oct 2016 22:54:55 +0200 Subject: [PATCH 1/3] DolphinWX: Exit after closing main window or on signal Previously Dolphin would only exit if the main window is closed, and Confirm on Stop is enabled. This makes Dolphin's behaviour more consistent by always exiting if the main window is closed or on shutdown signal. --- Source/Core/DolphinWX/Frame.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 2253297bb6..1e31ee48cb 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -615,8 +615,7 @@ void CFrame::OnClose(wxCloseEvent& event) event.Veto(); } // Tell OnStopped to resubmit the Close event - if (m_confirmStop) - m_bClosing = true; + m_bClosing = true; return; } @@ -1716,6 +1715,7 @@ void CFrame::HandleSignal(wxTimerEvent& event) { if (!s_shutdown_signal_received.TestAndClear()) return; + m_bClosing = true; Close(); } From 48ff76d495949219474254b62388f1b83ddbf5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 4 Oct 2016 22:57:04 +0200 Subject: [PATCH 2/3] DolphinWX: Update GUI properly after unpausing If an unpause was forced by the graceful shutdown code, the UI was previously not updated. --- Source/Core/DolphinWX/FrameTools.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index ef08e6b721..7da392e2b4 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1344,7 +1344,9 @@ void CFrame::DoStop() if (SConfig::GetInstance().bWii && !m_tried_graceful_shutdown) { Core::DisplayMessage("Shutting down", 30000); - Core::SetState(Core::CORE_RUN); + // Unpause because gracefully shutting down needs the game to actually request a shutdown + if (Core::GetState() == Core::CORE_PAUSE) + DoPause(); ProcessorInterface::PowerButton_Tap(); m_confirmStop = false; m_tried_graceful_shutdown = true; From a0a246bf3e33eac9fd4d234590c721d972979bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 4 Oct 2016 22:58:01 +0200 Subject: [PATCH 3/3] Only attempt a graceful shutdown when there's a STM hook For Wii graceful shutdown to work, the emulated software has to open the STM event hook and install a hook. Without this, there is no way to inform them about the shutdown, so trying to do a graceful shutdown and requiring the use of the shutdown fallback (exiting a second time to force) is pointless. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp | 5 +++++ Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h | 1 + Source/Core/DolphinWX/FrameTools.cpp | 6 +++++- Source/Core/DolphinWX/MainNoGUI.cpp | 6 +++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp index 0bd3f8f257..19102f9e9e 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp @@ -135,6 +135,11 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(u32 command_address) return GetNoReply(); } +bool CWII_IPC_HLE_Device_stm_eventhook::HasHookInstalled() const +{ + return s_event_hook_address != 0; +} + void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const { if (!m_Active || s_event_hook_address == 0) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h index 56adc6a929..6e2f939114 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h @@ -59,6 +59,7 @@ public: IPCCommandResult Close(u32 command_address, bool force) override; IPCCommandResult IOCtl(u32 command_address) override; + bool HasHookInstalled() const; void ResetButton() const; void PowerButton() const; diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7da392e2b4..6e4b2831c3 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -42,6 +42,8 @@ #include "Core/HW/Wiimote.h" #include "Core/Host.h" #include "Core/HotkeyManager.h" +#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" #include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" #include "Core/Movie.h" @@ -1341,7 +1343,9 @@ void CFrame::DoStop() } } - if (SConfig::GetInstance().bWii && !m_tried_graceful_shutdown) + const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook"); + if (!m_tried_graceful_shutdown && stm && + std::static_pointer_cast(stm)->HasHookInstalled()) { Core::DisplayMessage("Shutting down", 30000); // Unpause because gracefully shutting down needs the game to actually request a shutdown diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 8e8512c07d..216eb5a707 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -23,6 +23,8 @@ #include "Core/Core.h" #include "Core/HW/Wiimote.h" #include "Core/Host.h" +#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" #include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" #include "Core/State.h" @@ -232,7 +234,9 @@ class PlatformX11 : public Platform { if (s_shutdown_requested.TestAndClear()) { - if (!s_tried_graceful_shutdown.IsSet() && SConfig::GetInstance().bWii) + const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook"); + if (!s_tried_graceful_shutdown.IsSet() && stm && + std::static_pointer_cast(stm)->HasHookInstalled()) { ProcessorInterface::PowerButton_Tap(); s_tried_graceful_shutdown.Set();