Debian Codegraph @

Source/Core/DolphinNoGUI/PlatformHeadless.cpp

raw symbols SCIP
1 // Copyright 2018 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include <cstdio>
5 #include <thread>
6
7 #include "Core/Core.h"
8 #include "Core/System.h"
9 #include "DolphinNoGUI/Platform.h"
10
11 namespace
12 {
13 class PlatformHeadless final : public Platform
14 {
15 public:
16 void SetTitle(const std::string& title) override;
17 void MainLoop() override;
18
19 WindowSystemInfo GetWindowSystemInfo() const override;
20 };
21
22 void PlatformHeadless::SetTitle(const std::string& title)
23 {
24 std::fprintf(stdout, "%s\n", title.c_str());
25 }
26
27 void PlatformHeadless::MainLoop()
28 {
29 while (m_running.IsSet())
30 {
31 UpdateRunningFlag();
32 Core::HostDispatchJobs(Core::System::GetInstance());
33 std::this_thread::sleep_for(std::chrono::milliseconds(100));
34 }
35 }
36
37 WindowSystemInfo PlatformHeadless::GetWindowSystemInfo() const
38 {
39 WindowSystemInfo wsi;
40 wsi.type = WindowSystemType::Headless;
41 wsi.display_connection = nullptr;
42 wsi.render_window = nullptr;
43 wsi.render_surface = nullptr;
44 return wsi;
45 }
46
47 } // namespace
48
49 std::unique_ptr<Platform> Platform::CreateHeadlessPlatform()
50 {
51 return std::make_unique<PlatformHeadless>();
52 }