|
|
|
@ -5,6 +5,14 @@
|
|
|
|
pub use crate::Pedal;
|
|
|
|
pub use crate::Pedal;
|
|
|
|
use evdev::{EventType, InputEvent, Key};
|
|
|
|
use evdev::{EventType, InputEvent, Key};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Repeatedly press the key with given intervals
|
|
|
|
|
|
|
|
/// and send these keypresses into transmit channel
|
|
|
|
|
|
|
|
/// mash! (key to press,
|
|
|
|
|
|
|
|
/// down time(while pressed),
|
|
|
|
|
|
|
|
/// up time(between presses),
|
|
|
|
|
|
|
|
/// transmit channel)
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
/// ```mash!(KEY_F, 24, 33, tx)```
|
|
|
|
macro_rules! mash {
|
|
|
|
macro_rules! mash {
|
|
|
|
( $key:ident, $dt:literal, $ut:literal, $tx:ident ) => {{
|
|
|
|
( $key:ident, $dt:literal, $ut:literal, $tx:ident ) => {{
|
|
|
|
let code = Key::$key.code();
|
|
|
|
let code = Key::$key.code();
|
|
|
|
@ -32,5 +40,53 @@ pub fn pedals() -> Vec<Pedal> {
|
|
|
|
key: Key::KEY_KP8,
|
|
|
|
key: Key::KEY_KP8,
|
|
|
|
action: Box::new(|tx| mash!(BTN_LEFT, 19, 26, tx)),
|
|
|
|
action: Box::new(|tx| mash!(BTN_LEFT, 19, 26, tx)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Pedal {
|
|
|
|
|
|
|
|
key: Key::KEY_KP3,
|
|
|
|
|
|
|
|
action: Box::new(|tx| mash!(KEY_T, 27, 30, tx)),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Pedal {
|
|
|
|
|
|
|
|
key: Key::KEY_KP1,
|
|
|
|
|
|
|
|
action: Box::new(|tx| mash!(KEY_Y, 30, 44, tx)),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Pedal {
|
|
|
|
|
|
|
|
// pew-pew N1RRW
|
|
|
|
|
|
|
|
key: Key::KEY_KP6,
|
|
|
|
|
|
|
|
action: Box::new(|tx| {
|
|
|
|
|
|
|
|
// N1
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::BTN_LEFT.code(), 1))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::BTN_LEFT.code(), 0))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(300));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// R
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_R.code(), 1))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_R.code(), 0))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// R W
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_R.code(), 1))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_W.code(), 1))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_R.code(), 0))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tx.send(InputEvent::new(EventType::KEY, Key::KEY_W.code(), 0))
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
},
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|