|
|
|
@ -12,7 +12,7 @@ fn main() -> () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
println!("{}", D.name().unwrap_or("Unknown device"));
|
|
|
|
println!("{}", D.name().unwrap_or("Unknown device"));
|
|
|
|
|
|
|
|
|
|
|
|
let mut pedals = vec![
|
|
|
|
let pedals = vec![
|
|
|
|
Pedal {
|
|
|
|
Pedal {
|
|
|
|
key: evdev::Key::BTN_SIDE,
|
|
|
|
key: evdev::Key::BTN_SIDE,
|
|
|
|
action: Box::new(|| println!("BTN_SIDE")),
|
|
|
|
action: Box::new(|| println!("BTN_SIDE")),
|
|
|
|
@ -23,23 +23,21 @@ fn main() -> () {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
let pedal = pedals.pop().unwrap();
|
|
|
|
let mut handles: Vec<_> = Vec::new();
|
|
|
|
let side_handle = std::thread::spawn(move || loop {
|
|
|
|
|
|
|
|
if D.get_key_state().unwrap().contains(pedal.key) {
|
|
|
|
|
|
|
|
(*pedal.action)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let extra_handle = std::thread::spawn(|| loop {
|
|
|
|
for pedal in pedals {
|
|
|
|
if D.get_key_state().unwrap().contains(evdev::Key::BTN_SIDE) {
|
|
|
|
let handle = std::thread::spawn(move || loop {
|
|
|
|
println!("BTN_SIDE");
|
|
|
|
if D.get_key_state().unwrap().contains(pedal.key) {
|
|
|
|
}
|
|
|
|
(*pedal.action)();
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
handles.push(handle);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extra_handle.join().expect("Couldn't join");
|
|
|
|
for handle in handles {
|
|
|
|
side_handle.join().expect("Couldn't join");
|
|
|
|
handle.join().expect("Couldn't join");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn pick_device() -> evdev::Device {
|
|
|
|
fn pick_device() -> evdev::Device {
|
|
|
|
|