add: output device creation

v0.1.1
rrr-marble 5 years ago
parent 73edc2da4f
commit 6f2caab6dd

@ -11,6 +11,10 @@ fn main() -> () {
let d = pick_device();
d
};
static ref OUTPUT_DEVICE: evdev::uinput::VirtualDevice = {
let d = create_device().unwrap();
d
};
}
println!("{}", INPUT_DEVICE.name().unwrap_or("Unknown device"));
@ -54,6 +58,20 @@ fn pick_device() -> evdev::Device {
}
}
use evdev::{uinput::VirtualDeviceBuilder, AttributeSet, Key};
fn create_device() -> Result<evdev::uinput::VirtualDevice, Box<dyn std::error::Error>> {
let mut keys = AttributeSet::<Key>::new();
keys.insert(Key::KEY_F);
let device = VirtualDeviceBuilder::new()?
.name("DPK Wired Gaming Keyboard Combo")
.with_keys(&keys)?
.build()
.unwrap();
Ok(device)
}
pub struct Pedal {
key: evdev::Key,
action: Box<dyn Fn() -> () + Send + 'static>,

Loading…
Cancel
Save