MCPcopy Index your code
hub / github.com/emberian/evdev

github.com/emberian/evdev @0.13.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.13.2 ↗ · + Follow
347 symbols 688 edges 30 files 148 documented · 43% 7 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

evdev

GitHub Workflow Status Crates.io

Documentation

Nice(r) access to evdev devices.

What is evdev?

evdev is the Linux kernel's generic input interface, also implemented by other kernels such as FreeBSD.

libevdev is a userspace library written in c for interacting with this system in a high level way rather than using ioctl system calls directly.

This crate is a re-implementation of libevdev in rust. There is some trickery involved, so please read the crate documentation.

There is also an alternative crate: evdev-rs which wraps libevdev instead.

Overview

This crate provides functionality for reading streams of events from input devices.

Like libevdev, this crate also provides functionality for interacting with uinput. Uinput is a kernel module which allows virtual input devices to be created from userspace.

Synchronization

This library exposes raw evdev events, but uses the Rust Iterator trait to do so. When processing events via fetch_events, the library will handle SYN_DROPPED events by injecting fake state updates in an attempt to ensure callers see state transition messages consistent with actual device state. When processing via *_no_sync this correction is not done, and SYN_DROPPED messages will appear if the kernel ring buffer is overrun before messages are read. I try to match libevdev closely, where possible.

Limitations

There is no abstraction for gamepad-like devices that allows mapping button numbers to logical buttons, nor is one planned. Such a thing should take place in a higher-level crate, likely supporting multiple platforms.

Example

Plenty of nice examples of how to use this crate can be found in the examples directory of this repository. If you feel like an example of how to use a certain part of the evdev crate is missing, then feel free to open a pull request.

A good introduction is the evtest.rs example (which roughly corresponds to the userspace evtest tool.

Releases

Detailed release notes are available in this repository at CHANGELOG.md.

Extension points exported contracts — how you extend this code

EvdevEnum (Interface)
(no doc)
src/attribute_set.rs
ArrayedEvdevEnum (Interface)
(no doc)
src/attribute_set.rs

Core symbols most depended-on inside this repo

as_raw_fd
called by 31
src/raw_stream.rs
as_raw_fd
called by 26
src/uinput.rs
emit
called by 25
src/uinput.rs
iter
called by 18
src/attribute_set.rs
contains
called by 17
src/attribute_set.rs
code
called by 14
src/lib.rs
as_mut_raw_slice
called by 13
src/attribute_set.rs
insert
called by 10
src/attribute_set.rs

Shape

Method 217
Class 80
Function 43
Enum 5
Interface 2

Languages

Rust100%

Modules by API surface

src/sync_stream.rs66 symbols
src/raw_stream.rs60 symbols
src/uinput.rs47 symbols
src/lib.rs35 symbols
src/attribute_set.rs27 symbols
src/event_variants.rs18 symbols
src/constants.rs15 symbols
src/compat/non_linux.rs15 symbols
src/inputid.rs10 symbols
src/device_state.rs10 symbols
src/ff.rs8 symbols
tests/common/mod.rs6 symbols

For agents

$ claude mcp add evdev \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact