From 0a75e71672ed63d6d92ba42c1a183e72090d7c83 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 10 Apr 2019 14:44:21 +0000 Subject: DolphinNoGUI: Add a FBDev platform And the associated GLContext bits --- Source/Core/DolphinNoGUI/PlatformFBDev.cpp | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 Source/Core/DolphinNoGUI/PlatformFBDev.cpp (limited to 'Source/Core/DolphinNoGUI/PlatformFBDev.cpp') diff --git a/Source/Core/DolphinNoGUI/PlatformFBDev.cpp b/Source/Core/DolphinNoGUI/PlatformFBDev.cpp new file mode 100644 index 0000000000..9818105521 --- /dev/null +++ b/Source/Core/DolphinNoGUI/PlatformFBDev.cpp @@ -0,0 +1,102 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include + +#include "DolphinNoGUI/Platform.h" + +#include "Common/MsgHandler.h" +#include "Core/ConfigManager.h" +#include "Core/Core.h" +#include "Core/State.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "VideoCommon/RenderBase.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; + +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(); + + // 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_surface = nullptr; + return wsi; +} +} // namespace + +std::unique_ptr Platform::CreateFBDevPlatform() +{ + return std::make_unique(); +} -- cgit v1.2.3