[PATCH libinput 3/4] trackpoint: drop handling of CONST_ACCEL and undo SENSITIVITY

Peter Hutterer peter.hutterer at who-t.net
Wed Jul 12 06:06:17 UTC 2017


This was to counteract hardware that doesn't work well out of the box,
resulting in quite different behavior across devices. Specifically, only
some trackpoints even have the sensitivity setting.

Change to take over all of the pointer acceleration on trackpoints, so we can
control the actual behavior mostly independent of the system setting. So we
drop the CONST_ACCEL parsing (which never was handled as const accel anyway)
and undo the effect that the SENSITIVITY udev property has. [1]

We take a default range at the default sensitivity and multiply it by the
proportion of the current sensitivity. This seems to be accurate enough.

[1] In the future, we should read not only the property but also the sysfs file to
make sure we're handling the right value, but for now this will do.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c         | 46 +++++++++++++++++++++-------------------------
 src/libinput-util.h |  2 ++
 2 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index e07d5f7e..991b12db 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2208,32 +2208,32 @@ evdev_read_wheel_tilt_props(struct evdev_device *device)
 }
 
 static inline int
-evdev_get_trackpoint_dpi(struct evdev_device *device)
+evdev_get_trackpoint_range(struct evdev_device *device)
 {
-	const char *trackpoint_accel;
-	double accel = DEFAULT_TRACKPOINT_ACCEL;
+	const char *prop;
+	int range = DEFAULT_TRACKPOINT_RANGE;
 
-	/*
-	 * parse the sensitivity property, and undo whatever it does.
-	 */
+	if (!(device->tags & EVDEV_TAG_TRACKPOINT))
+		return DEFAULT_TRACKPOINT_RANGE;
 
-	trackpoint_accel = udev_device_get_property_value(
-				device->udev_device, "POINTINGSTICK_CONST_ACCEL");
-	if (trackpoint_accel) {
-		accel = parse_trackpoint_accel_property(trackpoint_accel);
-		if (accel == 0.0) {
+	prop = udev_device_get_property_value(device->udev_device,
+					      "POINTINGSTICK_SENSITIVITY");
+	if (prop) {
+		int sensitivity;
+
+		if (!safe_atoi(prop, &sensitivity) ||
+		    (sensitivity < 0.0 || sensitivity > 255)) {
 			evdev_log_error(device,
-					"trackpoint accel property is present but invalid, "
-					"using %.2f instead\n",
-					DEFAULT_TRACKPOINT_ACCEL);
-			accel = DEFAULT_TRACKPOINT_ACCEL;
+					"trackpoint sensitivity property is present but invalid, "
+					"using %d instead\n",
+					DEFAULT_TRACKPOINT_SENSITIVITY);
+			sensitivity = DEFAULT_TRACKPOINT_SENSITIVITY;
 		}
-		evdev_log_info(device, "set to const accel %.2f\n", accel);
+		range = 1.0 * DEFAULT_TRACKPOINT_RANGE *
+			sensitivity/DEFAULT_TRACKPOINT_SENSITIVITY;
 	}
 
-	device->trackpoint_range = 20; /* FIXME */
-
-	return DEFAULT_MOUSE_DPI / accel;
+	return range;
 }
 
 static inline int
@@ -2242,13 +2242,8 @@ evdev_read_dpi_prop(struct evdev_device *device)
 	const char *mouse_dpi;
 	int dpi = DEFAULT_MOUSE_DPI;
 
-	/*
-	 * Trackpoints do not have dpi, instead hwdb may contain a
-	 * POINTINGSTICK_CONST_ACCEL value to compensate for sensitivity
-	 * differences between models, we translate this to a fake dpi.
-	 */
 	if (device->tags & EVDEV_TAG_TRACKPOINT)
-		return evdev_get_trackpoint_dpi(device);
+		return DEFAULT_MOUSE_DPI;
 
 	mouse_dpi = udev_device_get_property_value(device->udev_device,
 						   "MOUSE_DPI");
@@ -2666,6 +2661,7 @@ evdev_configure_device(struct evdev_device *device)
 		evdev_tag_external_mouse(device, device->udev_device);
 		evdev_tag_trackpoint(device, device->udev_device);
 		device->dpi = evdev_read_dpi_prop(device);
+		device->trackpoint_range = evdev_get_trackpoint_range(device);
 
 		device->seat_caps |= EVDEV_DEVICE_POINTER;
 
diff --git a/src/libinput-util.h b/src/libinput-util.h
index 26f0b632..212e9080 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -53,6 +53,8 @@
 
 /* The HW DPI rate we normalize to before calculating pointer acceleration */
 #define DEFAULT_MOUSE_DPI 1000
+#define DEFAULT_TRACKPOINT_RANGE 20
+#define DEFAULT_TRACKPOINT_SENSITIVITY 128
 
 #define ANSI_HIGHLIGHT		"\x1B[0;1;39m"
 #define ANSI_RED		"\x1B[0;31m"
-- 
2.13.0



More information about the wayland-devel mailing list