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 clap::Parser;
|
||||||
use evdev::Device;
|
use evdev::raw_stream::RawDevice;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[arg(short, long)]
|
/// Print additional information
|
||||||
verbose: bool,
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
|
verbose: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let mut _verbosity = 0;
|
let devices = evdev::raw_stream::enumerate();
|
||||||
if args.verbose {
|
devices.for_each(|(path, dev)| match print_device(path, dev, args.verbose) {
|
||||||
_verbosity += 1;
|
Ok(_) => return,
|
||||||
}
|
Err(err) => println!("Failed to print device info: {err}"),
|
||||||
|
});
|
||||||
|
|
||||||
let devices = get_devices();
|
println!("{}", args.verbose);
|
||||||
|
|
||||||
for _device in devices.iter() {
|
|
||||||
// print_device(device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_devices() -> Vec<evdev::Device> {
|
fn print_device(path: PathBuf, device: RawDevice, verbose: u8) -> Result<(), std::io::Error> {
|
||||||
return Vec::new();
|
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(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue