mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-30 19:13:09 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
96 lines
1.7 KiB
C++
96 lines
1.7 KiB
C++
// Copyright 2018 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "DolphinNoGUI/Platform.h"
|
|
|
|
#include "Core/ConfigManager.h"
|
|
#include "Core/Core.h"
|
|
#include "Core/State.h"
|
|
#include "Core/System.h"
|
|
|
|
#include <cstdio>
|
|
#include <thread>
|
|
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
|
|
namespace
|
|
{
|
|
class PlatformFBDev : public Platform
|
|
{
|
|
public:
|
|
~PlatformFBDev() override;
|
|
|
|
bool Init() override;
|
|
void SetTitle(const std::string& string) override;
|
|
void MainLoop() override;
|
|
|
|
WindowSystemInfo GetWindowSystemInfo() const override;
|
|
|
|
private:
|
|
bool OpenFramebuffer();
|
|
|
|
int m_fb_fd = -1;
|
|
};
|
|
|
|
PlatformFBDev::~PlatformFBDev()
|
|
{
|
|
if (m_fb_fd >= 0)
|
|
close(m_fb_fd);
|
|
}
|
|
|
|
bool PlatformFBDev::Init()
|
|
{
|
|
if (!OpenFramebuffer())
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool PlatformFBDev::OpenFramebuffer()
|
|
{
|
|
m_fb_fd = open("/dev/fb0", O_RDWR);
|
|
if (m_fb_fd < 0)
|
|
{
|
|
std::fprintf(stderr, "open(/dev/fb0) failed\n");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void PlatformFBDev::SetTitle(const std::string& string)
|
|
{
|
|
std::fprintf(stdout, "%s\n", string.c_str());
|
|
}
|
|
|
|
void PlatformFBDev::MainLoop()
|
|
{
|
|
while (IsRunning())
|
|
{
|
|
UpdateRunningFlag();
|
|
Core::HostDispatchJobs(Core::System::GetInstance());
|
|
|
|
// TODO: Is this sleep appropriate?
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
}
|
|
}
|
|
|
|
WindowSystemInfo PlatformFBDev::GetWindowSystemInfo() const
|
|
{
|
|
WindowSystemInfo wsi;
|
|
wsi.type = WindowSystemType::FBDev;
|
|
wsi.display_connection = nullptr; // EGL_DEFAULT_DISPLAY
|
|
wsi.render_window = nullptr;
|
|
wsi.render_surface = nullptr;
|
|
return wsi;
|
|
}
|
|
} // namespace
|
|
|
|
std::unique_ptr<Platform> Platform::CreateFBDevPlatform()
|
|
{
|
|
return std::make_unique<PlatformFBDev>();
|
|
}
|