From d5136c6cb9fbefa14f1e41685a658f2fa029d163 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 26 Aug 2014 13:44:03 +1000 Subject: [PATCH] evdev: load the LIBINPUT_CALIBRATION_MATRIX as default matrix Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev.c | 19 ++++++++++++------- src/evdev.h | 4 ++++ src/udev-seat.c | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 00594440..e24e2680 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -612,15 +612,11 @@ static int evdev_calibration_get_default_matrix(struct libinput_device *libinput_device, float matrix[6]) { - struct matrix m; + struct evdev_device *device = (struct evdev_device*)libinput_device; - /* Always return the identity matrix for now. In the future, this - should return the WL_CALIBRATION matrix defined as default - matrix for this device */ - matrix_init_identity(&m); - matrix_to_farray6(&m, matrix); + matrix_to_farray6(&device->abs.default_calibration, matrix); - return !matrix_is_identity(&m); + return !matrix_is_identity(&device->abs.default_calibration); } struct evdev_dispatch_interface fallback_interface = { @@ -956,6 +952,7 @@ evdev_device_create(struct libinput_seat *seat, matrix_init_identity(&device->abs.calibration); matrix_init_identity(&device->abs.usermatrix); + matrix_init_identity(&device->abs.default_calibration); if (evdev_configure_device(device) == -1) goto err; @@ -1026,6 +1023,14 @@ evdev_device_get_id_vendor(struct evdev_device *device) return libevdev_get_id_vendor(device->evdev); } +void +evdev_device_set_default_calibration(struct evdev_device *device, + const float calibration[6]) +{ + matrix_from_farray6(&device->abs.default_calibration, calibration); + evdev_device_calibrate(device, calibration); +} + void evdev_device_calibrate(struct evdev_device *device, const float calibration[6]) diff --git a/src/evdev.h b/src/evdev.h index 110ea745..50ca713d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -74,6 +74,7 @@ struct evdev_device { int apply_calibration; struct matrix calibration; + struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */ struct matrix usermatrix; /* as supplied by the caller */ } abs; @@ -160,6 +161,9 @@ evdev_device_get_id_product(struct evdev_device *device); unsigned int evdev_device_get_id_vendor(struct evdev_device *device); +void +evdev_device_set_default_calibration(struct evdev_device *device, + const float calibration[6]); void evdev_device_calibrate(struct evdev_device *device, const float calibration[6]); diff --git a/src/udev-seat.c b/src/udev-seat.c index d0324dd0..ccff35c5 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -100,7 +100,7 @@ device_added(struct udev_device *udev_device, struct udev_input *input) &calibration[3], &calibration[4], &calibration[5]) == 6) { - evdev_device_calibrate(device, calibration); + evdev_device_set_default_calibration(device, calibration); log_info(&input->base, "Applying calibration: %f %f %f %f %f %f\n", calibration[0], -- 2.34.1