[PATCH v2 0/3] Input: add ABS_TWIST and support it in HID and Wacom

From: Siarhei Vishniakou

Date: Wed Nov 25 2026 - 21:43:51 EST


Some styli can report rotation along their long ("barrel") axis,
commonly referred to as "twist". While the HID specification defines
this usage as HID_DG_TWIST (0x000d0041) in the Digitizers page, there is
currently no corresponding evdev axis code to expose it to userspace.

Because evdev has no MSC_SCAN equivalent for axes, drivers and OEMs
currently work around this by mapping stylus twist onto unrelated axes
such as ABS_Z or ABS_RZ. As a result, userspace input stacks must
maintain device-specific workarounds to know which axis carries twist.

This series introduces a dedicated ABS_TWIST (0x1d) axis for single-tool
devices such as styli and wires it up in the HID subsystem:

1. Input: Define ABS_TWIST (0x1d) in input-event-codes.h, add its name
to hid-debug.c, and document its semantics in event-codes.rst.
2. HID: Map HID_DG_TWIST (0x000d0041) to ABS_TWIST in hid-input, compute
its resolution in units/radian, and add KUnit test coverage.
3. HID: wacom: Report un-offset pen twist on ABS_TWIST (zero at top/-Y)
while keeping the shifted ABS_Z axis (zero at left/-X) for backwards
compatibility with existing applications.

v1: https://lore.kernel.org/linux-input/20261110020632.4003499-1-svv@xxxxxxxxxx/

Changes in v2:
- Rebased onto v7.4-rc4 (8d7fe9885c62, including hid-for-linus-2026112301).
- Patch 1 (Dmitry):
- Moved ABS_TWIST directly below ABS_SND_PROFILE in event-codes.rst.
- Expanded event-codes.rst with precise value semantics: clockwise
rotation when viewed down the barrel toward the surface, zero when
the neutral reference faces the top (-Y, north) of the surface,
support for both non-negative [0, 360) and signed [-180, 180)
full-revolution ranges with wraparound, units/radian resolution,
and the distinction from ABS_MT_ORIENTATION.
- Patch 2:
- No changes.
- Patch 3 (Jason):
- Added comments explaining the forced angular resolution_code in
wacom_map_usage(), the order-dependent double-mapping in
wacom_wac_pen_usage_mapping(), and explicit ABS_Z emission in
wacom_wac_pen_event().
- Emit un-offset twist (zero at top/-Y, matching ABS_TWIST
documentation and HID_DG_TWIST) on ABS_TWIST across all three pen
rotation paths, while preserving the +1/4 revolution offset (zero at
left/-X) on legacy ABS_Z.

Testing:
Hardware-tested with a Wacom Intuos Pro and Art Pen 2 (HID_GENERIC
path): verified ABS_TWIST reports 0 when the barrel button points to the
top (-Y) edge, increases clockwise when viewed from eraser toward tip,
tracks ABS_Z with a constant +450 (+90 deg) offset, resets cleanly to 0
on proximity exit, and exposes min -900, max 899, resolution 287.

Siarhei Vishniakou (3):
Input: add ABS_TWIST event code
HID: input: map Digitizers Twist usage to ABS_TWIST
HID: wacom: report ABS_TWIST alongside ABS_Z for pen twist

Documentation/input/event-codes.rst | 23 +++++++
drivers/hid/hid-debug.c | 1 +
drivers/hid/hid-input-test.c | 87 ++++++++++++++++++++++++
drivers/hid/hid-input.c | 5 ++
drivers/hid/wacom_wac.c | 94 ++++++++++++++++++++------
include/uapi/linux/input-event-codes.h | 1 +
6 files changed, 189 insertions(+), 22 deletions(-)

base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc

--
2.56.1.911.g883d8bcb20-goog