mirror of
https://github.com/k0kubun/xremap
synced 2024-11-02 03:40:25 +00:00
Set relative axes
This commit is contained in:
parent
06b2d04a89
commit
4b33dee052
@ -11,9 +11,10 @@ fn event_loop(input_device: &mut Device) -> Result<(), Box<dyn Error>> {
|
|||||||
if !select::is_readable(input_device) { continue }
|
if !select::is_readable(input_device) { continue }
|
||||||
|
|
||||||
for event in input_device.fetch_events().unwrap() {
|
for event in input_device.fetch_events().unwrap() {
|
||||||
if event.event_type() == EventType::KEY {
|
println!("event: {:?}", event);
|
||||||
println!("event: {:?}", event);
|
//if event.event_type() == EventType::KEY {
|
||||||
}
|
// println!("event: {:?}", event);
|
||||||
|
//}
|
||||||
output_device.emit(&[event]).unwrap();
|
output_device.emit(&[event]).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use evdev::{Device};
|
use evdev::{AttributeSet, Device, RelativeAxisType};
|
||||||
use evdev::uinput::{VirtualDevice, VirtualDeviceBuilder};
|
use evdev::uinput::{VirtualDevice, VirtualDeviceBuilder};
|
||||||
|
|
||||||
pub fn build_device(base_device: &Device) -> Result<VirtualDevice, Box<dyn Error>> {
|
pub fn build_device(base_device: &Device) -> Result<VirtualDevice, Box<dyn Error>> {
|
||||||
|
let mut rel_axes = AttributeSet::<RelativeAxisType>::new();
|
||||||
|
rel_axes.insert(evdev::RelativeAxisType::REL_X);
|
||||||
|
rel_axes.insert(evdev::RelativeAxisType::REL_Y);
|
||||||
|
rel_axes.insert(evdev::RelativeAxisType::REL_HWHEEL);
|
||||||
|
rel_axes.insert(evdev::RelativeAxisType::REL_WHEEL);
|
||||||
|
rel_axes.insert(evdev::RelativeAxisType::REL_MISC);
|
||||||
|
|
||||||
let device = VirtualDeviceBuilder::new()?
|
let device = VirtualDeviceBuilder::new()?
|
||||||
.name("xremap")
|
.name("xremap")
|
||||||
.with_keys(base_device.supported_keys().unwrap())?
|
.with_keys(base_device.supported_keys().unwrap())?
|
||||||
|
.with_relative_axes(&rel_axes)?
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Ok(device)
|
Ok(device)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user