diff --git a/src/main.rs b/src/main.rs index 0703bb3..82a5804 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {