[PATCH weston 13/25] libinput: move calibration printing into do_set_calibration()

Pekka Paalanen ppaalanen at gmail.com
Fri Mar 23 12:00:53 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move calibration printing here and call do_set_calibration() from
evdev_device_set_calibration() so that all matrix setting paths print
the same way.

Print the matrix values in a matrix style to help readability, and
mention the input device.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/libinput-device.c | 51 +++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
index cb0bafe8..742cb5c9 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -344,10 +344,17 @@ do_set_calibration(struct evdev_device *evdev_device,
 {
 	enum libinput_config_status status;
 
+	weston_log("input device %s: applying calibration:\n",
+		   libinput_device_get_sysname(evdev_device->device));
+	weston_log_continue(STAMP_SPACE "  %f %f %f\n",
+			    calb->m[0], calb->m[1], calb->m[2]);
+	weston_log_continue(STAMP_SPACE "  %f %f %f\n",
+			    calb->m[3], calb->m[4], calb->m[5]);
+
 	status = libinput_device_config_calibration_set_matrix(evdev_device->device,
 							       calb->m);
 	if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-		weston_log("Failed to apply calibration.\n");
+		weston_log("Error: Failed to apply calibration.\n");
 }
 
 static void
@@ -557,8 +564,7 @@ evdev_device_set_calibration(struct evdev_device *device)
 	const char *sysname = libinput_device_get_sysname(device->device);
 	const char *calibration_values;
 	uint32_t width, height;
-	float calibration[6];
-	enum libinput_config_status status;
+	struct weston_touch_device_matrix calibration;
 
 	if (!libinput_device_config_calibration_has_matrix(device->device))
 		return;
@@ -568,7 +574,7 @@ evdev_device_set_calibration(struct evdev_device *device)
 	 * output to load a calibration. */
 	if (libinput_device_config_calibration_get_default_matrix(
 							  device->device,
-							  calibration) != 0)
+							  calibration.m) != 0)
 		return;
 
 	/* touch_set_calibration() has updated the values, do not load old
@@ -612,35 +618,26 @@ evdev_device_set_calibration(struct evdev_device *device)
 
 	if (!calibration_values || sscanf(calibration_values,
 					  "%f %f %f %f %f %f",
-					  &calibration[0],
-					  &calibration[1],
-					  &calibration[2],
-					  &calibration[3],
-					  &calibration[4],
-					  &calibration[5]) != 6)
+					  &calibration.m[0],
+					  &calibration.m[1],
+					  &calibration.m[2],
+					  &calibration.m[3],
+					  &calibration.m[4],
+					  &calibration.m[5]) != 6)
 		goto out;
 
-	weston_log("Applying calibration: %f %f %f %f %f %f "
-		   "(normalized %f %f)\n",
-		    calibration[0],
-		    calibration[1],
-		    calibration[2],
-		    calibration[3],
-		    calibration[4],
-		    calibration[5],
-		    calibration[2] / width,
-		    calibration[5] / height);
-
 	/* normalize to a format libinput can use. There is a chance of
 	   this being wrong if the width/height don't match the device
 	   width/height but I'm not sure how to fix that */
-	calibration[2] /= width;
-	calibration[5] /= height;
+	calibration.m[2] /= width;
+	calibration.m[5] /= height;
 
-	status = libinput_device_config_calibration_set_matrix(device->device,
-							       calibration);
-	if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-		weston_log("Failed to apply calibration.\n");
+	do_set_calibration(device, &calibration);
+
+	weston_log_continue(STAMP_SPACE "  raw translation %f %f for output %s\n",
+		   calibration.m[2] * width,
+		   calibration.m[5] * height,
+		   device->output->name);
 
 out:
 	if (udev_device)
-- 
2.16.1



More information about the wayland-devel mailing list