From 836f76da898ee514022d7b2c84a88f6dcc1a4c0b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 24 Oct 2018 15:50:54 +1000 Subject: DolphinNoGUI: Runtime selection of platform --- Source/Core/DolphinNoGUI/Platform.cpp | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Source/Core/DolphinNoGUI/Platform.cpp (limited to 'Source/Core/DolphinNoGUI/Platform.cpp') diff --git a/Source/Core/DolphinNoGUI/Platform.cpp b/Source/Core/DolphinNoGUI/Platform.cpp new file mode 100644 index 0000000000..69b184bfe9 --- /dev/null +++ b/Source/Core/DolphinNoGUI/Platform.cpp @@ -0,0 +1,53 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinNoGUI/Platform.h" +#include "Core/IOS/IOS.h" +#include "Core/IOS/STM/STM.h" +#include "Core/State.h" + +namespace ProcessorInterface +{ +void PowerButton_Tap(); +} + +Platform::~Platform() = default; + +bool Platform::Init() +{ + return true; +} + +void Platform::SetTitle(const std::string& title) +{ +} + +void Platform::UpdateRunningFlag() +{ + if (m_shutdown_requested.TestAndClear()) + { + const auto ios = IOS::HLE::GetIOS(); + const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr; + if (!m_tried_graceful_shutdown.IsSet() && stm && + std::static_pointer_cast(stm)->HasHookInstalled()) + { + ProcessorInterface::PowerButton_Tap(); + m_tried_graceful_shutdown.Set(); + } + else + { + m_running.Clear(); + } + } +} + +void Platform::Stop() +{ + m_running.Clear(); +} + +void Platform::RequestShutdown() +{ + m_shutdown_requested.Set(); +} -- cgit v1.2.3