NoGUI: Migrate to new host abstraction
This commit is contained in:
57
src/duckstation-nogui/vty_nogui_platform.h
Normal file
57
src/duckstation-nogui/vty_nogui_platform.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include "nogui_platform.h"
|
||||
#include <atomic>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <libevdev/libevdev.h>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
class VTYNoGUIPlatform : public NoGUIPlatform
|
||||
{
|
||||
public:
|
||||
VTYNoGUIPlatform();
|
||||
~VTYNoGUIPlatform();
|
||||
|
||||
bool Initialize();
|
||||
|
||||
void ReportError(const std::string_view& title, const std::string_view& message) override;
|
||||
|
||||
void SetDefaultConfig(SettingsInterface& si) override;
|
||||
|
||||
bool CreatePlatformWindow(std::string title) override;
|
||||
void DestroyPlatformWindow() override;
|
||||
std::optional<WindowInfo> GetPlatformWindowInfo() override;
|
||||
void SetPlatformWindowTitle(std::string title) override;
|
||||
void* GetPlatformWindowHandle() override;
|
||||
|
||||
std::optional<u32> ConvertHostKeyboardStringToCode(const std::string_view& str) override;
|
||||
std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code) override;
|
||||
|
||||
void RunMessageLoop() override;
|
||||
void ExecuteInMessageLoop(std::function<void()> func) override;
|
||||
void QuitMessageLoop() override;
|
||||
|
||||
void SetFullscreen(bool enabled) override;
|
||||
|
||||
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
|
||||
|
||||
private:
|
||||
void OpenEVDevFDs();
|
||||
void CloseEVDevFDs();
|
||||
void PollEvDevKeyboards();
|
||||
void SetImGuiKeyMap();
|
||||
|
||||
struct EvDevKeyboard
|
||||
{
|
||||
struct libevdev* obj;
|
||||
int fd;
|
||||
};
|
||||
|
||||
std::vector<EvDevKeyboard> m_evdev_keyboards;
|
||||
|
||||
std::deque<std::function<void()>> m_callback_queue;
|
||||
std::mutex m_callback_queue_mutex;
|
||||
|
||||
std::atomic_bool m_message_loop_running{false};
|
||||
};
|
||||
Reference in New Issue
Block a user