input: enable configuring of trackpoint devices
Browse files at this commit363e1d876492a26a1b7d5261ac28aba94f323d08Parent: 8e1d4de4 changed files +42 -0
- niri-config/src/lib.rs +23 -0
- resources/default-config.kdl +6 -0
- src/input.rs +12 -0
- src/niri.rs +1 -0
niri-config/src/lib.rsmodified+23 -0
| @@ -57,6 +57,8 @@ pub struct Input { | ||
| 57 | 57 | #[knuffel(child, default)] |
| 58 | 58 | pub mouse: Mouse, |
| 59 | 59 | #[knuffel(child, default)] |
| 60 | + pub trackpoint: Trackpoint, | |
| 61 | + #[knuffel(child, default)] | |
| 60 | 62 | pub tablet: Tablet, |
| 61 | 63 | #[knuffel(child)] |
| 62 | 64 | pub disable_power_key_handling: bool, |
| @@ -151,6 +153,16 @@ pub struct Mouse { | ||
| 151 | 153 | pub accel_profile: Option<AccelProfile>, |
| 152 | 154 | } |
| 153 | 155 | |
| 156 | +#[derive(knuffel::Decode, Debug, Default, PartialEq)] | |
| 157 | +pub struct Trackpoint { | |
| 158 | + #[knuffel(child)] | |
| 159 | + pub natural_scroll: bool, | |
| 160 | + #[knuffel(child, unwrap(argument), default)] | |
| 161 | + pub accel_speed: f64, | |
| 162 | + #[knuffel(child, unwrap(argument, str))] | |
| 163 | + pub accel_profile: Option<AccelProfile>, | |
| 164 | +} | |
| 165 | + | |
| 154 | 166 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 155 | 167 | pub enum AccelProfile { |
| 156 | 168 | Adaptive, |
| @@ -924,6 +936,12 @@ mod tests { | ||
| 924 | 936 | accel-profile "flat" |
| 925 | 937 | } |
| 926 | 938 | |
| 939 | + trackpoint { | |
| 940 | + natural-scroll | |
| 941 | + accel-speed 0.0 | |
| 942 | + accel-profile "flat" | |
| 943 | + } | |
| 944 | + | |
| 927 | 945 | tablet { |
| 928 | 946 | map-to-output "eDP-1" |
| 929 | 947 | } |
| @@ -1043,6 +1061,11 @@ mod tests { | ||
| 1043 | 1061 | accel_speed: 0.4, |
| 1044 | 1062 | accel_profile: Some(AccelProfile::Flat), |
| 1045 | 1063 | }, |
| 1064 | + trackpoint: Trackpoint { | |
| 1065 | + natural_scroll: true, | |
| 1066 | + accel_speed: 0.0, | |
| 1067 | + accel_profile: Some(AccelProfile::Flat), | |
| 1068 | + }, | |
| 1046 | 1069 | tablet: Tablet { |
| 1047 | 1070 | map_to_output: Some("eDP-1".to_owned()), |
| 1048 | 1071 | }, |
resources/default-config.kdlmodified+6 -0
| @@ -41,6 +41,12 @@ input { | ||
| 41 | 41 | // accel-profile "flat" |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + trackpoint { | |
| 45 | + // natural-scroll | |
| 46 | + // accel-speed 0.2 | |
| 47 | + // accel-profile "flat" | |
| 48 | + } | |
| 49 | + | |
| 44 | 50 | tablet { |
| 45 | 51 | // Set the name of the output (see below) which the tablet will map to. |
| 46 | 52 | // If this is unset or the output doesn't exist, the tablet maps to one of the |
src/input.rsmodified+12 -0
| @@ -1622,6 +1622,18 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: | ||
| 1622 | 1622 | let _ = device.config_accel_set_profile(default); |
| 1623 | 1623 | } |
| 1624 | 1624 | } |
| 1625 | + | |
| 1626 | + if is_trackpoint { | |
| 1627 | + let c = &config.trackpoint; | |
| 1628 | + let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll); | |
| 1629 | + let _ = device.config_accel_set_speed(c.accel_speed); | |
| 1630 | + | |
| 1631 | + if let Some(accel_profile) = c.accel_profile { | |
| 1632 | + let _ = device.config_accel_set_profile(accel_profile.into()); | |
| 1633 | + } else if let Some(default) = device.config_accel_default_profile() { | |
| 1634 | + let _ = device.config_accel_set_profile(default); | |
| 1635 | + } | |
| 1636 | + } | |
| 1625 | 1637 | } |
| 1626 | 1638 | |
| 1627 | 1639 | #[cfg(test)] |
src/niri.rsmodified+1 -0
| @@ -628,6 +628,7 @@ impl State { | ||
| 628 | 628 | |
| 629 | 629 | if config.input.touchpad != old_config.input.touchpad |
| 630 | 630 | || config.input.mouse != old_config.input.mouse |
| 631 | + || config.input.trackpoint != old_config.input.trackpoint | |
| 631 | 632 | { |
| 632 | 633 | libinput_config_changed = true; |
| 633 | 634 | } |