|
|
|
@ -11,17 +11,23 @@ fn main() -> () {
|
|
|
|
let d = pick_device();
|
|
|
|
let d = pick_device();
|
|
|
|
d
|
|
|
|
d
|
|
|
|
};
|
|
|
|
};
|
|
|
|
static ref OUTPUT_DEVICE: evdev::uinput::VirtualDevice = {
|
|
|
|
|
|
|
|
let d = create_device().unwrap();
|
|
|
|
|
|
|
|
d
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
println!("{}", INPUT_DEVICE.name().unwrap_or("Unknown device"));
|
|
|
|
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<Item = Pedal>) {
|
|
|
|
fn run(
|
|
|
|
|
|
|
|
input_device: &'static evdev::Device,
|
|
|
|
|
|
|
|
output_device: &mut evdev::uinput::VirtualDevice,
|
|
|
|
|
|
|
|
pedals: impl Iterator<Item = Pedal>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
let mut handles: Vec<_> = Vec::new();
|
|
|
|
let mut handles: Vec<_> = Vec::new();
|
|
|
|
let (tx, rx) = std::sync::mpsc::channel();
|
|
|
|
let (tx, rx) = std::sync::mpsc::channel();
|
|
|
|
for pedal in pedals {
|
|
|
|
for pedal in pedals {
|
|
|
|
@ -36,7 +42,7 @@ fn run(input_device: &'static evdev::Device, pedals: impl Iterator<Item = Pedal>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for recieved in rx {
|
|
|
|
for recieved in rx {
|
|
|
|
println!("{:?}", recieved);
|
|
|
|
output_device.emit(&[recieved]).unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for handle in handles {
|
|
|
|
for handle in handles {
|
|
|
|
|