From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263815; b=5ibPVI/jDZlLiS4qXlG80U7xqQtOlCSfiFfsqxYVnnWXWYxDuTdn8xqG8M2QiJsJeKrD 3hjX3N7cG+36Laaa5JMu+/jxkU5IHmIjPcN0LRMH7NG9yOD1qa2gYZg8fnXTI8ZrtcTvi 5KCAWmOENR1yz+IZTUU4aEtyh8yEehU02BCUJvdmVHsXmKri9Yu+nBQD5LBPYeB00Z5+l hlaGiC0oJSkkbpAzItNabC0B8TWn6V+HvF1isgsxLJzKFluCB51h2mVBifs8R6SjIhM5l LZhU1IufySTm0dVcgFP2eWmPPqX9dhdEQqQan4bv2fSFnAUo3jtAQLdjWq4ysa3McfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263815; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=i/CFWqEykz4bbekqMJ3FrwuzmWVsUCaRzUqUQuZusdo=; b=ZXAPjkIKhpIJPm4FSlzNocQXF9QhO3HNIu1xvVbxr/R3A4ciBsjIVea0TSVH7IQ+Y6hK PsLvM86TPzZKB3BUwxohSa4Aq67bL39uku5et5OK41g551zo7auAtQ57BpU156XFaNYVg +5L4Km4azPF3M9acJcbw5WkU0/FkqzFuhlpwMjTzAJk/NOzxWQS+fPtqFWn9jCSbMoykj P81bWu214+dXsGzj8FTePBldtovExNxeYCxu6jchdz03wdRj1n16pKA90HOpD8g9qDU1j 6UriPJZ2DRm2okrtTmz6DOZoGd3VjBZgfvkRoi0IZAPcV6jYp2s7tUwEFNQXR50MzIg== 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="BOD/gbnt"; arc=none smtp.remote-ip=74.125.82.71 Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) (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 7903E606A32C for ; Thu, 3 Dec 2026 02:10:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7903E606A32C 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=BOD/gbnt Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-1383723dfddso2088461c88.0 for ; Wed, 02 Dec 2026 18:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796263814; x=1796868614; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=i/CFWqEykz4bbekqMJ3FrwuzmWVsUCaRzUqUQuZusdo=; b=BOD/gbntOUIVBLQyScQc7wR83615Y2D6E2ZdpKt/PG9IkO+xdDZ41CC+VJd2mRe7Eh yAQeJo7z9jxebqFy4n6lCgkEg4P3D6UZ4pzKdCgTZIc0GfH7bPekzaU1zmJZWMp7K80R uYCpz2SHlBIPAO+Ce4Gnxoka6bakqLawvRQwYbBFrZ8PI5GalUw6RJ/1ulmSNwoNfPjA oMMAtsraxWInSOYj8nHUm2i7ebumNZ3ycr2EK41JteFbGM6tD4CdtsRR9yxhHsAQXaAb vqTOifGEuYNkxOwxe3ny3N9Iz6J9G0rsinMsqc9Q/SxiFfdYFwRUhWnrrsCcK78On2DO R6ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796263814; x=1796868614; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=i/CFWqEykz4bbekqMJ3FrwuzmWVsUCaRzUqUQuZusdo=; b=jJF0AunmhrNRWhDb89bI2p/P1o6HmelLP2LKrtBSvAGEEIaIXGJOXFTYs1ZOiteyBd 84fQAyLRVxhgWV1PIVOAmX6qT0jU4j+BnBjZM42NNp241t8gCFHh4DfI4j0c3Z9+E9FK DQG9haAeQNUG9ZmbYuBWn3VYAczuiuh9t1gf7SuoVTJRG9Bz1F04tdxN9jjDTVS1m1Rb tXNS6sDrnK7x/Ln9OvZf5IWybDm8oFUEp3cMVMdq2lYmDTYsvaYExbtga1L3cH34Q9YR 3eJj9AyUQjAB76u6DFdFYjBnnq9s2OXsHG9mcXHlO0hIYsS049BM5SzaGdwtIK8CfFxv q90Q== X-Forwarded-Encrypted: i=1; AL+hErHCZJTpyCvuY73edeRUfepQan/wAB1N+7YW2C+JUI7cq8zB3n0W8SuSHbaCSIDZolHxhbqi6k43kjUpSw==@vger.kernel.org X-Gm-Message-State: APuU4Z9bngbFwLpD5xglfcGT7nPTT547FZNiXnfJFY5Ye9x/Tj84X8GX T3KglLTgw9hHtAE8v+yW1euUdg5jGscdCnbggHQQCvYNdOYBrLu/NayxjMMzRNBmh1WW4A== X-Received: from dlxx13.prod.google.com ([2002:a05:7022:408d:b0:1b2:4b00:1331]) (user=svv job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:4555:20b0:1b5:2988:eba7 with SMTP id a92af1059eb24-1b556947286mr42507328c88.41.1796263813311; Wed, 02 Dec 2026 18:10:13 -0800 (PST) Date: Wed, 2 Dec 2026 18:10:02 -0800 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 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261203021005.1106826-1-svv@google.com> Subject: [PATCH v3 0/3] Input: add ABS_TWIST and support it in HID and Wacom 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 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. v2: https://lore.kernel.org/linux-input/20261126024337.4168845-1-svv@google.com/ v1: https://lore.kernel.org/linux-input/20261110020632.4003499-1-svv@google.com/ Changes in v3: - Patch 1 (Jason, Peter): - Clarified docs on how to properly handle restricted angular ranges. Also explained that asymmetric ranges are acceptable. - Patch 2: - No changes. - Patch 3: - No changes. 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. Note for Input/HID maintainers: Patch 1 has Peter's Acked-by and Patch 3 has Jason's Reviewed-by. Patch 2 still needs HID review, and please let me know how you prefer to merge this cross-subsystem series (e.g., all patches via the HID tree with Dmitry's Ack on Patch 1, or Patch 1 via an Input immutable branch). 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 | 26 +++++++ 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, 192 insertions(+), 22 deletions(-) base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc -- 2.56.1.911.g883d8bcb20-goog