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
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "Common/Flag.h"
|
|
|
|
#include "Common/WindowSystemInfo.h"
|
|
|
|
|
|
|
|
class Platform
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Platform();
|
|
|
|
|
|
|
|
bool IsRunning() const { return m_running.IsSet(); }
|
|
|
|
bool IsWindowFocused() const { return m_window_focus; }
|
|
|
|
bool IsWindowFullscreen() const { return m_window_fullscreen; }
|
|
|
|
|
|
|
|
virtual bool Init();
|
|
|
|
virtual void SetTitle(const std::string& title);
|
|
|
|
virtual void MainLoop() = 0;
|
|
|
|
|
|
|
|
virtual WindowSystemInfo GetWindowSystemInfo() const = 0;
|
|
|
|
|
|
|
|
// Requests a graceful shutdown, from SIGINT/SIGTERM.
|
|
|
|
void RequestShutdown();
|
|
|
|
|
|
|
|
// Request an immediate shutdown.
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
static std::unique_ptr<Platform> CreateHeadlessPlatform();
|
|
|
|
#ifdef HAVE_X11
|
|
|
|
static std::unique_ptr<Platform> CreateX11Platform();
|
|
|
|
#endif
|
2019-11-26 04:25:19 +00:00
|
|
|
|
2019-04-10 14:44:21 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
static std::unique_ptr<Platform> CreateFBDevPlatform();
|
|
|
|
#endif
|
2018-10-24 05:50:54 +00:00
|
|
|
|
2019-11-26 04:25:19 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
static std::unique_ptr<Platform> CreateWin32Platform();
|
|
|
|
#endif
|
|
|
|
|
2023-02-02 00:00:12 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
static std::unique_ptr<Platform> CreateMacOSPlatform();
|
|
|
|
#endif
|
|
|
|
|
2018-10-24 05:50:54 +00:00
|
|
|
protected:
|
|
|
|
void UpdateRunningFlag();
|
|
|
|
|
|
|
|
Common::Flag m_running{true};
|
|
|
|
Common::Flag m_shutdown_requested{false};
|
|
|
|
Common::Flag m_tried_graceful_shutdown{false};
|
|
|
|
|
2021-05-09 10:28:04 +00:00
|
|
|
bool m_window_focus = true; // Should be made atomic if actually implemented
|
2018-10-24 05:50:54 +00:00
|
|
|
bool m_window_fullscreen = false;
|
|
|
|
};
|