https://github.com/dkosmari/libevdevxx
A C++ wrapper for libevdev
https://github.com/dkosmari/libevdevxx
cplusplus-20 evdev libevdev linux
Last synced: 6 months ago
JSON representation
A C++ wrapper for libevdev
- Host: GitHub
- URL: https://github.com/dkosmari/libevdevxx
- Owner: dkosmari
- License: mit
- Created: 2023-03-24T11:01:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-09-12T05:52:38.000Z (6 months ago)
- Last Synced: 2025-09-12T06:25:18.946Z (6 months ago)
- Topics: cplusplus-20, evdev, libevdev, linux
- Language: C++
- Homepage: https://dkosmari.github.io/libevdevxx/
- Size: 521 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
- Authors: AUTHORS
Awesome Lists containing this project
README
# libevdevxx - a C++ wrapper for libevdev

`libevdevxx` is a C++20 wrapper for the C library `libevdev`, which is a high-level C
library for the `evdev` Linux driver. This library exposes all of `libevdev` as C++ classes
and methods, with RAII and type safety.
## Documentation
HTML documentation can be found here: https://dkosmari.github.io/libevdevxx/
## Example
This example ([examples/circle-mouse.cpp](examples/circle-mouse.cpp)) creates a virtual
mouse, through the `uinput` subsystem, and generates events to simulate the mouse moving
in a circle.
```cpp
#include
#include
#include
#include
#include
using std::cout;
using std::endl;
using std::flush;
using namespace std::literals;
int
main()
{
using evdev::Code;
evdev::Device dev;
dev.set_name("Fake Mouse");
dev.enable_rel(Code{REL_X});
dev.enable_rel(Code{REL_Y});
// needs at least one button to be recognized as a mouse
dev.enable_key(Code{BTN_LEFT});
evdev::Uinput udev{dev};
cout << "Created uinput device at "
<< udev.get_devnode()
<< endl;
cout << "Doing a circle... " << flush;
const float radius = 10;
for (int i = 0; i < 100; ++i) {
float angle = i/100.0f * 2 * M_PI;
int x = static_cast(radius * std::cos(angle));
int y = static_cast(radius * std::sin(angle));
udev.write_rel(Code{REL_X}, x);
udev.write_rel(Code{REL_Y}, y);
udev.flush();
std::this_thread::sleep_for(16ms);
}
cout << "done." << endl;
}
```
See the contents of [examples](examples) and [tools](tools) for more examples.
## Building
### Dependencies
- A C++20 compiler, usually installed by a meta package like `task-c++` or `build-essential`.
- C/C++ compilation tools such as:
- `autoconf`
- `automake`
- `libtool`
- `pkg-config`
- [libevdev](http://www.freedesktop.org/wiki/Software/libevdev) 1.13+: usually available as a
package in your distro (you need the "devel" package.)
### Instructions
You can obtain the source through a release tarball, or by cloning the repository. If you
use a release tarball, you can skip step 0.
0. `./bootstrap`
1. `./configure`
2. `make`
3. `sudo make install`
This is a standard Automake package; more installation details can be found in the file
[INSTALL](INSTALL) or by running `./configure --help`.