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 005944407039781d06efcd94bc2bd8bebc47a816..e24e2680695703d0d5af7ada1153518e188cc105 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;
@@ -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])
index 110ea745f8ecae818d284aeee3ee33a0b56e62d0..50ca713d706994b6dae6e83b9673d15d6bf261ed 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;
 
@@ -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]);
index d0324dd031ab94e938f097bf292123212719e98d..ccff35c58dadfa093de31f5a7e6c3e285bba7627 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],