Support calibration-matrix in touch input config
Browse files at this commit03c564736ae96de01de1aecd9e941ab112ea2af8Parent: 1b41ef14 changed files +22 -2
- docs/wiki/Configuration:-Input.md +5 -2
- niri-config/src/input.rs +2 -0
- niri-config/src/lib.rs +1 -0
- src/input/mod.rs +14 -0
docs/wiki/Configuration:-Input.mdmodified+5 -2
| @@ -96,6 +96,7 @@ input { | |||
| 96 | touch { | 96 | touch { |
| 97 | // off | 97 | // off |
| 98 | map-to-output "eDP-1" | 98 | map-to-output "eDP-1" |
| 99 | + // calibration-matrix 1.0 0.0 0.0 0.0 1.0 0.0 | ||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | // disable-power-key-handling | 102 | // disable-power-key-handling |
| @@ -256,9 +257,11 @@ Settings specific to `touchpad` and `mouse`: | |||
| 256 | 257 | ||
| 257 | <sup>Since: 25.08</sup> You can also override horizontal and vertical scroll factor separately like so: `scroll-factor horizontal=2.0 vertical=-1.0` | 258 | <sup>Since: 25.08</sup> You can also override horizontal and vertical scroll factor separately like so: `scroll-factor horizontal=2.0 vertical=-1.0` |
| 258 | 259 | ||
| 259 | -Settings specific to `tablet`s: | 260 | +Settings specific to `tablet` and `touch`: |
| 260 | 261 | ||
| 261 | -- `calibration-matrix`: <sup>Since: 25.02</sup> set to six floating point numbers to change the calibration matrix. See the [`LIBINPUT_CALIBRATION_MATRIX` documentation](https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html) for examples. | 262 | +- `calibration-matrix`: set to six floating point numbers to change the calibration matrix. See the [`LIBINPUT_CALIBRATION_MATRIX` documentation](https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html) for examples. |
| 263 | + - <sup>Since: 25.02</sup> for `tablet` | ||
| 264 | + - <sup>Since: next release</sup> for `touch` | ||
| 262 | 265 | ||
| 263 | Tablets and touchscreens are absolute pointing devices that can be mapped to a specific output like so: | 266 | Tablets and touchscreens are absolute pointing devices that can be mapped to a specific output like so: |
| 264 | 267 | ||
niri-config/src/input.rsmodified+2 -0
| @@ -371,6 +371,8 @@ pub struct Tablet { | |||
| 371 | pub struct Touch { | 371 | pub struct Touch { |
| 372 | #[knuffel(child)] | 372 | #[knuffel(child)] |
| 373 | pub off: bool, | 373 | pub off: bool, |
| 374 | + #[knuffel(child, unwrap(arguments))] | ||
| 375 | + pub calibration_matrix: Option<Vec<f32>>, | ||
| 374 | #[knuffel(child, unwrap(argument))] | 376 | #[knuffel(child, unwrap(argument))] |
| 375 | pub map_to_output: Option<String>, | 377 | pub map_to_output: Option<String>, |
| 376 | } | 378 | } |
niri-config/src/lib.rsmodified+1 -0
| @@ -993,6 +993,7 @@ mod tests { | |||
| 993 | }, | 993 | }, |
| 994 | touch: Touch { | 994 | touch: Touch { |
| 995 | off: false, | 995 | off: false, |
| 996 | + calibration_matrix: None, | ||
| 996 | map_to_output: Some( | 997 | map_to_output: Some( |
| 997 | "eDP-1", | 998 | "eDP-1", |
| 998 | ), | 999 | ), |
src/input/mod.rsmodified+14 -0
| @@ -4564,6 +4564,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: | |||
| 4564 | } else { | 4564 | } else { |
| 4565 | input::SendEventsMode::ENABLED | 4565 | input::SendEventsMode::ENABLED |
| 4566 | }); | 4566 | }); |
| 4567 | + | ||
| 4568 | + #[rustfmt::skip] | ||
| 4569 | + const IDENTITY_MATRIX: [f32; 6] = [ | ||
| 4570 | + 1., 0., 0., | ||
| 4571 | + 0., 1., 0., | ||
| 4572 | + ]; | ||
| 4573 | + | ||
| 4574 | + let _ = device.config_calibration_set_matrix( | ||
| 4575 | + c.calibration_matrix | ||
| 4576 | + .as_deref() | ||
| 4577 | + .and_then(|m| m.try_into().ok()) | ||
| 4578 | + .or(device.config_calibration_default_matrix()) | ||
| 4579 | + .unwrap_or(IDENTITY_MATRIX), | ||
| 4580 | + ); | ||
| 4567 | } | 4581 | } |
| 4568 | } | 4582 | } |
| 4569 | 4583 | ||