diff --git a/src/main.rs b/src/main.rs index 1dd2e63..cac8b71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ fn run(input_device: &'static evdev::Device, pedals: impl Iterator } for recieved in rx { - println!("{}", recieved); + println!("{:?}", recieved); } for handle in handles { @@ -81,5 +81,5 @@ fn create_device() -> Result) -> () + Send + 'static>, + action: Box) -> () + Send + 'static>, } diff --git a/src/pedals.rs b/src/pedals.rs index 206ad91..5612641 100644 --- a/src/pedals.rs +++ b/src/pedals.rs @@ -1,19 +1,27 @@ pub use crate::Pedal; -use evdev::Key; +use evdev::{EventType, InputEvent, Key}; pub fn pedals() -> Vec { vec![ Pedal { key: Key::BTN_SIDE, - action: Box::new(|tx| tx.send(String::from("BTN_SIDE")).unwrap()), + action: Box::new(|tx| ()), }, Pedal { key: Key::BTN_EXTRA, - action: Box::new(|tx| tx.send(String::from("BTN_EXTRA")).unwrap()), + action: Box::new(|tx| { + let code = Key::KEY_F.code(); + let down_event = InputEvent::new(EventType::KEY, code, 1); + let up_event = InputEvent::new(EventType::KEY, code, 0); + tx.send(down_event).unwrap(); + std::thread::sleep(std::time::Duration::from_millis(24)); + tx.send(up_event).unwrap(); + std::thread::sleep(std::time::Duration::from_millis(33)); + }), }, Pedal { key: Key::BTN_RIGHT, - action: Box::new(|tx| tx.send(String::from("BTN_RIGHT")).unwrap()), + action: Box::new(|tx| ()), }, ] }