* [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
@ 2025-07-10 21:28 Ping Cheng
2025-08-12 12:35 ` Jiri Kosina
0 siblings, 1 reply; 5+ messages in thread
From: Ping Cheng @ 2025-07-10 21:28 UTC (permalink / raw)
To: linux-input; +Cc: jkosina, bentiss, Dmitry.Torokhov, stable, Ping Cheng
HID_GD_Z is mapped to ABS_Z for stylus and pen in hid-input.c. But HID_GD_Z
should be used to report ABS_DISTANCE for stylus and pen as described at:
Documentation/input/event-codes.rst#n226
* ABS_DISTANCE:
- Used to describe the distance of a tool from an interaction surface. This
event should only be emitted while the tool is hovering, meaning in close
proximity of the device and while the value of the BTN_TOUCH code is 0. If
the input device may be used freely in three dimensions, consider ABS_Z
instead.
- BTN_TOOL_<name> should be set to 1 when the tool comes into detectable
proximity and set to 0 when the tool leaves detectable proximity.
BTN_TOOL_<name> signals the type of tool that is currently detected by the
hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH.
This patch makes the correct mapping. The ABS_DISTANCE is currently not mapped
by any HID usage in hid-generic driver.
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
---
drivers/hid/hid-input.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index ff1784b5c2a4..240bc8a5f3bc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -858,8 +858,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
goto ignore;
switch (usage->hid) {
+ case HID_GD_Z:
+ /* HID_GD_Z is mapped to ABS_DISTANCE for stylus/pen */
+ if ((field->application & 0xff) == 0x02) {
+ if (field->flags & HID_MAIN_ITEM_RELATIVE)
+ map_rel(usage->hid & 0xf);
+ else
+ map_abs_clear(ABS_DISTANCE);
+ break;
+ }
+ /* fall through for other devices/tools */
/* These usage IDs map directly to the usage codes. */
- case HID_GD_X: case HID_GD_Y: case HID_GD_Z:
+ case HID_GD_X: case HID_GD_Y:
case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
if (field->flags & HID_MAIN_ITEM_RELATIVE)
map_rel(usage->hid & 0xf);
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
2025-07-10 21:28 [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen Ping Cheng
@ 2025-08-12 12:35 ` Jiri Kosina
2025-08-12 13:43 ` Cheng, Ping
0 siblings, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2025-08-12 12:35 UTC (permalink / raw)
To: Ping Cheng; +Cc: linux-input, bentiss, Dmitry.Torokhov, stable, Ping Cheng
Both applied to hid.git#for-6.18/core, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
2025-08-12 12:35 ` Jiri Kosina
@ 2025-08-12 13:43 ` Cheng, Ping
2025-08-12 15:14 ` Benjamin Tissoires
0 siblings, 1 reply; 5+ messages in thread
From: Cheng, Ping @ 2025-08-12 13:43 UTC (permalink / raw)
To: Jiri Kosina, Ping Cheng
Cc: linux-input@vger.kernel.org, bentiss@kernel.org,
Dmitry.Torokhov@gmail.com, stable@kernel.org
Hi Jiri,
Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...
Thank you for your effort. And sorry for the trouble.
Ping
________________________________________
From: Jiri Kosina <jikos@kernel.org>
Sent: Tuesday, August 12, 2025 5:35 AM
To: Ping Cheng <pinglinux@gmail.com>
Cc: linux-input@vger.kernel.org <linux-input@vger.kernel.org>; bentiss@kernel.org <bentiss@kernel.org>; Dmitry.Torokhov@gmail.com <Dmitry.Torokhov@gmail.com>; stable@kernel.org <stable@kernel.org>; Cheng, Ping <Ping.Cheng@wacom.com>
Subject: Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
Both applied to hid.git#for-6.18/core, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
2025-08-12 13:43 ` Cheng, Ping
@ 2025-08-12 15:14 ` Benjamin Tissoires
2025-08-12 15:31 ` Jiri Kosina
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Tissoires @ 2025-08-12 15:14 UTC (permalink / raw)
To: Cheng, Ping
Cc: Jiri Kosina, Ping Cheng, linux-input@vger.kernel.org,
Dmitry.Torokhov@gmail.com, stable@kernel.org
On Aug 12 2025, Cheng, Ping wrote:
> Hi Jiri,
>
> Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...
Furthermore:
CC drivers/hid/hid-input.o
drivers/hid/hid-input.c: In function 'hidinput_configure_usage':
drivers/hid/hid-input.c:863:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
863 | if ((field->application & 0xff) == 0x02) {
| ^
drivers/hid/hid-input.c:872:17: note: here
872 | case HID_GD_X: case HID_GD_Y:
| ^~~~
So this breaks compilation entirely :(
[Sorry I'm just back from vacations, and hadn't had the time to look at
the pile of emails]
Cheers,
Benjamin
>
> Thank you for your effort. And sorry for the trouble.
> Ping
>
> ________________________________________
> From: Jiri Kosina <jikos@kernel.org>
> Sent: Tuesday, August 12, 2025 5:35 AM
> To: Ping Cheng <pinglinux@gmail.com>
> Cc: linux-input@vger.kernel.org <linux-input@vger.kernel.org>; bentiss@kernel.org <bentiss@kernel.org>; Dmitry.Torokhov@gmail.com <Dmitry.Torokhov@gmail.com>; stable@kernel.org <stable@kernel.org>; Cheng, Ping <Ping.Cheng@wacom.com>
> Subject: Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
>
> Both applied to hid.git#for-6.18/core, thanks.
>
> --
> Jiri Kosina
> SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
2025-08-12 15:14 ` Benjamin Tissoires
@ 2025-08-12 15:31 ` Jiri Kosina
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Kosina @ 2025-08-12 15:31 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Cheng, Ping, Ping Cheng, linux-input@vger.kernel.org,
Dmitry.Torokhov@gmail.com, stable@kernel.org
On Tue, 12 Aug 2025, Benjamin Tissoires wrote:
> On Aug 12 2025, Cheng, Ping wrote:
> > Hi Jiri,
> >
> > Please revert this patchset since I need help from Benjamin to make the selftest real. Patch 2 does not do its job...
>
> Furthermore:
> CC drivers/hid/hid-input.o
> drivers/hid/hid-input.c: In function 'hidinput_configure_usage':
> drivers/hid/hid-input.c:863:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
> 863 | if ((field->application & 0xff) == 0x02) {
> | ^
> drivers/hid/hid-input.c:872:17: note: here
> 872 | case HID_GD_X: case HID_GD_Y:
> | ^~~~
>
> So this breaks compilation entirely :(
Hm, I really wonder how this escaped me, as I always run a compile+boot
battery before pushing out.
Sorry for the hassle, I'll investigate more where the glitch was on the
side of my automation.
Now dropped.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-12 15:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 21:28 [PATCH 1/2] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen Ping Cheng
2025-08-12 12:35 ` Jiri Kosina
2025-08-12 13:43 ` Cheng, Ping
2025-08-12 15:14 ` Benjamin Tissoires
2025-08-12 15:31 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox