From: Siarhei Vishniakou <svv@google.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Ping Cheng <ping.cheng@wacom.com>,
Jason Gerecke <jason.gerecke@wacom.com>
Cc: Peter Hutterer <peter.hutterer@who-t.net>,
Jason Gerecke <killertofu@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Henrik Rydberg <rydberg@bitmath.org>,
linux-input@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Siarhei Vishniakou <svv@google.com>
Subject: [PATCH v3 1/3] Input: add ABS_TWIST event code
Date: Wed, 2 Dec 2026 18:10:03 -0800 [thread overview]
Message-ID: <20261203021005.1106826-2-svv@google.com> (raw)
In-Reply-To: <20261203021005.1106826-1-svv@google.com>
Some styli can report the rotation along their long ("barrel") axis.
This is typically referred to as "twist".
Unlike ABS_MT_ORIENTATION (which describes the 2D alignment of the
contact ellipse on the surface, analogous to stylus azimuth/tilt
projected onto the surface), twist captures the roll of a tool around
its own longitudinal axis independently of tilt or azimuth.
In the HID usage pages, twist is already supported as HID_DG_TWIST
(0x000d0041). However, this usage is not reported to userspace via the
evdev interface today, since there is no MSC_SCAN equivalent for axes.
Peripheral OEMs get around this today by mapping this axis to other axes
like ABS_Z or ABS_RZ. This is not a valid way to report twist.
As a result, userspace programs that would like to support twist must
account for the various ways specific OEMs map this, since there is no
generic axis for this.
Unify this behaviour by introducing a new axis, ABS_TWIST (0x1d). This
axis applies to single-pointer devices (such as styli), as opposed to
per-slot multi-touch devices (which would use an ABS_MT_* axis).
Document ABS_TWIST in event-codes.rst with its value semantics:
clockwise-increasing when viewed down the tool's major axis toward the
surface, 0 aligned toward the top (-Y, north) of the interaction surface
matching HID_DG_TWIST, non-negative or signed ranges (with optional
units/radian resolution for full-revolution devices and required
units/radian resolution for devices with a restricted angular range).
Signed-off-by: Siarhei Vishniakou <svv@google.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
---
Changes since v2:
- Clarified event-codes.rst on how to handle restricted angular ranges
(Jason), and noted that asymmetric ranges are acceptable.
- Updated commit message to match the clarified documentation.
- Kept Peter Hutterer's Acked-by from v2.
Changes since v1:
- Moved ABS_TWIST directly below ABS_SND_PROFILE in event-codes.rst
(Dmitry).
- Expanded event-codes.rst documentation with precise value semantics:
clockwise-increasing direction viewed down the barrel toward the
surface, 0 aligned toward the top (-Y, north) of the surface,
non-negative [0, 360) and signed [-180, 180) ranges, wraparound
behavior, and distinction from ABS_MT_ORIENTATION (Dmitry).
Documentation/input/event-codes.rst | 26 ++++++++++++++++++++++++++
drivers/hid/hid-debug.c | 1 +
include/uapi/linux/input-event-codes.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
index 77a6c9b3956d..478a38ca7c4b 100644
--- a/Documentation/input/event-codes.rst
+++ b/Documentation/input/event-codes.rst
@@ -247,6 +247,32 @@ A few EV_ABS codes have special meanings:
An event is emitted only when the selected profile changes,
indicating the newly selected profile value.
+* ABS_TWIST:
+
+ - Used to describe the rotation of a tool (such as a stylus) around its own
+ major (barrel) axis. Unlike ABS_MT_ORIENTATION (which describes the 2D
+ orientation of a contact ellipse on the surface), ABS_TWIST reports the
+ tool's roll around its longitudinal axis independently of tilt or azimuth.
+ - Values increase for clockwise rotation and decrease for counter-clockwise
+ rotation when viewed looking down the tool's major axis toward the
+ interaction surface (e.g., from the eraser end of a stylus toward the tip).
+ - A value of 0 corresponds to the tool's neutral reference orientation (e.g.,
+ its primary barrel button or flat edge) facing toward the top (-Y, north)
+ of the interaction surface.
+ - The [minimum, maximum] range in struct input_absinfo may be non-negative or
+ signed (symmetry around the neutral 0 position is not required). If
+ resolution is non-zero, it is specified in units/radian.
+ - For devices supporting a full revolution, the [minimum, maximum] range
+ spans one full revolution (typically covering [0, 360) degrees for
+ non-negative ranges or [-180, 180) degrees for signed ranges). Resolution
+ is optional: drivers should set it in units/radian when known, or leave it
+ as 0, in which case userspace may assume the full [minimum, maximum] range
+ represents one full revolution.
+ - For devices supporting only a restricted angular range, the
+ [minimum, maximum] range covers the supported subset of angles. Resolution
+ is required: drivers must set a non-zero resolution in units/radian so
+ userspace can convert reported values into physical angles.
+
* ABS_MT_<name>:
- Used to describe multitouch input events. Please see
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index f44e6e708404..2e9ff8a3b2cf 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -3518,6 +3518,7 @@ static const char *absolutes[ABS_CNT] = {
[ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure",
[ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt",
[ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "ToolWidth",
+ [ABS_TWIST] = "Twist",
[ABS_VOLUME] = "Volume", [ABS_PROFILE] = "Profile",
[ABS_SND_PROFILE] = "SoundProfile",
[ABS_MISC] = "Misc",
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 4217950e5d16..d4ed115fdeca 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -892,6 +892,7 @@
#define ABS_TILT_X 0x1a
#define ABS_TILT_Y 0x1b
#define ABS_TOOL_WIDTH 0x1c
+#define ABS_TWIST 0x1d
#define ABS_VOLUME 0x20
#define ABS_PROFILE 0x21
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 2:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 2:10 [PATCH v3 0/3] Input: add ABS_TWIST and support it in HID and Wacom Siarhei Vishniakou
2026-12-03 2:10 ` Siarhei Vishniakou [this message]
2026-12-03 2:10 ` [PATCH v3 2/3] HID: input: map Digitizers Twist usage to ABS_TWIST Siarhei Vishniakou
2026-12-03 2:10 ` [PATCH v3 3/3] HID: wacom: report ABS_TWIST alongside ABS_Z for pen twist Siarhei Vishniakou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203021005.1106826-2-svv@google.com \
--to=svv@google.com \
--cc=bentiss@kernel.org \
--cc=corbet@lwn.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jason.gerecke@wacom.com \
--cc=jikos@kernel.org \
--cc=killertofu@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=ping.cheng@wacom.com \
--cc=rdunlap@infradead.org \
--cc=rydberg@bitmath.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®