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 mut d = Device::new_from_path("/dev/input/event0").unwrap();

Getting the next event

use evdev_rs::Device;
use std::fs::File;
use evdev_rs::ReadFlag;

let mut d = Device::new_from_path("/dev/input/event0").unwrap();

loop {
    let ev = d.next_event(ReadFlag::NORMAL).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.

[dependencies]
evdev-rs = { version = "0.4.0", features = ["serde"] }

Re-exports

pub use util::EventCodeIterator;
pub use util::EventTypeIterator;
pub use util::InputPropIterator;

Modules

Structs

used by EVIOCGABS/EVIOCSABS ioctls
Opaque struct representing an evdev device
The event structure itself
Opaque struct representing an evdev uinput device
Opaque struct representing an evdev device with no backing file

Enums

Extra data for use with enable_event_code

Traits

Abstraction over structs which contain an inner *mut libevdev
Types that can be enabled on a DeviceWrapper (i.e. buttons, keys, relative motion)