Crate evdev_rs[−][src]
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
| device | |
| enums | |
| logging | |
| uinput | |
| util |
Structs
| AbsInfo | used by EVIOCGABS/EVIOCSABS ioctls |
| Device | Opaque struct representing an evdev device |
| DeviceId | |
| InputEvent | The event structure itself |
| ReadFlag | |
| TimeVal | |
| UInputDevice | Opaque struct representing an evdev uinput device |
| UninitDevice | Opaque struct representing an evdev device with no backing file |
Enums
| GrabMode | |
| LedState | |
| ReadStatus |
Traits
| DeviceWrapper | Abstraction over structs which contain an inner |