input: add click method and middle button emulation
This commit is contained in:
parent
0524e01a3c
commit
b20153550e
24 changed files with 598 additions and 21 deletions
|
|
@ -22,7 +22,7 @@ use {
|
|||
ahash::AHashMap,
|
||||
jay_config::{
|
||||
Axis, Direction, Workspace,
|
||||
input::{SwitchEvent, acceleration::AccelProfile},
|
||||
input::{SwitchEvent, acceleration::AccelProfile, clickmethod::ClickMethod},
|
||||
keyboard::{Keymap, ModifiedKeySym, mods::Modifiers, syms::KeySym},
|
||||
logging::LogLevel,
|
||||
status::MessageFormat,
|
||||
|
|
@ -362,6 +362,8 @@ pub struct Input {
|
|||
pub tap_drag_lock_enabled: Option<bool>,
|
||||
pub left_handed: Option<bool>,
|
||||
pub natural_scrolling: Option<bool>,
|
||||
pub click_method: Option<ClickMethod>,
|
||||
pub middle_button_emulation: Option<bool>,
|
||||
pub px_per_wheel_scroll: Option<f64>,
|
||||
pub transform_matrix: Option<[[f64; 2]; 2]>,
|
||||
pub keymap: Option<ConfigKeymap>,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -546,6 +546,12 @@ impl Input {
|
|||
if let Some(v) = self.calibration_matrix {
|
||||
c.set_calibration_matrix(v);
|
||||
}
|
||||
if let Some(v) = self.click_method {
|
||||
c.set_click_method(v);
|
||||
}
|
||||
if let Some(v) = self.middle_button_emulation {
|
||||
c.set_middle_button_emulation_enabled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue