2018-10-24 05:50:54 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-10-24 05:50:54 +00:00
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <thread>
|
2024-03-18 08:35:42 +00:00
|
|
|
|
2018-10-24 05:50:54 +00:00
|
|
|
#include "Core/Core.h"
|
2024-03-18 08:35:42 +00:00
|
|
|
#include "Core/System.h"
|
2018-10-24 05:50:54 +00:00
|
|
|
#include "DolphinNoGUI/Platform.h"
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class PlatformHeadless : public Platform
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void SetTitle(const std::string& title) override;
|
|
|
|
void MainLoop() override;
|
|
|
|
|
|
|
|
WindowSystemInfo GetWindowSystemInfo() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
void PlatformHeadless::SetTitle(const std::string& title)
|
|
|
|
{
|
|
|
|
std::fprintf(stdout, "%s\n", title.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlatformHeadless::MainLoop()
|
|
|
|
{
|
|
|
|
while (m_running.IsSet())
|
|
|
|
{
|
|
|
|
UpdateRunningFlag();
|
2024-03-18 08:35:42 +00:00
|
|
|
Core::HostDispatchJobs(Core::System::GetInstance());
|
2018-10-24 05:50:54 +00:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowSystemInfo PlatformHeadless::GetWindowSystemInfo() const
|
|
|
|
{
|
|
|
|
WindowSystemInfo wsi;
|
|
|
|
wsi.type = WindowSystemType::Headless;
|
|
|
|
wsi.display_connection = nullptr;
|
2020-03-11 13:09:28 +00:00
|
|
|
wsi.render_window = nullptr;
|
2018-10-24 05:50:54 +00:00
|
|
|
wsi.render_surface = nullptr;
|
|
|
|
return wsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
std::unique_ptr<Platform> Platform::CreateHeadlessPlatform()
|
|
|
|
{
|
|
|
|
return std::make_unique<PlatformHeadless>();
|
|
|
|
}
|