Expand description
Rust bindings to libevdev, a wrapper for evdev devices.
This library intends to provide a safe interface to the libevdev library. It will look for the library on the local system, and link to the installed copy.
§Examples
§Intializing a evdev device
use evdev_rs::Device;
use std::fs::File;
let file = File::open("/dev/input/event0").unwrap();
let mut d = Device::new_from_file(file).unwrap();§Getting the next event
use evdev_rs::Device;
use std::fs::File;
use evdev_rs::ReadFlag;
let file = File::open("/dev/input/event0").unwrap();
let mut d = Device::new_from_file(file).unwrap();
loop {
let ev = d.next_event(ReadFlag::NORMAL | ReadFlag::BLOCKING).map(|val| val.1);
match ev {
Ok(ev) => println!("Event: time {}.{}, ++++++++++++++++++++ {} +++++++++++++++",
ev.time.tv_sec,
ev.time.tv_usec,
ev.event_type().map(|ev_type| format!("{}", ev_type)).unwrap_or("".to_owned())),
Err(e) => (),
}
}§Serialization
to use serialization, you muse enable the serde feature.
# Cargo.toml
[dependencies]
evdev-rs = { version = "0.4.0", features = ["serde"] }Modules§
Structs§
- AbsInfo
- used by EVIOCGABS/EVIOCSABS ioctls
- Device
- Opaque struct representing an evdev device
- Device
Id - Input
Event - The event structure itself
- Read
Flag - TimeVal
- UInput
Device - Opaque struct representing an evdev uinput device
- Uninit
Device - Opaque struct representing an evdev device with no backing file
Enums§
Traits§
- Device
Wrapper - Abstraction over structs which contain an inner
*mut libevdev