ref: keep the list of required buttons with pedals

v0.2.1
rrr-marble 4 years ago
parent fac9b529e9
commit 436a916ce2

@ -40,7 +40,7 @@ fn main() -> () {
}
println!("{}", INPUT_DEVICE.name().unwrap_or("Unknown device"));
let mut drum_pedal: evdev::uinput::VirtualDevice = create_device().unwrap();
let mut drum_pedal: evdev::uinput::VirtualDevice = create_device(pedals::buttons()).unwrap();
run(
&INPUT_DEVICE,
@ -104,16 +104,14 @@ fn pick_device() -> evdev::Device {
use evdev::{uinput::VirtualDeviceBuilder, AttributeSet, Key};
/// Create new uinput device to send generated events into
/// Enables explicitly allowed here key press events to be generated
fn create_device() -> Result<evdev::uinput::VirtualDevice, Box<dyn std::error::Error>> {
fn create_device(
buttons: Vec<evdev::Key>,
) -> Result<evdev::uinput::VirtualDevice, Box<dyn std::error::Error>> {
let mut keys = AttributeSet::<Key>::new();
// Addtional buttons go here in `keys.insert(evdev::Key)` format
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);
for button in buttons {
keys.insert(button);
}
let device = VirtualDeviceBuilder::new()?
.name("DPK Wired Gaming Keyboard Combo")

@ -90,3 +90,15 @@ pub fn pedals() -> Vec<Pedal> {
},
]
}
pub fn buttons() -> Vec<evdev::Key> {
vec![
Key::KEY_F,
Key::KEY_SPACE,
Key::BTN_LEFT,
Key::KEY_T,
Key::KEY_Y,
Key::KEY_R,
Key::KEY_W,
]
}

Loading…
Cancel
Save