[PATCH libinput] touchpad: always enable palm detection on apple touchpads

Peter Hutterer peter.hutterer at who-t.net
Sun Jul 20 23:31:37 PDT 2014


They don't set resolution so we can't calculate the size but we know they're
big enough to need palm detection.

And fix the descriptor for the bcm5974. For some reason this was advertising
synaptics coordinates. Fix it to represent (one of) the apple touchpads.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Should really be two separate patches, but the broken descriptors causes the
tests to break otherwise.

 src/evdev-mt-touchpad-buttons.c |  2 +-
 src/evdev-mt-touchpad.c         | 19 +++++++++++--------
 src/evdev-mt-touchpad.h         |  2 ++
 test/litest-bcm5974.c           | 19 ++++++++++++-------
 test/touchpad.c                 |  3 +++
 5 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index bd3c0e2..fe33d0b 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -521,7 +521,7 @@ tp_init_buttons(struct tp_dispatch *tp,
 
 	tp->buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD;
 
-	if (libevdev_get_id_vendor(device->evdev) == 0x5ac) /* Apple */
+	if (libevdev_get_id_vendor(device->evdev) == VENDOR_ID_APPLE)
 		tp->buttons.use_clickfinger = true;
 
 	if (tp->buttons.is_clickpad && !tp->buttons.use_clickfinger) {
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 5db204f..0755f2c 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -757,17 +757,20 @@ tp_init_palmdetect(struct tp_dispatch *tp,
 	tp->palm.right_edge = INT_MAX;
 	tp->palm.left_edge = INT_MIN;
 
-	/* We don't know how big the touchpad is */
-	if (device->abs.absinfo_x->resolution == 1)
-		return 0;
-
 	width = abs(device->abs.absinfo_x->maximum -
 		    device->abs.absinfo_x->minimum);
 
-	/* Enable palm detection on touchpads >= 80 mm. Anything smaller
-	   probably won't need it, until we find out it does */
-	if (width/device->abs.absinfo_x->resolution < 80)
-		return 0;
+	/* Apple touchpads are always big enough to warrant palm detection */
+	if (evdev_device_get_id_vendor(device) != VENDOR_ID_APPLE) {
+		/* We don't know how big the touchpad is */
+		if (device->abs.absinfo_x->resolution == 1)
+			return 0;
+
+		/* Enable palm detection on touchpads >= 80 mm. Anything smaller
+		   probably won't need it, until we find out it does */
+		if (width/device->abs.absinfo_x->resolution < 80)
+			return 0;
+	}
 
 	/* palm edges are 5% of the width on each side */
 	tp->palm.right_edge = device->abs.absinfo_x->maximum - width * 0.05;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 4779120..192c401 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -33,6 +33,8 @@
 #define TOUCHPAD_HISTORY_LENGTH 4
 #define TOUCHPAD_MIN_SAMPLES 4
 
+#define VENDOR_ID_APPLE 0x5ac
+
 enum touchpad_event {
 	TOUCHPAD_EVENT_NONE		= 0,
 	TOUCHPAD_EVENT_MOTION		= (1 << 0),
diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c
index 10a9eb4..c7bd857 100644
--- a/test/litest-bcm5974.c
+++ b/test/litest-bcm5974.c
@@ -65,13 +65,18 @@ static struct litest_device_interface interface = {
 };
 
 static struct input_absinfo absinfo[] = {
-	{ ABS_X, 1472, 5472, 0, 0, 75 },
-	{ ABS_Y, 1408, 4448, 0, 0, 129 },
-	{ ABS_PRESSURE, 0, 255, 0, 0, 0 },
-	{ ABS_TOOL_WIDTH, 0, 15, 0, 0, 0 },
-	{ ABS_MT_SLOT, 0, 1, 0, 0, 0 },
-	{ ABS_MT_POSITION_X, 1472, 5472, 0, 0, 75 },
-	{ ABS_MT_POSITION_Y, 1408, 4448, 0, 0, 129 },
+	{ ABS_X, -4824, 4824, 0, 0, 0 },
+	{ ABS_Y, -172, 4290, 0, 0, 0 },
+	{ ABS_PRESSURE, 0, 256, 5, 0, 0 },
+	{ ABS_TOOL_WIDTH, 0, 16, 0, 0, 0 },
+	{ ABS_MT_SLOT, 0, 15, 0, 0, 0 },
+	{ ABS_MT_POSITION_X, -4824, 4824, 17, 0, 0 },
+	{ ABS_MT_POSITION_Y, -172, 4290, 17, 0, 0 },
+	{ ABS_MT_ORIENTATION, -16384, 16384, 3276, 0, 0 },
+	{ ABS_MT_TOUCH_MAJOR, 0, 2048, 81, 0, 0 },
+	{ ABS_MT_TOUCH_MINOR, 0, 2048, 81, 0, 0 },
+	{ ABS_MT_WIDTH_MAJOR, 0, 2048, 81, 0, 0 },
+	{ ABS_MT_WIDTH_MINOR, 0, 2048, 81, 0, 0 },
 	{ ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
 	{ ABS_MT_PRESSURE, 0, 255, 0, 0, 0 },
 	{ .value = -1 },
diff --git a/test/touchpad.c b/test/touchpad.c
index 9b232bf..0de3cbb 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -1247,6 +1247,9 @@ touchpad_has_palm_detect_size(struct litest_device *dev)
 	double width, height;
 	int rc;
 
+	if (libinput_device_get_id_vendor(dev->libinput_device) == 0x5ac) /* Apple */
+		return 1;
+
 	rc = libinput_device_get_size(dev->libinput_device, &width, &height);
 
 	return rc == 0 && width >= 80;
-- 
1.9.3



More information about the wayland-devel mailing list