evdev: load the LIBINPUT_CALIBRATION_MATRIX as default matrix
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 26 Aug 2014 03:44:03 +0000 (13:44 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 1 Sep 2014 01:23:54 +0000 (11:23 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev.c
src/evdev.h
src/udev-seat.c

index 0059444..e24e268 100644 (file)
@@ -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;
@@ -1027,6 +1024,14 @@ evdev_device_get_id_vendor(struct evdev_device *device)
 }
 
 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])
 {
index 110ea74..50ca713 100644 (file)
@@ -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;
 
@@ -161,6 +162,9 @@ 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]);
 
index d0324dd..ccff35c 100644 (file)
@@ -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],