Deamon management
This commit is contained in:
38
daemon/uinput_keyboard.h
Normal file
38
daemon/uinput_keyboard.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// gKeyMapper daemon - virtual keyboard for replaying "key" mappings.
|
||||
#ifndef GKEYMAPPER_DAEMON_UINPUT_KEYBOARD_H
|
||||
#define GKEYMAPPER_DAEMON_UINPUT_KEYBOARD_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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<gkeymapper::ShortcutStep>& 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
|
||||
Reference in New Issue
Block a user