diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-01-20 23:11:00 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-01-20 23:11:00 +0100 |
commit | 47ada4d79844d9a98d9689d0de0c92864e0fc372 (patch) | |
tree | 1325fd3061e78a194b3db0be848a06928fdacce9 /include/Hotplug.hpp | |
parent | 92401d8bc8fa3cbc8017936eb1d18280199942e0 (diff) |
Add option to save replay with controller (double-click share button), allow prime-run on wayland
Diffstat (limited to 'include/Hotplug.hpp')
-rw-r--r-- | include/Hotplug.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/Hotplug.hpp b/include/Hotplug.hpp new file mode 100644 index 0000000..38fe25d --- /dev/null +++ b/include/Hotplug.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <functional> + +namespace gsr { + enum class HotplugAction { + ADD, + REMOVE + }; + + using HotplugEventCallback = std::function<void(HotplugAction hotplug_action, const char *devname)>; + + class Hotplug { + public: + Hotplug() = default; + Hotplug(const Hotplug&) = delete; + Hotplug& operator=(const Hotplug&) = delete; + ~Hotplug(); + + bool start(); + int steal_fd(); + void process_event_data(int fd, const HotplugEventCallback &callback); + private: + void parse_netlink_data(const char *line, const HotplugEventCallback &callback); + private: + int fd = -1; + bool started = false; + bool event_is_add = false; + bool event_is_remove = false; + bool subsystem_is_input = false; + char event_data[1024]; + }; +}
\ No newline at end of file |