add: alternative hotkeys for the pedals

v0.1.1
rrr-marble 5 years ago
parent 68edb7ad72
commit eaad057411

@ -8,6 +8,18 @@ use evdev::{EventType, InputEvent, Key};
/// Returns a vector of currently defined key-action pairs
pub fn pedals() -> Vec<Pedal> {
vec![
Pedal {
key: Key::KEY_KP0,
action: Box::new(|tx| {
let code = Key::KEY_SPACE.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(26));
tx.send(up_event).unwrap();
std::thread::sleep(std::time::Duration::from_millis(31));
}),
},
Pedal {
key: Key::BTN_SIDE,
action: Box::new(|tx| {
@ -32,6 +44,18 @@ pub fn pedals() -> Vec<Pedal> {
std::thread::sleep(std::time::Duration::from_millis(33));
}),
},
Pedal {
key: Key::KEY_KP6,
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| {
@ -44,5 +68,17 @@ pub fn pedals() -> Vec<Pedal> {
std::thread::sleep(std::time::Duration::from_millis(26));
}),
},
Pedal {
key: Key::KEY_KP4,
action: Box::new(|tx| {
let code = Key::BTN_LEFT.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(19));
tx.send(up_event).unwrap();
std::thread::sleep(std::time::Duration::from_millis(26));
}),
},
]
}

Loading…
Cancel
Save