[PATCH libinput 2/7] evdev: move reading the calibration prop into a helper function

Peter Hutterer peter.hutterer at who-t.net
Mon Nov 28 05:20:45 UTC 2016


No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c     | 39 +++++++++++++++++++++++++++++++++++++++
 src/evdev.h     |  3 +++
 src/udev-seat.c | 26 +-------------------------
 3 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 6a34e37..620588d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2975,6 +2975,45 @@ evdev_device_calibrate(struct evdev_device *device,
 	matrix_mult(&device->abs.calibration, &transform, &scale);
 }
 
+void
+evdev_read_calibration_prop(struct evdev_device *device)
+{
+	const char *calibration_values;
+	float calibration[6];
+	int nread;
+
+	calibration_values =
+		udev_device_get_property_value(device->udev_device,
+					       "LIBINPUT_CALIBRATION_MATRIX");
+
+	if (calibration_values == NULL)
+		return;
+
+	if (!device->abs.absinfo_x || !device->abs.absinfo_y)
+		return;
+
+	nread = sscanf(calibration_values,
+		       "%f %f %f %f %f %f",
+		       &calibration[0],
+		       &calibration[1],
+		       &calibration[2],
+		       &calibration[3],
+		       &calibration[4],
+		       &calibration[5]);
+	if (nread != 6)
+		return;
+
+	evdev_device_set_default_calibration(device, calibration);
+	log_info(evdev_libinput_context(device),
+		 "Applying calibration: %f %f %f %f %f %f\n",
+		 calibration[0],
+		 calibration[1],
+		 calibration[2],
+		 calibration[3],
+		 calibration[4],
+		 calibration[5]);
+}
+
 bool
 evdev_device_has_capability(struct evdev_device *device,
 			    enum libinput_device_capability capability)
diff --git a/src/evdev.h b/src/evdev.h
index 0888600..3ad385e 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -338,6 +338,9 @@ evdev_init_calibration(struct evdev_device *device,
 		        struct libinput_device_config_calibration *calibration);
 
 void
+evdev_read_calibration_prop(struct evdev_device *device);
+
+void
 evdev_device_init_pointer_acceleration(struct evdev_device *device,
 				       struct motion_filter *filter);
 
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 6bf85de..cdeb7fd 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -51,8 +51,6 @@ device_added(struct udev_device *udev_device,
 	struct evdev_device *device;
 	const char *devnode;
 	const char *device_seat, *output_name;
-	const char *calibration_values;
-	float calibration[6];
 	struct udev_seat *seat;
 
 	device_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
@@ -94,29 +92,7 @@ device_added(struct udev_device *udev_device,
 		return 0;
 	}
 
-	calibration_values =
-		udev_device_get_property_value(udev_device,
-					       "LIBINPUT_CALIBRATION_MATRIX");
-
-	if (device->abs.absinfo_x && device->abs.absinfo_y &&
-	    calibration_values && sscanf(calibration_values,
-					 "%f %f %f %f %f %f",
-					 &calibration[0],
-					 &calibration[1],
-					 &calibration[2],
-					 &calibration[3],
-					 &calibration[4],
-					 &calibration[5]) == 6) {
-		evdev_device_set_default_calibration(device, calibration);
-		log_info(&input->base,
-			 "Applying calibration: %f %f %f %f %f %f\n",
-			 calibration[0],
-			 calibration[1],
-			 calibration[2],
-			 calibration[3],
-			 calibration[4],
-			 calibration[5]);
-	}
+	evdev_read_calibration_prop(device);
 
 	output_name = udev_device_get_property_value(udev_device, "WL_OUTPUT");
 	if (output_name)
-- 
2.9.3



More information about the wayland-devel mailing list