forge
Explore
Log in

Don't you dare go Hollow

input: enable configuring of trackpoint devices

Browse files at this commit

363e1d876492a26a1b7d5261ac28aba94f323d08Viktor PocedulicParent: 8e1d4de
niri-config/src/lib.rsmodified+23 -0
@@ -57,6 +57,8 @@ pub struct Input {
57 #[knuffel(child, default)]57 #[knuffel(child, default)]
58 pub mouse: Mouse,58 pub mouse: Mouse,
59 #[knuffel(child, default)]59 #[knuffel(child, default)]
60+ pub trackpoint: Trackpoint,
61+ #[knuffel(child, default)]
60 pub tablet: Tablet,62 pub tablet: Tablet,
61 #[knuffel(child)]63 #[knuffel(child)]
62 pub disable_power_key_handling: bool,64 pub disable_power_key_handling: bool,
@@ -151,6 +153,16 @@ pub struct Mouse {
151 pub accel_profile: Option<AccelProfile>,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 #[derive(Debug, Clone, Copy, PartialEq, Eq)]166 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
155 pub enum AccelProfile {167 pub enum AccelProfile {
156 Adaptive,168 Adaptive,
@@ -924,6 +936,12 @@ mod tests {
924 accel-profile "flat"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 tablet {945 tablet {
928 map-to-output "eDP-1"946 map-to-output "eDP-1"
929 }947 }
@@ -1043,6 +1061,11 @@ mod tests {
1043 accel_speed: 0.4,1061 accel_speed: 0.4,
1044 accel_profile: Some(AccelProfile::Flat),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 tablet: Tablet {1069 tablet: Tablet {
1047 map_to_output: Some("eDP-1".to_owned()),1070 map_to_output: Some("eDP-1".to_owned()),
1048 },1071 },
resources/default-config.kdlmodified+6 -0
@@ -41,6 +41,12 @@ input {
41 // accel-profile "flat"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 tablet {50 tablet {
45 // Set the name of the output (see below) which the tablet will map to.51 // Set the name of the output (see below) which the tablet will map to.
46 // If this is unset or the output doesn't exist, the tablet maps to one of the52 // 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 let _ = device.config_accel_set_profile(default);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 #[cfg(test)]1639 #[cfg(test)]
src/niri.rsmodified+1 -0
@@ -628,6 +628,7 @@ impl State {
628 628
629 if config.input.touchpad != old_config.input.touchpad629 if config.input.touchpad != old_config.input.touchpad
630 || config.input.mouse != old_config.input.mouse630 || config.input.mouse != old_config.input.mouse
631+ || config.input.trackpoint != old_config.input.trackpoint
631 {632 {
632 libinput_config_changed = true;633 libinput_config_changed = true;
633 }634 }