From 3f3382ffa7360fcfae8d80b514784f2f8a6b7c09 Mon Sep 17 00:00:00 2001 From: Anna Rose Wiggins Date: Thu, 7 Aug 2025 19:02:55 -0400 Subject: [PATCH] Make evinfo build. --- src/bin/evinfo.rs | 50 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/bin/evinfo.rs b/src/bin/evinfo.rs index c392f44..82665f1 100644 --- a/src/bin/evinfo.rs +++ b/src/bin/evinfo.rs @@ -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}"), + }); - let devices = get_devices(); - - for _device in devices.iter() { - // print_device(device); - } + println!("{}", args.verbose); } -fn get_devices() -> Vec { - return Vec::new(); +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() + ); + + 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()); + } + + // if verbose > 1 { + // let absInfo = device.get_absinfo()?; + // if absInfo.count() > 0 { + // println!("\tAxis Data:"); + // absInfo.for_each(|info| println!("\t\t{} {}")); + // } + // } + + Ok(()) }