forge
Explore
Log in

Don't you dare go Hollow

Support for setting tablet calibration matrix

Browse files at this commit

9e794f358b7d44b4e04346dffbd684b2860d6fccUnverifiedIvan ChinenovParent: 4e17cbb
  • feat
    • support for setting tablet calibration matrix
    • this allows for rotating tablet inputs (#1122)
Show full message
feat: support for setting tablet calibration matrix; this allows for rotating tablet inputs (#1122)

* feat: support for setting tablet calibration matrix

* Change default matrix
niri-config/src/lib.rsmodified+6 -0
@@ -337,6 +337,8 @@ impl From<TapButtonMap> for input::TapButtonMap {
337337 pub struct Tablet {
338338 #[knuffel(child)]
339339 pub off: bool,
340+ #[knuffel(child, unwrap(arguments))]
341+ pub calibration_matrix: Option<Vec<f32>>,
340342 #[knuffel(child, unwrap(argument))]
341343 pub map_to_output: Option<String>,
342344 #[knuffel(child)]
@@ -3560,6 +3562,8 @@ mod tests {
35603562
35613563 tablet {
35623564 map-to-output "eDP-1"
3565+ calibration-matrix 1.0 2.0 3.0 \
3566+ 4.0 5.0 6.0
35633567 }
35643568
35653569 touch {
@@ -3804,6 +3808,8 @@ mod tests {
38043808 },
38053809 tablet: Tablet {
38063810 off: false,
3811+ calibration_matrix: Some(vec![1., 2., 3.,
3812+ 4., 5., 6.]),
38073813 map_to_output: Some("eDP-1".to_owned()),
38083814 left_handed: false,
38093815 },
src/input/mod.rsmodified+14 -0
@@ -3451,6 +3451,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
34513451 } else {
34523452 input::SendEventsMode::ENABLED
34533453 });
3454+
3455+ #[rustfmt::skip]
3456+ const IDENTITY_MATRIX: [f32; 6] = [
3457+ 1., 0., 0.,
3458+ 0., 1., 0.,
3459+ ];
3460+
3461+ let _ = device.config_calibration_set_matrix(
3462+ c.calibration_matrix
3463+ .as_deref()
3464+ .and_then(|m| m.try_into().ok())
3465+ .or(device.config_calibration_default_matrix())
3466+ .unwrap_or(IDENTITY_MATRIX),
3467+ );
34543468 let _ = device.config_left_handed_set(c.left_handed);
34553469 }
34563470 }