evdev-rs/README.md
Jeff Hiner cb2f5ef87a
Separate out sane blocking and async (nonblocking) implementations (#33)
* Default impl should block. Renaming it to avoid API confusion from previous users.

* Can't get rid of libc::read because we have MaybeUninit, but we can clean up the match

* Remove extra include

* Switch everything over to io::Error

* Add initial tokio impl+example

* Move evtest_tokio to normal example

* Add documentation and clarify

* Use a VecDeque (ring buffer) instead of repeatedly popping things off the front of a Vec

* Looks like we are not using thiserror anymore; removing

* Store read buf between calls

* Add nonblocking example with epoll

Co-authored-by: Jeff Hiner <jeff-hiner@users.noreply.github.com>
Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
2021-03-01 10:09:11 -07:00

44 lines
1.6 KiB
Markdown

`evdev`
=======
[![Travis](https://img.shields.io/travis/cmr/evdev.svg?style=flat-square)](https://travis-ci.org/cmr/evdev)
[![Crates.io](https://img.shields.io/crates/v/evdev.svg?style=flat-square)](https://crates.io/crates/evdev)
[Documentation](https://docs.rs/evdev)
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.
This crate exposes access to these sorts of input devices. There is some trickery
involved, so please read the crate documentation.
What does this library support?
===============================
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](https://www.freedesktop.org/software/libevdev/doc/latest/)
closely, where possible.
Writing to devices is not yet supported (eg, turning LEDs on).
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
=======
See <examples/evtest.rs> for an example of using this library (which roughly
corresponds to the userspace [evtest](https://cgit.freedesktop.org/evtest/)
tool.