mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Implement input configuration for trackballs (#743)
* niri-config: add trackball configuration struct The available options are mostly the same as for mice. I've verified that each option is applicable to trackballs in the libinput CLI. * input: apply trackball config settings
This commit is contained in:
@@ -70,6 +70,8 @@ pub struct Input {
|
|||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub trackpoint: Trackpoint,
|
pub trackpoint: Trackpoint,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
|
pub trackball: Trackball,
|
||||||
|
#[knuffel(child, default)]
|
||||||
pub tablet: Tablet,
|
pub tablet: Tablet,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub touch: Touch,
|
pub touch: Touch,
|
||||||
@@ -218,6 +220,22 @@ pub struct Trackpoint {
|
|||||||
pub middle_emulation: bool,
|
pub middle_emulation: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
|
||||||
|
pub struct Trackball {
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub off: bool,
|
||||||
|
#[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>,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub left_handed: bool,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub middle_emulation: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum ClickMethod {
|
pub enum ClickMethod {
|
||||||
Clickfinger,
|
Clickfinger,
|
||||||
@@ -2904,6 +2922,15 @@ mod tests {
|
|||||||
scroll-method "on-button-down"
|
scroll-method "on-button-down"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackball {
|
||||||
|
off
|
||||||
|
natural-scroll
|
||||||
|
accel-speed 0.0
|
||||||
|
accel-profile "flat"
|
||||||
|
left-handed
|
||||||
|
middle-emulation
|
||||||
|
}
|
||||||
|
|
||||||
tablet {
|
tablet {
|
||||||
map-to-output "eDP-1"
|
map-to-output "eDP-1"
|
||||||
}
|
}
|
||||||
@@ -3091,6 +3118,14 @@ mod tests {
|
|||||||
scroll_method: Some(ScrollMethod::OnButtonDown),
|
scroll_method: Some(ScrollMethod::OnButtonDown),
|
||||||
middle_emulation: false,
|
middle_emulation: false,
|
||||||
},
|
},
|
||||||
|
trackball: Trackball {
|
||||||
|
off: true,
|
||||||
|
natural_scroll: true,
|
||||||
|
accel_speed: 0.0,
|
||||||
|
accel_profile: Some(AccelProfile::Flat),
|
||||||
|
left_handed: true,
|
||||||
|
middle_emulation: true,
|
||||||
|
},
|
||||||
tablet: Tablet {
|
tablet: Tablet {
|
||||||
off: false,
|
off: false,
|
||||||
map_to_output: Some("eDP-1".to_owned()),
|
map_to_output: Some("eDP-1".to_owned()),
|
||||||
|
|||||||
@@ -2718,6 +2718,25 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if is_trackball {
|
||||||
|
let c = &config.trackball;
|
||||||
|
let _ = device.config_send_events_set_mode(if c.off {
|
||||||
|
input::SendEventsMode::DISABLED
|
||||||
|
} else {
|
||||||
|
input::SendEventsMode::ENABLED
|
||||||
|
});
|
||||||
|
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
|
||||||
|
let _ = device.config_accel_set_speed(c.accel_speed);
|
||||||
|
let _ = device.config_middle_emulation_set_enabled(c.middle_emulation);
|
||||||
|
let _ = device.config_left_handed_set(c.left_handed);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if is_trackpoint {
|
if is_trackpoint {
|
||||||
let c = &config.trackpoint;
|
let c = &config.trackpoint;
|
||||||
let _ = device.config_send_events_set_mode(if c.off {
|
let _ = device.config_send_events_set_mode(if c.off {
|
||||||
|
|||||||
Reference in New Issue
Block a user