diff options
| author | Viktor Pocedulic <kvik@a-b.xyz> | 2024-02-14 16:24:46 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-15 10:27:12 +0400 |
| commit | 363e1d876492a26a1b7d5261ac28aba94f323d08 (patch) | |
| tree | 9f2884ff4f5ea28215b53bc3c503260dec6e48b1 | |
| parent | 8e1d4de0dccdf14cb60d505cd0864a40e56a33d8 (diff) | |
| download | niri-363e1d876492a26a1b7d5261ac28aba94f323d08.tar.gz niri-363e1d876492a26a1b7d5261ac28aba94f323d08.tar.bz2 niri-363e1d876492a26a1b7d5261ac28aba94f323d08.zip | |
input: enable configuring of trackpoint devices
| -rw-r--r-- | niri-config/src/lib.rs | 23 | ||||
| -rw-r--r-- | resources/default-config.kdl | 6 | ||||
| -rw-r--r-- | src/input.rs | 12 | ||||
| -rw-r--r-- | src/niri.rs | 1 |
4 files changed, 42 insertions, 0 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 564b0b9f..fdf3d700 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -57,6 +57,8 @@ pub struct Input { #[knuffel(child, default)] pub mouse: Mouse, #[knuffel(child, default)] + pub trackpoint: Trackpoint, + #[knuffel(child, default)] pub tablet: Tablet, #[knuffel(child)] pub disable_power_key_handling: bool, @@ -151,6 +153,16 @@ pub struct Mouse { pub accel_profile: Option<AccelProfile>, } +#[derive(knuffel::Decode, Debug, Default, PartialEq)] +pub struct Trackpoint { + #[knuffel(child)] + pub natural_scroll: bool, + #[knuffel(child, unwrap(argument), default)] + pub accel_speed: f64, + #[knuffel(child, unwrap(argument, str))] + pub accel_profile: Option<AccelProfile>, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum AccelProfile { Adaptive, @@ -924,6 +936,12 @@ mod tests { accel-profile "flat" } + trackpoint { + natural-scroll + accel-speed 0.0 + accel-profile "flat" + } + tablet { map-to-output "eDP-1" } @@ -1043,6 +1061,11 @@ mod tests { accel_speed: 0.4, accel_profile: Some(AccelProfile::Flat), }, + trackpoint: Trackpoint { + natural_scroll: true, + accel_speed: 0.0, + accel_profile: Some(AccelProfile::Flat), + }, tablet: Tablet { map_to_output: Some("eDP-1".to_owned()), }, diff --git a/resources/default-config.kdl b/resources/default-config.kdl index 001d0be4..a95d9001 100644 --- a/resources/default-config.kdl +++ b/resources/default-config.kdl @@ -41,6 +41,12 @@ input { // accel-profile "flat" } + trackpoint { + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + } + tablet { // Set the name of the output (see below) which the tablet will map to. // If this is unset or the output doesn't exist, the tablet maps to one of the diff --git a/src/input.rs b/src/input.rs index d59b020f..080ed03d 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1622,6 +1622,18 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: let _ = device.config_accel_set_profile(default); } } + + if is_trackpoint { + let c = &config.trackpoint; + let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll); + let _ = device.config_accel_set_speed(c.accel_speed); + + if let Some(accel_profile) = c.accel_profile { + let _ = device.config_accel_set_profile(accel_profile.into()); + } else if let Some(default) = device.config_accel_default_profile() { + let _ = device.config_accel_set_profile(default); + } + } } #[cfg(test)] diff --git a/src/niri.rs b/src/niri.rs index ca9a7c47..97511b6e 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -628,6 +628,7 @@ impl State { if config.input.touchpad != old_config.input.touchpad || config.input.mouse != old_config.input.mouse + || config.input.trackpoint != old_config.input.trackpoint { libinput_config_changed = true; } |
