Make evinfo build.
This commit is contained in:
parent
08aac599a6
commit
3f3382ffa7
1 changed files with 35 additions and 15 deletions
|
@ -1,29 +1,49 @@
|
|||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use evdev::Device;
|
||||
use evdev::raw_stream::RawDevice;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(short, long)]
|
||||
verbose: bool,
|
||||
/// Print additional information
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
verbose: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let mut _verbosity = 0;
|
||||
if args.verbose {
|
||||
_verbosity += 1;
|
||||
let devices = evdev::raw_stream::enumerate();
|
||||
devices.for_each(|(path, dev)| match print_device(path, dev, args.verbose) {
|
||||
Ok(_) => return,
|
||||
Err(err) => println!("Failed to print device info: {err}"),
|
||||
});
|
||||
|
||||
println!("{}", args.verbose);
|
||||
}
|
||||
|
||||
let devices = get_devices();
|
||||
fn print_device(path: PathBuf, device: RawDevice, verbose: u8) -> Result<(), std::io::Error> {
|
||||
println!(
|
||||
"{}: \"{}\"",
|
||||
path.to_str().unwrap_or_default(),
|
||||
device.name().unwrap_or_default()
|
||||
);
|
||||
|
||||
for _device in devices.iter() {
|
||||
// print_device(device);
|
||||
}
|
||||
if verbose > 0 {
|
||||
let input_id = device.input_id();
|
||||
println!("\tUUID:\t{}", device.unique_name().unwrap_or_default());
|
||||
println!("\tVendor:\t{}", input_id.vendor());
|
||||
println!("\tProduct:\t{}", input_id.product());
|
||||
println!("\tVersion:\t{}", input_id.version());
|
||||
}
|
||||
|
||||
fn get_devices() -> Vec<evdev::Device> {
|
||||
return Vec::new();
|
||||
// if verbose > 1 {
|
||||
// let absInfo = device.get_absinfo()?;
|
||||
// if absInfo.count() > 0 {
|
||||
// println!("\tAxis Data:");
|
||||
// absInfo.for_each(|info| println!("\t\t{} {}"));
|
||||
// }
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue