From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263818; b=GCcU1Ux0SGq7pgXWCHXmDnKyQdBCGZpwsY4XnuM7/OiRoPkNOygyTye2MHma+phNjpKH btPOKnxnCLliksWW4N1wSHwF2E3WzYod1oo3B/9VHaQKSIq2hnPHcW15eGaOqybVYb/ks 9/AfOgf8JhI/eDXmyK8wJ9rUKOVjZnhQ8KRlOAQlMNur/hgUSrpGzSQSPT5T2NF1/k33L n4WexCaM6NQ1AvvCzDR0u6LFU7FAUGbhudMFCNEriZxZdd27VV/C3568Xa0WiWNR4fqpi 0LM1Djru4n2RndDM0P/hfHWNFRX4XHviSoON55h933lNhsYbASWb/Ec+bJIQ6e9pPKw== 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=xn/R4RSP4iFFadzAD9ixllfXrBZVPe/CT5jVSPX0TSLDlHYTZGY73Y99ELrLFQkQv3km bdSXK6tm6a566RiMYK1N9dDVRswAOVUFjEVtpcfeTirTYm0sINnsHR/vFmKobpRRiKiOO z/Hkr5BoUt8JiK7KG0+TVuv/ibZDS1oylDJuLqXeHhjlm8C1cQMuviuiTW4eIYWW7mJI8 cwTH4YOuEafFkFJSP84UAgKqdq2X/ADlhF7qOqDyZkHV/0xzaioWYIH73ENFsN1J3xXKc PGUz/lV5jUc/6GVuFiuT1rwZ/0ZA1NTS/+9HczHIiK98Jfga1ZTa3lHJxeI2JTOvUAQ== 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.69 Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) (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 B5A63606A335 for ; Thu, 3 Dec 2026 02:10:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5A63606A335 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-f69.google.com with SMTP id a92af1059eb24-1b3acec6613so92226c88.0 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=tN9yzTElAA+JVlZd1lsGmwEb1GXGHaWaLz5Ku6hXxQBglPP5cip1+cE2Uiyq52GFZp gCeSd5/7WeNXaVLW9Jll28GWLm6v6vYUBfPGL9+2c/onqJPh4MtPASGqII5UQ59BeauB 3vEs5IdeVx7Tc8rHw7IazNElj00O1f+IM1pTF5APcsW5wJzGQ7CsLXMBKYPf1h+dbW+y +MVVPd0y7LLcIDPF3Dr9iBKEu5Gl6lxoIggMvE2H/1ylJhaxEVbKPPqUlTZxWg3+G0Hd MVdtCi5X+PYHNJsQ9fyTBZpHIgAhX0gP+wNS+vBOsRacpGLWcnkL5ULMxq2cT5FKgI72 6pPA== X-Forwarded-Encrypted: i=1; AL+hErGgNm6GxNbU7Pfu6aBGx2Pm9MuEH/reMeS9kAUeyVe44/s4b7jfXTtq2PLtfm8BfCqXU1zO16F+sWt/gA==@vger.kernel.org X-Gm-Message-State: APuU4Z9kYHFg3yUYOC622ejD/GMfwbItw7l41bG93O4sCrJoCDVErD8C kxyueOCbQzDoYsci2nsAUgkmmC8Q5kW4ciyJ+6oM/KioMMAWrxqy64mJwFe6QNH8a1Yhqg== 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-input@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