diff --git a/src/main.rs b/src/main.rs index cac8b71..2a8f5d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,17 +11,23 @@ fn main() -> () { let d = pick_device(); d }; - static ref OUTPUT_DEVICE: evdev::uinput::VirtualDevice = { - let d = create_device().unwrap(); - d - }; } println!("{}", INPUT_DEVICE.name().unwrap_or("Unknown device")); - run(&INPUT_DEVICE, crate::pedals::pedals().into_iter()); + let mut drum_pedal: evdev::uinput::VirtualDevice = create_device().unwrap(); + + run( + &INPUT_DEVICE, + &mut drum_pedal, + crate::pedals::pedals().into_iter(), + ); } -fn run(input_device: &'static evdev::Device, pedals: impl Iterator) { +fn run( + input_device: &'static evdev::Device, + output_device: &mut evdev::uinput::VirtualDevice, + pedals: impl Iterator, +) { let mut handles: Vec<_> = Vec::new(); let (tx, rx) = std::sync::mpsc::channel(); for pedal in pedals { @@ -36,7 +42,7 @@ fn run(input_device: &'static evdev::Device, pedals: impl Iterator } for recieved in rx { - println!("{:?}", recieved); + output_device.emit(&[recieved]).unwrap(); } for handle in handles {