Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263818; b=L1IDrMCypSwcxaec3gPOTQpdXVRBtk4X+6i0fuCpzh9M8/Fs7CAl9U91q6tcuMD9G3jU xBW79TvC6wdzP9UYf/zt5Ni70EEmwA7mnVU7aKgc6GT8yicIn+rR9hZbwFuPV8EhBLHA5 npD0IxN7YlpyPqhWZgcpbb/C/+yScNAsp4eF6YoqSRqnuJJKtNCh2vrFeC54enZyvpvar dwX7eZXH7kCCL7o/izR+MIVvy1hK3NE0G7HiCTkMBi6si+gS4xTMUVwmOPlGyogb3NtIn H6BEYoFhRjFfHrPD+Dcxsr5bPUuqDBcY3L923ph91IeWeOfC29mjRqMSD6pvpcCwPjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263818; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=KUKBHB4EinKSIVcdRv1xHfSniMpybKs0OQQpf80BCEE=; b=En8FGGI6xSVRvXKyAFXdgR4BHBbH4rJR+8ySJAAFOTHyqnZpPl+UbpzgVkhEpug250EW R701s4AD/6hzxILn1xYkCxMVInhNnEi2zxbTnIDr/eg4uerNV0vZCYfLEXV9CYVam7jCx sDQcWEgwZHpg/MhsrgRKOccSQZYh6D/uo/Ks7XQWSAf7SSJjjhvHpTPzVY4FqJTbE1MeT kGfi4NX8s3lExUjEFbFpv4I+2+ehCLxPZZsht3Mxe8sGAra4J/48YQDKiAwviePEQtN2I I+2t//4suL0nAWfsZ5TicatTZhtKGH/XoSfhIRAgscOig4ZHtKl7fV9t/oip164UG3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--svv.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=cIZ2Wqdh; arc=none smtp.remote-ip=74.125.82.70 Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B18BA606A322 for ; Thu, 3 Dec 2026 02:10:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B18BA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--svv.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=cIZ2Wqdh Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b587df8d13so209399c88.1 for ; Wed, 02 Dec 2026 18:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796263817; x=1796868617; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KUKBHB4EinKSIVcdRv1xHfSniMpybKs0OQQpf80BCEE=; b=cIZ2Wqdh8Nu2qcgu5p+p6zPJI8E8xcwbLtyoJmlsm6pv8xzsZFQcQRVm9vfAMl8yhi LUL+K1RQ/x/h92KRyUsEJOnaH+LwvPtTiMGF3+1Jb6bboCvYvmqfuGjboNchgr8JRjH7 EgF5/EEEAp1F6qFosTM/L93Y3QpoAALckj5qhj0BdnLxpaVj+3rjB4QfFUeewPz6kfmJ 2aD7ywQeqkCt7u46XbH+00XTN2Zu5JK0E7KMfJXeivcqkknqcbiQbO8GssKI1idbjgsD PUd0qx9FBhPc2Y07q/vFIe3pZA1MownuuJOS1u0pHS5Kjw7skiEbCElRQfsB0h+lOJeV rgVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796263817; x=1796868617; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KUKBHB4EinKSIVcdRv1xHfSniMpybKs0OQQpf80BCEE=; b=dsnedyt/PXOeruSPs6/rc1PYfClKc1PC4p4E9nvp3UvW9u/QVav95K/0sLANSPgeuU ccVpJF38LDI++ketEVR6U3K09mb+hosB3SyWuSD9KY3eHNO11NU3AicFRtln0CY9hKQy y508nNIJr3PbP9jKYWZIskITbfSRscr8lsvfNFKRpzaNBr3Xobwnx9S+vRVcOrSw7QkA 4FHAJLdHetA6VCUuisO/hoAjoiJ3UnOtvfZVBynRTcEJ2irjK7a7W2F0Ns/0TPBvL47B t5VNCtFlxkxyRkrH4xL6cHX1/zftes9+kBG8pWKgwr2RQtZUUcR6uhoU4R+/59vX1GAl wH/g== X-Forwarded-Encrypted: i=1; AL+hErFuJAjX2El1H3866NetdG4nKqtqDDO3u4oQ9DUqLewvJ7tpV94wmj2SEfrxcWdJiDgx7F2BRpVBneA=@vger.kernel.org X-Gm-Message-State: APuU4Z+sMm3grjfxbmNr2ft4h6SjZmPPvYrb1tPohc1YaRah6lYb3cEE VEMI1pegbIV8FMXxdt+ddxUKIzGUOoacDNdbmhNtdlZ3vxy/f/J+rAZzK2iCJDYoVoaP0w== X-Received: from dlbrj23.prod.google.com ([2002:a05:7022:f417:b0:18c:3061:3bca]) (user=svv job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:420b:20b0:1b2:5ecf:9bd1 with SMTP id a92af1059eb24-1b5ced721e3mr594800c88.7.1796263816593; Wed, 02 Dec 2026 18:10:16 -0800 (PST) Date: Wed, 2 Dec 2026 18:10:03 -0800 In-Reply-To: <20261203021005.1106826-1-svv@google.com> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261203021005.1106826-1-svv@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261203021005.1106826-2-svv@google.com> Subject: [PATCH v3 1/3] Input: add ABS_TWIST event code From: Siarhei Vishniakou To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires , Ping Cheng , Jason Gerecke Cc: Peter Hutterer , Jason Gerecke , Jonathan Corbet , Shuah Khan , Randy Dunlap , Henrik Rydberg , linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Siarhei Vishniakou Content-Type: text/plain; charset="UTF-8" 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 Acked-by: Peter Hutterer --- 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_: - 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