1
0
Fork 0
forked from wry/wry

input: add click method and middle button emulation

This commit is contained in:
Stipe Kotarac 2025-05-12 17:52:36 +02:00 committed by Julian Orth
parent 0524e01a3c
commit b20153550e
24 changed files with 598 additions and 21 deletions

View file

@ -22,6 +22,7 @@ use {
jay_config::input::{
SwitchEvent,
acceleration::{ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT},
clickmethod::{CLICK_METHOD_BUTTON_AREAS, CLICK_METHOD_CLICKFINGER, CLICK_METHOD_NONE},
},
thiserror::Error,
};
@ -87,7 +88,9 @@ impl Parser for InputParser<'_> {
output_val,
remove_mapping,
calibration_matrix,
click_method,
),
(middle_button_emulation,),
) = ext.extract((
(
opt(str("tag")),
@ -111,7 +114,9 @@ impl Parser for InputParser<'_> {
opt(val("output")),
recover(opt(bol("remove-mapping"))),
recover(opt(val("calibration-matrix"))),
recover(opt(str("click-method"))),
),
(recover(opt(bol("middle-button-emulation"))),),
))?;
let accel_profile = match accel_profile {
None => None,
@ -124,6 +129,18 @@ impl Parser for InputParser<'_> {
}
},
};
let click_method = match click_method {
None => None,
Some(p) => match p.value.to_ascii_lowercase().as_str() {
"none" => Some(CLICK_METHOD_NONE),
"button-areas" => Some(CLICK_METHOD_BUTTON_AREAS),
"clickfinger" => Some(CLICK_METHOD_CLICKFINGER),
v => {
log::warn!("Unknown click-method {v}: {}", self.cx.error3(p.span));
None
}
},
};
let transform_matrix = match transform_matrix {
None => None,
Some(matrix) => match matrix.parse(&mut TransformMatrixParser) {
@ -242,6 +259,8 @@ impl Parser for InputParser<'_> {
tap_drag_lock_enabled: tap_drag_lock_enabled.despan(),
left_handed: left_handed.despan(),
natural_scrolling: natural_scrolling.despan(),
middle_button_emulation: middle_button_emulation.despan(),
click_method,
px_per_wheel_scroll: px_per_wheel_scroll.despan(),
transform_matrix,
keymap,