Working evdev tester

This commit is contained in:
Marc Riera 2023-02-05 23:34:55 +01:00
parent c4cb41ac70
commit c1f0aa2a89
2 changed files with 18 additions and 2 deletions

View file

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
evdev-rs = "0.6.1"

View file

@ -1,3 +1,18 @@
use evdev_rs::Device;
use evdev_rs::ReadFlag;
fn main() {
println!("Hello, world!");
}
let d = Device::new_from_path("/dev/input/event4").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()),
ev.value),
Err(_e) => (),
}
}
}