[PATCH libinput 1/2] tablet: rely on libwacom for the list of axis capabilities

Peter Hutterer peter.hutterer at who-t.net
Mon Mar 9 22:03:45 PDT 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac       |  2 +-
 src/evdev-tablet.c | 56 +++++++++++++++++++++++++-----------------------------
 2 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/configure.ac b/configure.ac
index 85db1fd..038022e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,7 +172,7 @@ AC_ARG_ENABLE(libwacom,
 	      [use_libwacom="$enableval"],
 	      [use_libwacom="yes"])
 if test "x$use_libwacom" = "xyes"; then
-	PKG_CHECK_MODULES(LIBWACOM, [libwacom], [HAVE_LIBWACOM="yes"])
+	PKG_CHECK_MODULES(LIBWACOM, [libwacom >= 0.12], [HAVE_LIBWACOM="yes"])
 	AC_DEFINE(HAVE_LIBWACOM, 1, [Build with libwacom])
 fi
 
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 3e3924c..c4b4154 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -592,6 +592,7 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
 	const WacomStylus *s = NULL;
 	int code;
 	WacomStylusType type;
+	WacomAxisTypeFlags axes;
 
 	db = libwacom_database_new();
 	if (!db) {
@@ -617,38 +618,33 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
 		copy_button_cap(tablet, tool, BTN_TOUCH);
 	}
 
-	/* Eventually we want libwacom to tell us each axis on each device
-	   separately. */
-	switch(type) {
-	case WSTYLUS_AIRBRUSH:
+	if (libwacom_stylus_has_wheel(s))
+		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_REL_WHEEL);
+
+	axes = libwacom_stylus_get_axes(s);
+
+	if (axes & WACOM_AXIS_TYPE_TILT) {
+		/* tilt on the puck is converted to rotation */
+		if (type == WSTYLUS_PUCK) {
+			set_bit(tool->axis_caps,
+				LIBINPUT_TABLET_AXIS_ROTATION_Z);
+		} else {
+			copy_axis_cap(tablet,
+				      tool,
+				      LIBINPUT_TABLET_AXIS_TILT_X);
+			copy_axis_cap(tablet,
+				      tool,
+				      LIBINPUT_TABLET_AXIS_TILT_Y);
+		}
+	}
+	if (axes & WACOM_AXIS_TYPE_ROTATION_Z)
+		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_ROTATION_Z);
+	if (axes & WACOM_AXIS_TYPE_DISTANCE)
+		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_DISTANCE);
+	if (axes & WACOM_AXIS_TYPE_SLIDER)
 		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_SLIDER);
-		/* fall-through */
-	case WSTYLUS_MARKER:
-		if (type == WSTYLUS_MARKER)
-			copy_axis_cap(tablet, tool,
-				      LIBINPUT_TABLET_AXIS_ROTATION_Z);
-		/* fallthrough */
-	case WSTYLUS_GENERAL:
-	case WSTYLUS_INKING:
-	case WSTYLUS_CLASSIC:
-	case WSTYLUS_STROKE:
+	if (axes & WACOM_AXIS_TYPE_PRESSURE)
 		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_PRESSURE);
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_DISTANCE);
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_TILT_X);
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_TILT_Y);
-		break;
-	case WSTYLUS_PUCK:
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_ROTATION_Z);
-		copy_axis_cap(tablet, tool, LIBINPUT_TABLET_AXIS_DISTANCE);
-		/* lens cursors don't have a wheel */
-		if (!libwacom_stylus_has_lens(s))
-			copy_axis_cap(tablet,
-				      tool,
-				      LIBINPUT_TABLET_AXIS_REL_WHEEL);
-		break;
-	default:
-		break;
-	}
 
 	rc = 0;
 out:
-- 
2.1.0



More information about the wayland-devel mailing list