libevdevxx 0.4.0
A C++ wrapper for libevdev.
Loading...
Searching...
No Matches
Uinput.hpp
Go to the documentation of this file.
1/*
2 * libevdevxx - a C++ wrapper for libevdev
3 *
4 * Copyright (C) 2021-2023 Daniel K. O.
5 * SPDX-License-Identifier: MIT
6 */
7
8
9#ifndef LIBEVDEVXX_UINPUT_HPP
10#define LIBEVDEVXX_UINPUT_HPP
11
12
13#include <filesystem>
14#include <memory>
15#include <optional>
16
17#include <libevdev/libevdev-uinput.h>
18
19#include "Device.hpp"
20#include "Event.hpp"
21
22
23namespace evdev {
24
25
27 class Uinput {
28
29 public:
30
31 Uinput(const Device& dev);
32 Uinput(const Device& dev, int filedes);
33
34
35 ::libevdev_uinput* data() noexcept;
36 const ::libevdev_uinput* data() const noexcept;
37
38
39 int fd() const noexcept;
40
41 std::optional<std::filesystem::path>
42 syspath() noexcept;
43
44 std::optional<std::filesystem::path>
45 devnode() noexcept;
46
47 void write(Type type, Code code, int value);
48 void write(TypeCode type_code, int value);
49 void write(const Event& event);
50
51
52 // convenience methods
53
54 void syn(Code code, int value);
55 void key(Code code, int value);
56 void rel(Code code, int value);
57 void abs(Code code, int value);
58 void msc(Code code, int value);
59 void sw(Code code, int value);
60 void led(Code code, int value);
61 void snd(Code code, int value);
62 void rep(Code code, int value);
63 void ff(Code code, int value);
64 void pwr(Code code, int value);
65 void ff_status(Code code, int value);
66
67 void flush();
68
69
70 private:
71
72 struct Deleter {
73 void operator()(::libevdev_uinput* udev) const noexcept;
74 };
75
76 std::unique_ptr<::libevdev_uinput, Deleter> udev;
77
78 };
79
80
81} // namespace evdev
82
83
84#endif
Represents a device (real of not).
Definition: Device.hpp:52
Definition: Type.hpp:28
A class to send events to a virtual device.
Definition: Uinput.hpp:27
void msc(Code code, int value)
void led(Code code, int value)
::libevdev_uinput * data() noexcept
void rel(Code code, int value)
void key(Code code, int value)
void write(Type type, Code code, int value)
void syn(Code code, int value)
Uinput(const Device &dev)
void ff(Code code, int value)
void rep(Code code, int value)
Uinput(const Device &dev, int filedes)
void ff_status(Code code, int value)
void sw(Code code, int value)
int fd() const noexcept
void pwr(Code code, int value)
std::optional< std::filesystem::path > syspath() noexcept
void abs(Code code, int value)
void snd(Code code, int value)
std::optional< std::filesystem::path > devnode() noexcept
The namespace of libevdevxx.
Definition: AbsInfo.hpp:20
Definition: TypeCode.hpp:23
Type-safe class for evdev codes (KEY_*, BTN_*, REL_*, etc).
Definition: Code.hpp:32
Definition: Event.hpp:30