Debian Codegraph @

README.md

raw symbols SCIP
1 `evdev`
2 =======
3
4 [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/emberian/evdev/rust.yml?branch=main)](https://github.com/emberian/evdev/actions/workflows/rust.yml)
5 [![Crates.io](https://img.shields.io/crates/v/evdev.svg?style=flat-square)](https://crates.io/crates/evdev)
6
7 [Documentation](https://docs.rs/evdev)
8
9 Nice(r) access to `evdev` devices.
10
11 What is `evdev`?
12 ===================
13
14 `evdev` is the Linux kernel's generic input interface, also implemented by other
15 kernels such as FreeBSD.
16
17 [libevdev](https://www.freedesktop.org/wiki/Software/libevdev/) is a userspace
18 library written in c for interacting with this system in a high level way rather
19 than using `ioctl` system calls directly.
20
21 This crate is a re-implementation of `libevdev` in rust. There is some trickery
22 involved, so please read the crate documentation.
23
24 There is also an alternative crate: [evdev-rs](https://crates.io/crates/evdev-rs)
25 which wraps `libevdev` instead.
26
27 Overview
28 ========
29 This crate provides functionality for reading streams of events from input devices.
30
31 Like `libevdev`, this crate also provides functionality for interacting with
32 [uinput](https://www.kernel.org/doc/html/latest/input/uinput.html).
33 Uinput is a kernel module which allows virtual input devices to be created from userspace.
34
35
36 Synchronization
37 ===============
38 This library exposes raw evdev events, but uses the Rust `Iterator` trait to
39 do so. When processing events via `fetch_events`, the library will handle
40 `SYN_DROPPED` events by injecting fake state updates in an attempt to ensure
41 callers see state transition messages consistent with actual device state. When
42 processing via `*_no_sync` this correction is not done, and `SYN_DROPPED` messages
43 will appear if the kernel ring buffer is overrun before messages are read. I try to
44 match [libevdev](https://www.freedesktop.org/software/libevdev/doc/latest/)
45 closely, where possible.
46
47
48 Limitations
49 ===========
50 There is no abstraction for gamepad-like devices that allows mapping button
51 numbers to logical buttons, nor is one planned. Such a thing should take place
52 in a higher-level crate, likely supporting multiple platforms.
53
54
55 Example
56 =======
57
58 Plenty of nice examples of how to use this crate can be found in the
59 [examples](examples) directory of this repository. If you feel like an example of
60 how to use a certain part of the evdev crate is missing, then feel free to open a
61 pull request.
62
63 A good introduction is the [evtest.rs](examples/evtest.rs) example (which roughly
64 corresponds to the userspace [evtest](https://cgit.freedesktop.org/evtest/)
65 tool.
66
67 Releases
68 ========
69
70 Detailed release notes are available in this repository at [CHANGELOG.md](CHANGELOG.md).