linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Illia Ostapyshyn <ostapyshyn@sra.uni-hannover.de>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	David Revoy <davidrevoy@protonmail.com>
Cc: jkosina@suse.cz, jason.gerecke@wacom.com,
	jose.exposito89@gmail.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, nils@nilsfuhler.de,
	peter.hutterer@who-t.net, ping.cheng@wacom.com,
	bagasdotme@gmail.com
Subject: Re: Requesting your attention and expertise regarding a Tablet/Kernel issue
Date: Mon, 6 Nov 2023 21:06:36 +0100	[thread overview]
Message-ID: <eb8e22f3-77dc-4923-a7ba-e237ee226edb@sra.uni-hannover.de> (raw)
In-Reply-To: <CAO-hwJLpKTb9yxvxaPDLZkF9kDF8u2VRJUf9yiQd+neOyxPeug@mail.gmail.com>

On 11/6/23 17:59, Benjamin Tissoires wrote:

> If the pen has 2 buttons, and an eraser side, it would be a serious
> design flow for XPPEN to report both as eraser.
> 
> Could you please use sudo hid-recorder from hid-tools[1] on any kernel
> version and send us the logs here?
> I'll be able to replay the events locally, and understand why the
> kernel doesn't work properly.
> 
> And if there is a design flaw that can be fixed, we might even be able
> to use hid-bpf to change it :)

My wild guess is that XP-Pen 16 Artist Pro reports an Eraser usage 
without Invert for the upper button and Eraser with Invert for the 
eraser tip.  A device-specific driver could work with that, but there 
seems to be no way to incorporate two different erasers (thus, allowing 
userspace to map them to different actions arbitrarily) in the generic 
driver currently.

> Generally speaking, relying on X to fix your hardware is going to be a
> dead end. When you switch to wayland, you'll lose all of your fixes,
> which isn't great.

> AFAIU, the kernel now "merges" both buttons, which is a problem. It
> seems to be a serious regression. This case is also worrying because I
> added regression tests on hid, but I don't have access to all of the
> various tablets, so I implemented them from the Microsoft
> specification[0]. We need a special case for you here.

The issue preventing David from mapping HID_DG_ERASER to BTN_STYLUS2 is 
that the hidinput_hid_event is not compatible with hidinput_setkeycode. 
If usage->code is no longer BTN_TOUCH after remapping, it won't be 
released when Eraser reports 0.  A simple fix is:

--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1589,7 +1589,7 @@ void hidinput_hid_event(struct hid_device *hid, 
struct hid_field *field, struct
  			/* value is off, tool is not rubber, ignore */
  			return;
  		else if (*quirks & HID_QUIRK_NOINVERT &&
-			 !test_bit(BTN_TOUCH, input->key)) {
+			 !test_bit(usage->code, input->key)) {
  			/*
  			 * There is no invert to release the tool, let hid_input
  			 * send BTN_TOUCH with scancode and release the tool after.

This change alone fixes David's problem and the right-click mapping in 
hwdb works again.  However, the tool switches to rubber for the remapped 
eraser (here BTN_STYLUS2) events, both for devices with and without 
Invert.  This does no harm but is not useful either.  A cleaner solution 
for devices without Invert would be to omit the whole tool switching 
logic in this case:

@@ -1577,6 +1577,9 @@ void hidinput_hid_event(struct hid_device *hid, 
struct hid_field *field, struct

  	switch (usage->hid) {
  	case HID_DG_ERASER:
+		if (*quirks & HID_QUIRK_NOINVERT && usage->code != BTN_TOUCH)
+			break;
+
  		report->tool_active |= !!value;

Remapping Invert does not work anyway as the Invert tool is hardcoded in 
hidinput_hid_event.  Even worse, I guess (not tested) trying to do so 
would mask BTN_TOOL_RUBBER from dev->keybit and could cause weird 
behavior similar to one between 87562fcd1342 and 276e14e6c3.  This 
raises the question: should users be able to remap Invert after all?

  reply	other threads:[~2023-11-06 20:06 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <kRKTNDYigUSblpNgSuZ2H4dX03Of1yD4j_L9GgbyKXcDqZ67yh5HOQfcd7_83U3jZuQzxpKT3L6FXcRkkZIGdl_-PQF14oIB0QmRSfvpc2k=@protonmail.com>
2023-11-01 19:37 ` Requesting your attention and expertise regarding a Tablet/Kernel issue Jiri Kosina
2023-11-02  0:44   ` Bagas Sanjaya
2023-11-02  6:31     ` Linux regression tracking (Thorsten Leemhuis)
2023-11-02  7:51       ` Bagas Sanjaya
2023-11-02  7:44   ` Linux regression tracking #adding (Thorsten Leemhuis)
2023-12-01  8:24     ` Linux regression tracking #update (Thorsten Leemhuis)
2023-11-03 20:05   ` Illia Ostapyshyn
2023-11-04  0:46     ` Bagas Sanjaya
2023-11-06 13:17     ` David Revoy
2023-11-06 13:39       ` Conor Dooley
2023-11-06 16:59       ` Benjamin Tissoires
2023-11-06 20:06         ` Illia Ostapyshyn [this message]
2023-11-07  7:59           ` Benjamin Tissoires
2023-11-07 13:25             ` Illia Ostapyshyn
2023-11-07 13:40             ` Illia Ostapyshyn
2023-11-08  5:23             ` Eric GOUYER
2023-11-08  9:04               ` Benjamin Tissoires
2023-11-08  9:23                 ` José Expósito
2023-11-08  9:34                   ` Benjamin Tissoires
2023-11-08 18:21                     ` Benjamin Tissoires
2023-11-09  0:32                       ` David Revoy
2023-11-09 11:56                         ` Benjamin Tissoires
2023-11-09 16:13                           ` Benjamin Tissoires
2023-11-09 22:04                             ` David Revoy
2023-11-10 10:19                               ` Benjamin Tissoires
2023-11-11  8:52                               ` Benjamin Tissoires
2023-11-13 22:08                                 ` David Revoy
2023-11-14 14:35                                   ` Benjamin Tissoires
2023-11-15 15:14                                     ` Benjamin Tissoires
2023-11-23 22:12                                       ` David Revoy
2023-11-24 17:18                                         ` Benjamin Tissoires
2023-11-29 15:32                                           ` Benjamin Tissoires
2023-11-30 22:25                                             ` David Revoy
2023-12-01 15:41                                               ` Benjamin Tissoires
2023-11-08 19:40                 ` Nils Fuhler
2023-11-08 20:34                   ` Benjamin Tissoires
2023-11-08 22:31                     ` ostapyshyn
2023-11-09 11:46                       ` Benjamin Tissoires
2023-11-08 23:18             ` David Revoy
2023-11-09 11:47               ` Benjamin Tissoires
2023-11-11 17:15               ` Thorsten Leemhuis
2023-11-08 22:28         ` David Revoy

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=eb8e22f3-77dc-4923-a7ba-e237ee226edb@sra.uni-hannover.de \
    --to=ostapyshyn@sra.uni-hannover.de \
    --cc=bagasdotme@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=davidrevoy@protonmail.com \
    --cc=jason.gerecke@wacom.com \
    --cc=jkosina@suse.cz \
    --cc=jose.exposito89@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nils@nilsfuhler.de \
    --cc=peter.hutterer@who-t.net \
    --cc=ping.cheng@wacom.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;
as well as URLs for NNTP newsgroup(s).