parent
e1b8988843
commit
2d00486f6b
@ -1,19 +1,27 @@
|
|||||||
pub use crate::Pedal;
|
pub use crate::Pedal;
|
||||||
use evdev::Key;
|
use evdev::{EventType, InputEvent, Key};
|
||||||
|
|
||||||
pub fn pedals() -> Vec<Pedal> {
|
pub fn pedals() -> Vec<Pedal> {
|
||||||
vec![
|
vec![
|
||||||
Pedal {
|
Pedal {
|
||||||
key: Key::BTN_SIDE,
|
key: Key::BTN_SIDE,
|
||||||
action: Box::new(|tx| tx.send(String::from("BTN_SIDE")).unwrap()),
|
action: Box::new(|tx| ()),
|
||||||
},
|
},
|
||||||
Pedal {
|
Pedal {
|
||||||
key: Key::BTN_EXTRA,
|
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 {
|
Pedal {
|
||||||
key: Key::BTN_RIGHT,
|
key: Key::BTN_RIGHT,
|
||||||
action: Box::new(|tx| tx.send(String::from("BTN_RIGHT")).unwrap()),
|
action: Box::new(|tx| ()),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue