mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Add touchpad tap-button-map setting
This commit is contained in:
@@ -114,6 +114,8 @@ pub struct Touchpad {
|
||||
pub accel_speed: f64,
|
||||
#[knuffel(child, unwrap(argument, str))]
|
||||
pub accel_profile: Option<AccelProfile>,
|
||||
#[knuffel(child, unwrap(argument, str))]
|
||||
pub tap_button_map: Option<TapButtonMap>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -131,6 +133,21 @@ impl From<AccelProfile> for input::AccelProfile {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TapButtonMap {
|
||||
LeftRightMiddle,
|
||||
LeftMiddleRight,
|
||||
}
|
||||
|
||||
impl From<TapButtonMap> for input::TapButtonMap {
|
||||
fn from(value: TapButtonMap) -> Self {
|
||||
match value {
|
||||
TapButtonMap::LeftRightMiddle => Self::LeftRightMiddle,
|
||||
TapButtonMap::LeftMiddleRight => Self::LeftMiddleRight,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
|
||||
pub struct Tablet {
|
||||
#[knuffel(child, unwrap(argument))]
|
||||
@@ -605,6 +622,20 @@ impl FromStr for AccelProfile {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for TapButtonMap {
|
||||
type Err = miette::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"left-right-middle" => Ok(Self::LeftRightMiddle),
|
||||
"left-middle-right" => Ok(Self::LeftMiddleRight),
|
||||
_ => Err(miette!(
|
||||
r#"invalid tap button map, can be "left-right-middle" or "left-middle-right""#
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_miette_hook() -> Result<(), miette::InstallError> {
|
||||
miette::set_hook(Box::new(|_| Box::new(NarratableReportHandler::new())))
|
||||
}
|
||||
@@ -645,6 +676,7 @@ mod tests {
|
||||
dwt
|
||||
accel-speed 0.2
|
||||
accel-profile "flat"
|
||||
tap-button-map "left-middle-right"
|
||||
}
|
||||
|
||||
tablet {
|
||||
@@ -734,6 +766,7 @@ mod tests {
|
||||
natural_scroll: false,
|
||||
accel_speed: 0.2,
|
||||
accel_profile: Some(AccelProfile::Flat),
|
||||
tap_button_map: Some(TapButtonMap::LeftMiddleRight),
|
||||
},
|
||||
tablet: Tablet {
|
||||
map_to_output: Some("eDP-1".to_owned()),
|
||||
|
||||
@@ -31,6 +31,7 @@ input {
|
||||
natural-scroll
|
||||
// accel-speed 0.2
|
||||
// accel-profile "flat"
|
||||
// tap-button-map "left-middle-right"
|
||||
}
|
||||
|
||||
tablet {
|
||||
|
||||
@@ -101,6 +101,10 @@ impl State {
|
||||
if let Some(accel_profile) = c.accel_profile {
|
||||
let _ = device.config_accel_set_profile(accel_profile.into());
|
||||
}
|
||||
|
||||
if let Some(tap_button_map) = c.tap_button_map {
|
||||
let _ = device.config_tap_set_button_map(tap_button_map.into());
|
||||
}
|
||||
}
|
||||
|
||||
if device.has_capability(input::DeviceCapability::TabletTool) {
|
||||
|
||||
Reference in New Issue
Block a user