add: more pedals

v0.2.1
rrr-marble 4 years ago
parent 3c0f8280b3
commit fac9b529e9

@ -110,6 +110,10 @@ fn create_device() -> Result<evdev::uinput::VirtualDevice, Box<dyn std::error::E
keys.insert(Key::KEY_F);
keys.insert(Key::KEY_SPACE);
keys.insert(Key::BTN_LEFT);
keys.insert(Key::KEY_T);
keys.insert(Key::KEY_Y);
keys.insert(Key::KEY_R);
keys.insert(Key::KEY_W);
let device = VirtualDeviceBuilder::new()?
.name("DPK Wired Gaming Keyboard Combo")

@ -5,6 +5,14 @@
pub use crate::Pedal;
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 {
( $key:ident, $dt:literal, $ut:literal, $tx:ident ) => {{
let code = Key::$key.code();
@ -32,5 +40,53 @@ pub fn pedals() -> Vec<Pedal> {
key: Key::KEY_KP8,
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));
}),
},
]
}

Loading…
Cancel
Save