UICommon: Move TriggerSTMPowerEvent() from Wx

This commit is contained in:
spycrab 2017-06-24 21:41:53 +02:00
parent 4320c641f7
commit 2de31317e9
4 changed files with 33 additions and 22 deletions

View File

@ -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);

View File

@ -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<IOS::HLE::Device::STMEventHook>(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;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#ifdef _WIN32
#include <shlobj.h> // 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<IOS::HLE::Device::STMEventHook>(stm)->HasHookInstalled())
return false;
Core::DisplayMessage("Shutting down", 30000);
ProcessorInterface::PowerButton_Tap();
return true;
}
} // namespace UICommon

View File

@ -12,5 +12,7 @@ void Shutdown();
void CreateDirectories();
void SetUserDirectory(const std::string& custom_path);
bool TriggerSTMPowerEvent();
void SaveWiimoteSources();
} // namespace UICommon