msc: clarify device role with a name

v0.1.1
rrr-marble 5 years ago
parent b0f43d0b66
commit 73edc2da4f

@ -1,4 +1,4 @@
use std::io::Write;
use std::io::Write; //for .flush()
#[macro_use]
extern crate lazy_static;
@ -7,21 +7,21 @@ mod pedals;
fn main() -> () {
lazy_static! {
static ref D: evdev::Device = {
static ref INPUT_DEVICE: evdev::Device = {
let d = pick_device();
d
};
}
println!("{}", D.name().unwrap_or("Unknown device"));
println!("{}", INPUT_DEVICE.name().unwrap_or("Unknown device"));
run(&D, crate::pedals::pedals().into_iter());
run(&INPUT_DEVICE, crate::pedals::pedals().into_iter());
}
fn run(device: &'static evdev::Device, pedals: impl Iterator<Item = Pedal>) {
fn run(input_device: &'static evdev::Device, pedals: impl Iterator<Item = Pedal>) {
let mut handles: Vec<_> = Vec::new();
for pedal in pedals {
let handle = std::thread::spawn(move || loop {
if device.get_key_state().unwrap().contains(pedal.key) {
if input_device.get_key_state().unwrap().contains(pedal.key) {
(*pedal.action)();
}
std::thread::sleep(std::time::Duration::from_millis(100));

Loading…
Cancel
Save