|
|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
use core::fmt;
|
|
|
|
|
use std::io::Write;
|
|
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate lazy_static;
|
|
|
|
|
|
|
|
|
|
@ -23,18 +23,20 @@ fn main() -> () {
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let mut handles: Vec<_> = Vec::new();
|
|
|
|
|
run(&D, pedals);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn run(device: &'static evdev::Device, pedals: Vec<Pedal>) {
|
|
|
|
|
let mut handles: Vec<_> = Vec::new();
|
|
|
|
|
for pedal in pedals {
|
|
|
|
|
let handle = std::thread::spawn(move || loop {
|
|
|
|
|
if D.get_key_state().unwrap().contains(pedal.key) {
|
|
|
|
|
if device.get_key_state().unwrap().contains(pedal.key) {
|
|
|
|
|
(*pedal.action)();
|
|
|
|
|
}
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
|
|
|
|
});
|
|
|
|
|
handles.push(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for handle in handles {
|
|
|
|
|
handle.join().expect("Couldn't join");
|
|
|
|
|
}
|
|
|
|
|
|