Crate evdev_rs

source ·
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.

# Cargo.toml
[dependencies]
evdev-rs = { version = "0.4.0", features = ["serde"] }

Re-exports

Modules

Structs

Enums

Traits

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