[PATCH libinput 2/3] Implement support for pen barrel rotation

Jason Gerecke killertofu at gmail.com
Mon Dec 8 09:59:06 PST 2014


Some Wacom tablets can report the rotation of the pen about its barrel
in the ABS_Z axis. Report this via LIBINPUT_TABLET_AXIS_TWIST.

Signed-off-by: Jason Gerecke <killertofu at gmail.com>
Acked-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-tablet.c | 6 ++++++
 src/evdev-tablet.h | 6 ++++++
 src/libinput.c     | 1 +
 src/libinput.h     | 5 ++++-
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index b924800..a7101da 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -47,6 +47,7 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
 	switch (e->code) {
 	case ABS_X:
 	case ABS_Y:
+	case ABS_Z:
 	case ABS_PRESSURE:
 	case ABS_TILT_X:
 	case ABS_TILT_Y:
@@ -147,6 +148,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
 			break;
 		case LIBINPUT_TABLET_AXIS_TILT_X:
 		case LIBINPUT_TABLET_AXIS_TILT_Y:
+		case LIBINPUT_TABLET_AXIS_TWIST:
 			tablet->axes[a] = normalize_double_ended(absinfo);
 			break;
 		default:
@@ -332,6 +334,10 @@ tablet_get_tool(struct tablet_dispatch *tablet,
 				       LIBINPUT_TABLET_AXIS_TILT_Y))
 				set_bit(tool->axis_caps,
 					LIBINPUT_TABLET_AXIS_TILT_Y);
+			if (bit_is_set(tablet->axis_caps,
+				       LIBINPUT_TABLET_AXIS_TWIST))
+				set_bit(tool->axis_caps,
+					LIBINPUT_TABLET_AXIS_TWIST);
 			break;
 		default:
 			break;
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index cb37577..73c178d 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -72,6 +72,9 @@ evcode_to_axis(const uint32_t evcode)
 	case ABS_Y:
 		axis = LIBINPUT_TABLET_AXIS_Y;
 		break;
+	case ABS_Z:
+		axis = LIBINPUT_TABLET_AXIS_TWIST;
+		break;
 	case ABS_DISTANCE:
 		axis = LIBINPUT_TABLET_AXIS_DISTANCE;
 		break;
@@ -116,6 +119,9 @@ axis_to_evcode(const enum libinput_tablet_axis axis)
 	case LIBINPUT_TABLET_AXIS_TILT_Y:
 		evcode = ABS_TILT_Y;
 		break;
+	case LIBINPUT_TABLET_AXIS_TWIST:
+		evcode = ABS_Z;
+		break;
 	default:
 		abort();
 	}
diff --git a/src/libinput.c b/src/libinput.c
index d6c1685..64b0f95 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -532,6 +532,7 @@ libinput_event_tablet_get_axis_value(struct libinput_event_tablet *event,
 		case LIBINPUT_TABLET_AXIS_PRESSURE:
 		case LIBINPUT_TABLET_AXIS_TILT_X:
 		case LIBINPUT_TABLET_AXIS_TILT_Y:
+		case LIBINPUT_TABLET_AXIS_TWIST:
 			return event->axes[axis];
 		default:
 			return 0;
diff --git a/src/libinput.h b/src/libinput.h
index 78bb9ef..03df3bb 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -277,7 +277,8 @@ enum libinput_tablet_axis {
 	LIBINPUT_TABLET_AXIS_PRESSURE = 3,
 	LIBINPUT_TABLET_AXIS_TILT_X = 4,
 	LIBINPUT_TABLET_AXIS_TILT_Y = 5,
-	LIBINPUT_TABLET_AXIS_CNT = LIBINPUT_TABLET_AXIS_TILT_Y + 1
+	LIBINPUT_TABLET_AXIS_TWIST = 6,
+	LIBINPUT_TABLET_AXIS_CNT = LIBINPUT_TABLET_AXIS_TWIST + 1
 };
 
 /**
@@ -1022,6 +1023,8 @@ libinput_event_tablet_axis_has_changed(struct libinput_event_tablet *event,
  * - @ref LIBINPUT_TABLET_AXIS_TILT_X and @ref LIBINPUT_TABLET_AXIS_TILT_Y -
  *   normalized value between -1 and 1 that indicates the X or Y tilt of the
  *   tool
+ * - @ref LIBINPUT_TABLET_AXIS_TWIST - normalized value between -1 and 1
+ *   that indicates the rotation of the tool about its long axis
  *
  * @param event The libinput tablet event
  * @param axis The axis to retrieve the value of
-- 
2.1.3



More information about the wayland-devel mailing list