commit
3bbae0c368
@ -0,0 +1 @@
|
||||
/target
|
||||
@ -0,0 +1,91 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "0.21.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "470fbd40e959c961f16841fbf96edbbdcff766ead89a1ae2b53d22852be20998"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
"tap",
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "dpk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"evdev",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "evdev"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8a9fbd0d18faa6e194945a35d8f57b504502835a4a82a622723b8184818e72a"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"libc",
|
||||
"nix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "funty"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.97"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb"
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "wyz"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
|
||||
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "dpk"
|
||||
version = "0.1.0"
|
||||
authors = ["rrr-marble <rrr@marble.lan>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
evdev = "0.11.0"
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
use std::io::Write;
|
||||
|
||||
fn main() -> ! {
|
||||
let mut d = pick_device();
|
||||
println!("{}", d);
|
||||
println!("Events:");
|
||||
loop {
|
||||
for ev in d.fetch_events().unwrap() {
|
||||
println!("{:?}", ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pick_device() -> evdev::Device {
|
||||
let mut args = std::env::args_os();
|
||||
args.next();
|
||||
|
||||
if let Some(dev_file) = args.next() {
|
||||
evdev::Device::open(dev_file).unwrap()
|
||||
} else {
|
||||
let mut devices = evdev::enumerate().collect::<Vec<_>>();
|
||||
devices.reverse();
|
||||
for (i, d) in devices.iter().enumerate() {
|
||||
println!("{}: {}", i, d.name().unwrap_or("Unnamed device"));
|
||||
}
|
||||
print!("Select the device [0-{}]: ", devices.len());
|
||||
let _ = std::io::stdout().flush();
|
||||
let mut chosen = String::new();
|
||||
std::io::stdin().read_line(&mut chosen).unwrap();
|
||||
let n = chosen.trim().parse::<usize>().unwrap();
|
||||
devices.into_iter().nth(n).unwrap()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue