3581aa25e0
* WIP syncing impl * Finish up syncing impl * Reorganize synchronization code + add more docs * Wrap libc::input_id * Remove thread::sleep used for testing * Make EventStream::Item io::Result<InputEvent> * Add RawDevice::empty_state() * Update Device rustdoc * Make raw/sync_stream naming consistent * Update crate docs * Fix missing first event of block * Owned AttributeSet, borrowed AttributeSetRef * Add some basic syncing tests * Add some more syncing tests
29 lines
882 B
Rust
29 lines
882 B
Rust
// Similar to the evtest tool.
|
|
|
|
use std::io::prelude::*;
|
|
|
|
fn main() {
|
|
let mut args = std::env::args_os();
|
|
let mut d = if args.len() > 1 {
|
|
evdev::Device::open(&args.nth(1).unwrap()).unwrap()
|
|
} else {
|
|
let devices = evdev::enumerate().collect::<Vec<_>>();
|
|
for (i, d) in devices.iter().enumerate() {
|
|
println!("{}: {}", i, d.name().unwrap_or("Unnamed device"));
|
|
}
|
|
print!("Select the device [0-{}]: ", devices.len());
|
|
let _ = std::io::stdout().flush();
|
|
let mut chosen = String::new();
|
|
std::io::stdin().read_line(&mut chosen).unwrap();
|
|
let n = chosen.trim().parse::<usize>().unwrap();
|
|
devices.into_iter().nth(n).unwrap()
|
|
};
|
|
println!("{}", d);
|
|
println!("Events:");
|
|
loop {
|
|
for ev in d.fetch_events().unwrap() {
|
|
println!("{:?}", ev);
|
|
}
|
|
}
|
|
}
|