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§

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

Modules§

enums
logging
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§

EnableCodeData
Extra data for use with enable_event_code
GrabMode
LedState
ReadStatus

Traits§

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