| 1 | // Copyright 2018 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinNoGUI/Platform.h" |
| 5 | |
| 6 | #include "Core/HW/ProcessorInterface.h" |
| 7 | #include "Core/IOS/IOS.h" |
| 8 | #include "Core/IOS/STM/STM.h" |
| 9 | #include "Core/System.h" |
| 10 | |
| 11 | Platform::~Platform() = default; |
| 12 | |
| 13 | bool Platform::Init() |
| 14 | { |
| 15 | return true; |
| 16 | } |
| 17 | |
| 18 | void Platform::SetTitle(const std::string& title) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | void Platform::UpdateRunningFlag() |
| 23 | { |
| 24 | if (m_shutdown_requested.TestAndClear()) |
| 25 | { |
| 26 | const auto& system = Core::System::GetInstance(); |
| 27 | const auto ios = system.GetIOS(); |
| 28 | const auto stm = ios ? ios->GetDeviceByName("/dev/stm/eventhook") : nullptr; |
| 29 | if (!m_tried_graceful_shutdown.IsSet() && stm && |
| 30 | std::static_pointer_cast<IOS::HLE::STMEventHookDevice>(stm)->HasHookInstalled()) |
| 31 | { |
| 32 | system.GetProcessorInterface().PowerButton_Tap(); |
| 33 | m_tried_graceful_shutdown.Set(); |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | m_running.Clear(); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void Platform::Stop() |
| 43 | { |
| 44 | m_running.Clear(); |
| 45 | } |
| 46 | |
| 47 | void Platform::RequestShutdown() |
| 48 | { |
| 49 | m_shutdown_requested.Set(); |
| 50 | } |