aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzybet <53944559+Szybet@users.noreply.github.com>2025-09-30 17:08:03 +0200
committerIvan Molodetskikh <yalterz@gmail.com>2025-10-02 10:27:09 +0300
commit03c564736ae96de01de1aecd9e941ab112ea2af8 (patch)
tree81f8ca0e5605efc4711c32ce330f6789cac12912
parent1b41ef146d7ae73a6686aeb2454af5965976b271 (diff)
downloadniri-03c564736ae96de01de1aecd9e941ab112ea2af8.tar.gz
niri-03c564736ae96de01de1aecd9e941ab112ea2af8.tar.bz2
niri-03c564736ae96de01de1aecd9e941ab112ea2af8.zip
Support calibration-matrix in touch input config
-rw-r--r--docs/wiki/Configuration:-Input.md7
-rw-r--r--niri-config/src/input.rs2
-rw-r--r--niri-config/src/lib.rs1
-rw-r--r--src/input/mod.rs14
4 files changed, 22 insertions, 2 deletions
diff --git a/docs/wiki/Configuration:-Input.md b/docs/wiki/Configuration:-Input.md
index 7d7c0d55..81a52e7a 100644
--- a/docs/wiki/Configuration:-Input.md
+++ b/docs/wiki/Configuration:-Input.md
@@ -96,6 +96,7 @@ input {
touch {
// off
map-to-output "eDP-1"
+ // calibration-matrix 1.0 0.0 0.0 0.0 1.0 0.0
}
// disable-power-key-handling
@@ -256,9 +257,11 @@ Settings specific to `touchpad` and `mouse`:
<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`
-Settings specific to `tablet`s:
+Settings specific to `tablet` and `touch`:
-- `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.
+- `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.
+ - <sup>Since: 25.02</sup> for `tablet`
+ - <sup>Since: next release</sup> for `touch`
Tablets and touchscreens are absolute pointing devices that can be mapped to a specific output like so:
diff --git a/niri-config/src/input.rs b/niri-config/src/input.rs
index cf3df973..12af80ae 100644
--- a/niri-config/src/input.rs
+++ b/niri-config/src/input.rs
@@ -371,6 +371,8 @@ pub struct Tablet {
pub struct Touch {
#[knuffel(child)]
pub off: bool,
+ #[knuffel(child, unwrap(arguments))]
+ pub calibration_matrix: Option<Vec<f32>>,
#[knuffel(child, unwrap(argument))]
pub map_to_output: Option<String>,
}
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 81971cff..eb6d48b3 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -993,6 +993,7 @@ mod tests {
},
touch: Touch {
off: false,
+ calibration_matrix: None,
map_to_output: Some(
"eDP-1",
),
diff --git a/src/input/mod.rs b/src/input/mod.rs
index ddd24c4a..163c7748 100644
--- a/src/input/mod.rs
+++ b/src/input/mod.rs
@@ -4564,6 +4564,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
} else {
input::SendEventsMode::ENABLED
});
+
+ #[rustfmt::skip]
+ const IDENTITY_MATRIX: [f32; 6] = [
+ 1., 0., 0.,
+ 0., 1., 0.,
+ ];
+
+ let _ = device.config_calibration_set_matrix(
+ c.calibration_matrix
+ .as_deref()
+ .and_then(|m| m.try_into().ok())
+ .or(device.config_calibration_default_matrix())
+ .unwrap_or(IDENTITY_MATRIX),
+ );
}
}