LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH RESEND v3] Input: clear BTN_RIGHT/MIDDLE on buttonpads
@ 2022-02-08 17:48 José Expósito
  2022-02-08 20:57 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: José Expósito @ 2022-02-08 17:48 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: rydberg, linux-input, linux-kernel, José Expósito,
	Peter Hutterer, Benjamin Tissoires, Jiri Kosina

Buttonpads are expected to map the INPUT_PROP_BUTTONPAD property bit
and the BTN_LEFT key bit.

As explained in the specification, where a device has a button type
value of 0 (click-pad) or 1 (pressure-pad) there should not be
discrete buttons:
https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection#device-capabilities-feature-report

However, some drivers map the BTN_RIGHT and/or BTN_MIDDLE key bits even
though the device is a buttonpad and therefore does not have those
buttons.

This behavior has forced userspace applications like libinput to
implement different workarounds and quirks to detect buttonpads and
offer to the user the right set of features and configuration options.
For more information:
https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/726

In order to avoid this issue clear the BTN_RIGHT and BTN_MIDDLE key
bits when the input device is register if the INPUT_PROP_BUTTONPAD
property bit is set.

Notice that this change will not affect udev because it does not check
for buttons. See systemd/src/udev/udev-builtin-input_id.c.

List of known affected hardware:

 - Chuwi AeroBook Plus
 - Chuwi Gemibook
 - Framework Laptop
 - GPD Win Max
 - Huawei MateBook 2020
 - Prestigio Smartbook 141 C2
 - Purism Librem 14v1
 - StarLite Mk II   - AMI firmware
 - StarLite Mk II   - Coreboot firmware
 - StarLite Mk III  - AMI firmware
 - StarLite Mk III  - Coreboot firmware
 - StarLabTop Mk IV - AMI firmware
 - StarLabTop Mk IV - Coreboot firmware
 - StarBook Mk V

Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>

---

v3:

 - Clear BTN_RIGHT/MIDDLE on input_register_device
   (Thanks to Dmitry Torokhov for pointing me in this direction)

 - Add acked-by tags (thanks to Peter, Benjamin and Jiří)
---
 drivers/input/input.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ccaeb2426385..c3139bc2aa0d 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2285,6 +2285,12 @@ int input_register_device(struct input_dev *dev)
 	/* KEY_RESERVED is not supposed to be transmitted to userspace. */
 	__clear_bit(KEY_RESERVED, dev->keybit);
 
+	/* Buttonpads should not map BTN_RIGHT and/or BTN_MIDDLE. */
+	if (test_bit(INPUT_PROP_BUTTONPAD, dev->propbit)) {
+		__clear_bit(BTN_RIGHT, dev->keybit);
+		__clear_bit(BTN_MIDDLE, dev->keybit);
+	}
+
 	/* Make sure that bitmasks not mentioned in dev->evbit are clean. */
 	input_cleanse_bitmasks(dev);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND v3] Input: clear BTN_RIGHT/MIDDLE on buttonpads
  2022-02-08 17:48 [PATCH RESEND v3] Input: clear BTN_RIGHT/MIDDLE on buttonpads José Expósito
@ 2022-02-08 20:57 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2022-02-08 20:57 UTC (permalink / raw)
  To: José Expósito
  Cc: rydberg, linux-input, linux-kernel, Peter Hutterer,
	Benjamin Tissoires, Jiri Kosina

On Tue, Feb 08, 2022 at 06:48:06PM +0100, José Expósito wrote:
> Buttonpads are expected to map the INPUT_PROP_BUTTONPAD property bit
> and the BTN_LEFT key bit.
> 
> As explained in the specification, where a device has a button type
> value of 0 (click-pad) or 1 (pressure-pad) there should not be
> discrete buttons:
> https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection#device-capabilities-feature-report
> 
> However, some drivers map the BTN_RIGHT and/or BTN_MIDDLE key bits even
> though the device is a buttonpad and therefore does not have those
> buttons.
> 
> This behavior has forced userspace applications like libinput to
> implement different workarounds and quirks to detect buttonpads and
> offer to the user the right set of features and configuration options.
> For more information:
> https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/726
> 
> In order to avoid this issue clear the BTN_RIGHT and BTN_MIDDLE key
> bits when the input device is register if the INPUT_PROP_BUTTONPAD
> property bit is set.
> 
> Notice that this change will not affect udev because it does not check
> for buttons. See systemd/src/udev/udev-builtin-input_id.c.
> 
> List of known affected hardware:
> 
>  - Chuwi AeroBook Plus
>  - Chuwi Gemibook
>  - Framework Laptop
>  - GPD Win Max
>  - Huawei MateBook 2020
>  - Prestigio Smartbook 141 C2
>  - Purism Librem 14v1
>  - StarLite Mk II   - AMI firmware
>  - StarLite Mk II   - Coreboot firmware
>  - StarLite Mk III  - AMI firmware
>  - StarLite Mk III  - Coreboot firmware
>  - StarLabTop Mk IV - AMI firmware
>  - StarLabTop Mk IV - Coreboot firmware
>  - StarBook Mk V
> 
> Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Acked-by: Jiri Kosina <jkosina@suse.cz>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> 

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-08 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 17:48 [PATCH RESEND v3] Input: clear BTN_RIGHT/MIDDLE on buttonpads José Expósito
2022-02-08 20:57 ` Dmitry Torokhov

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).