denise_evdev/lib.rs
1//! Linux evdev input for Denise.
2//!
3//! Reads mice, touchscreens and keyboards straight from `/dev/input/event*`, with
4//! no display server in the way.
5//!
6//! # Testing
7//!
8//! [`translate`] and [`keymap`] are platform-independent and unit tested
9//! everywhere. That is not tidiness: multitouch slot tracking, frame batching and
10//! modifier state are the parts that break, and each one is far easier to pin down
11//! as a table of raw event codes than by dragging a finger across a panel and
12//! guessing. Only device discovery and reading are gated to Linux.
13//!
14//! # Permissions
15//!
16//! Reading `/dev/input/event*` needs membership in the `input` group, or root.
17//! Being able to read every keystroke on the machine is exactly as sensitive as it
18//! sounds, which is why the group exists.
19//!
20//! # Blocking
21//!
22//! [`InputBackend::poll`] never blocks: it drains whatever is ready and returns.
23//! A frame loop that wants to sleep should wait on [`InputBackend::raw_fds`]
24//! together with the DRM device's descriptor, so the process idles in the kernel
25//! until either input arrives or the display retires a flip — rather than spinning
26//! to ask.
27
28pub mod codes;
29pub mod keymap;
30pub mod layout;
31pub mod translate;
32
33pub use keymap::key_code;
34pub use translate::{AbsAxis, MAX_SLOTS, RawEvent, Translator};
35
36#[cfg(target_os = "linux")]
37pub mod console;
38#[cfg(target_os = "linux")]
39mod device;
40#[cfg(target_os = "linux")]
41mod error;
42
43#[cfg(target_os = "linux")]
44pub use console::{Console, ConsoleError};
45#[cfg(target_os = "linux")]
46pub use device::{Capabilities, InputBackend, InputDevice};
47#[cfg(target_os = "linux")]
48pub use error::EvdevError;
49
50/// Compiles the examples in this crate's README, so they cannot drift from the API
51/// they claim to demonstrate. Never built except under `cargo test --doc`.
52#[cfg(doctest)]
53#[doc = include_str!("../README.md")]
54struct Readme;