The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Siarhei Vishniakou <svv@google.com>,
	 Peter Hutterer <peter.hutterer@who-t.net>
Cc: Jiri Kosina <jikos@kernel.org>,
	 Benjamin Tissoires <bentiss@kernel.org>,
	Ping Cheng <ping.cheng@wacom.com>,
	 Jason Gerecke <jason.gerecke@wacom.com>,
	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
Subject: Re: [PATCH v2 1/3] Input: add ABS_TWIST event code
Date: Wed, 25 Nov 2026 21:53:31 -0800	[thread overview]
Message-ID: <awfJCmpYAxF5uUfm@google.com> (raw)
In-Reply-To: <20261126024337.4168845-2-svv@google.com>

On Wed, Nov 25, 2026 at 06:43:35PM -0800, Siarhei Vishniakou wrote:
> 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, supporting either non-negative [0, maximum] or
> signed [minimum, maximum] full-revolution ranges, and resolution in
> units/radian.
> 
> Signed-off-by: Siarhei Vishniakou <svv@google.com>
> ---
> 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).

I'd like Peter (CCed) to take a look at this too...

> 
>  Documentation/input/event-codes.rst    | 23 +++++++++++++++++++++++
>  drivers/hid/hid-debug.c                |  1 +
>  include/uapi/linux/input-event-codes.h |  1 +
>  3 files changed, 25 insertions(+)
> 
> diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst
> index 77a6c9b3956d..4f03dcacbd55 100644
> --- a/Documentation/input/event-codes.rst
> +++ b/Documentation/input/event-codes.rst
> @@ -247,6 +247,29 @@ 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 range reported in struct input_absinfo may be either non-negative or
> +    signed. A non-negative range ([0, maximum]) covers [0, 360) degrees.
> +    A signed range ([minimum, maximum]) is centered at 0 and covers
> +    [-180, 180) degrees.
> +  - Unless the hardware only supports a restricted angular range, the
> +    [minimum, maximum] range spans one full revolution and wraps between
> +    maximum and minimum.
> +  - If the resolution is non-zero, the twist data is in units/radian. If the
> +    resolution is zero, userspace may assume the full [minimum, maximum] range
> +    represents one full revolution.
> +
>  * 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

-- 
Dmitry

  reply	other threads:[~2026-11-26  5:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  2:43 [PATCH v2 0/3] Input: add ABS_TWIST and support it in HID and Wacom Siarhei Vishniakou
2026-11-26  2:43 ` [PATCH v2 1/3] Input: add ABS_TWIST event code Siarhei Vishniakou
2026-11-26  5:53   ` Dmitry Torokhov [this message]
2026-11-26  2:43 ` [PATCH v2 2/3] HID: input: map Digitizers Twist usage to ABS_TWIST Siarhei Vishniakou
2026-11-26  2:43 ` [PATCH v2 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=awfJCmpYAxF5uUfm@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=corbet@lwn.net \
    --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 \
    --cc=svv@google.com \
    /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