add: threaded prototype press checker

v0.1.1
rrr-marble 5 years ago
parent 57c6a86f0f
commit a05ed22f26

@ -2,7 +2,7 @@ use std::{io::Write, thread::sleep};
#[macro_use]
extern crate lazy_static;
fn main() -> ! {
fn main() -> () {
lazy_static! {
static ref D: evdev::Device = {
let d = pick_device();
@ -10,12 +10,23 @@ fn main() -> ! {
};
}
println!("{}", D.name().unwrap_or("Unknown device"));
loop {
let side_handle = std::thread::spawn(|| loop {
if D.get_key_state().unwrap().contains(evdev::Key::BTN_SIDE) {
println!("BTN_SIDE");
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
});
let extra_handle = std::thread::spawn(|| loop {
if D.get_key_state().unwrap().contains(evdev::Key::BTN_EXTRA) {
println!("BTN_EXTRA");
}
std::thread::sleep(std::time::Duration::from_millis(100));
});
extra_handle.join().expect("Couldn't join");
side_handle.join().expect("Couldn't join");
}
fn pick_device() -> evdev::Device {

Loading…
Cancel
Save