1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::fs::OpenOptions;
use std::os::unix::prelude::*;
use std::path::Path;
use hidraw::{get_physical_address, get_raw_info, get_raw_name, get_raw_unique, get_report_descriptor, Result};
const O_NONBLOCK: i32 = 2048;
fn print_info<P: AsRef<Path>>(path: P) -> Result<()> {
let mut file = OpenOptions::new().custom_flags(O_NONBLOCK).read(true).open(path)?;
println!("{:?}", get_physical_address(&mut file)?);
println!("{:?}", get_report_descriptor(&mut file)?);
println!("{:?}", get_raw_info(&mut file)?);
println!("{:?}", get_raw_name(&mut file)?);
println!("{:?}", get_raw_unique(&mut file)?);
Ok(())
}
fn main() {
for i in 0..20 {
if let Err(error) = print_info(format!("/dev/hidraw{i}")) {
eprintln!("{error}");
}
}
}