// gKeyMapper daemon - virtual keyboard for replaying "key" mappings. #ifndef GKEYMAPPER_DAEMON_UINPUT_KEYBOARD_H #define GKEYMAPPER_DAEMON_UINPUT_KEYBOARD_H #include #include "mapping.h" namespace gkeymapper::daemon { // A virtual keyboard created through /dev/uinput. It is only used to replay // shortcuts; the daemon never reads from it. class UinputKeyboard { public: UinputKeyboard() = default; ~UinputKeyboard(); UinputKeyboard(const UinputKeyboard&) = delete; UinputKeyboard& operator=(const UinputKeyboard&) = delete; bool open(); void close(); bool is_open() const { return fd_ >= 0; } // Presses and releases every step of the shortcut in order. void play(const std::vector& steps); private: void emit(unsigned short type, unsigned short code, int value); void sync(); void key_event(unsigned short code, bool down); int fd_ = -1; }; } // namespace gkeymapper::daemon #endif // GKEYMAPPER_DAEMON_UINPUT_KEYBOARD_H