[PATCH libinput 4/8] tablet: force the pressure/distance to 0 depending on contact state

Peter Hutterer peter.hutterer at who-t.net
Tue Dec 1 17:46:28 PST 2015


If we have pressure but not BTN_TOUCH, force the pressure to 0. Otherwise,
force distance to 0.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-tablet.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 395cbef..e9473e8 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -846,22 +846,34 @@ tablet_notify_buttons(struct tablet_dispatch *tablet,
 static void
 sanitize_tablet_axes(struct tablet_dispatch *tablet)
 {
+	bool tool_in_contact;
 	const struct input_absinfo *distance,
 	                           *pressure;
 
 	distance = libevdev_get_abs_info(tablet->device->evdev, ABS_DISTANCE);
 	pressure = libevdev_get_abs_info(tablet->device->evdev, ABS_PRESSURE);
 
+	tool_in_contact = (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT) ||
+			   tablet_has_status(tablet,
+					     TABLET_TOOL_ENTERING_CONTACT));
+
 	/* Keep distance and pressure mutually exclusive */
 	if ((bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE) ||
 	     bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) &&
 	    distance->value > distance->minimum &&
 	    pressure->value > pressure->minimum) {
-		clear_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
-		tablet->axes[LIBINPUT_TABLET_TOOL_AXIS_DISTANCE] = 0;
+		if (tool_in_contact) {
+			clear_bit(tablet->changed_axes,
+				  LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
+			tablet->axes[LIBINPUT_TABLET_TOOL_AXIS_DISTANCE] =
+			0;
+		} else {
+			clear_bit(tablet->changed_axes,
+				  LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
+			tablet->axes[LIBINPUT_TABLET_TOOL_AXIS_PRESSURE] = 0;
+		}
 	} else if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE) &&
-		   (!tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT) &&
-		    !tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT))) {
+		   !tool_in_contact) {
 		/* Make sure that the last axis value sent to the caller is a 0 */
 		if (tablet->axes[LIBINPUT_TABLET_TOOL_AXIS_PRESSURE] == 0)
 			clear_bit(tablet->changed_axes,
-- 
2.5.0



More information about the wayland-devel mailing list