Make evinfo build.

This commit is contained in:
Anna Rose Wiggins 2025-08-07 19:02:55 -04:00
parent 08aac599a6
commit 3f3382ffa7

View file

@ -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<evdev::Device> {
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(())
}