From 06b2d04a896624b1c3cfa4414525a18b7e1b2ea2 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 13 Dec 2021 21:55:22 -0800 Subject: [PATCH] Simulate supported keys --- src/main.rs | 2 +- src/output.rs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index cb1c853..899e58f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ mod select; mod output; fn event_loop(input_device: &mut Device) -> Result<(), Box> { - let mut output_device = output::build_device().unwrap(); + let mut output_device = output::build_device(input_device).unwrap(); for _ in 0..5 { if !select::is_readable(input_device) { continue } diff --git a/src/output.rs b/src/output.rs index 94592fe..0171156 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,14 +1,11 @@ use std::error::Error; -use evdev::{AttributeSet, Key}; +use evdev::{Device}; use evdev::uinput::{VirtualDevice, VirtualDeviceBuilder}; -pub fn build_device() -> Result> { - let mut keys = AttributeSet::::new(); - keys.insert(Key::KEY_A); - +pub fn build_device(base_device: &Device) -> Result> { let device = VirtualDeviceBuilder::new()? .name("xremap") - .with_keys(&keys)? + .with_keys(base_device.supported_keys().unwrap())? .build() .unwrap();