linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls
@ 2022-02-08 22:26 The Cheaterman
  0 siblings, 0 replies; 6+ messages in thread
From: The Cheaterman @ 2022-02-08 22:26 UTC (permalink / raw)
  To: linux-input

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Hello,

This breaks userspace. Now XkbLayout in xorg.conf.d is ignored for my
keyboard 0d62:3740 Darfon Electronics Corp. (built into my laptop)

Attached a simple patch that fixes the issue. Obviously, a revert is
probably a better idea ; or even better yet, do the part that was kept
aside to "keep the code simple".

Given this is happening on a consumer laptop (Alienware m15 R6), I'm
probably not the only one with this issue.

Thanks for reading.

[-- Attachment #2: 0001-fix-keyboard-layout.patch --]
[-- Type: text/x-patch, Size: 596 bytes --]

--- a/hid-input.c	2022-02-08 22:56:10.850000022 +0100
+++ b/hid-input.c	2022-02-08 22:56:15.737021611 +0100
@@ -1904,16 +1904,6 @@
 	list_for_each_entry(hidinput, &hid->inputs, list) {
 		if (hidinput->application == report->application)
 			return hidinput;
-
-		/*
-		 * Keep SystemControl and ConsumerControl applications together
-		 * with the main keyboard, if present.
-		 */
-		if ((report->application == HID_GD_SYSTEM_CONTROL ||
-		     report->application == HID_CP_CONSUMER_CONTROL) &&
-		    hidinput->application == HID_GD_KEYBOARD) {
-			return hidinput;
-		}
 	}
 
 	return NULL;

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls
@ 2021-01-14  6:24 Dmitry Torokhov
  2021-01-14  9:23 ` Benjamin Tissoires
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2021-01-14  6:24 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Peter Hutterer, seobrien, linux-input, linux-kernel

A typical USB keyboard usually splits its keys into several reports:

- one for the basic alphanumeric keys, modifier keys, F<n> keys, six pack
  keys and keypad. This report's application is normally listed as
  GenericDesktop.Keyboard
- a GenericDesktop.SystemControl report for the system control keys, such
  as power and sleep
- Consumer.ConsumerControl report for multimedia (forward, rewind,
  play/pause, mute, etc) and other extended keys.
- additional output, vendor specific, and feature reports

Splitting each report into a separate input device is wasteful and even
hurts userspace as it makes it harder to determine the true capabilities
(set of available keys) of a keyboard, so let's adjust application
matching to merge system control and consumer control reports with
keyboard report, if one has already been processed.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/hid/hid-input.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index f797659cb9d9..df45d8d07dc2 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1851,6 +1851,16 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
 	list_for_each_entry(hidinput, &hid->inputs, list) {
 		if (hidinput->application == report->application)
 			return hidinput;
+
+		/*
+		 * Keep SystemControl and ConsumerControl applications together
+		 * with the main keyboard, if present.
+		 */
+		if ((report->application == HID_GD_SYSTEM_CONTROL ||
+		     report->application == HID_CP_CONSUMER_CONTROL) &&
+		    hidinput->application == HID_GD_KEYBOARD) {
+			return hidinput;
+		}
 	}
 
 	return NULL;
-- 
2.30.0.284.gd98b1dd5eaa7-goog


-- 
Dmitry

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 22:26 [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls The Cheaterman
  -- strict thread matches above, loose matches on Subject: below --
2021-01-14  6:24 Dmitry Torokhov
2021-01-14  9:23 ` Benjamin Tissoires
2021-01-14 18:43   ` Dmitry Torokhov
2021-01-15  4:44 ` Peter Hutterer
2021-02-02 10:15 ` Jiri Kosina

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