sharkcz / rpms / kernel

Forked from rpms/kernel 6 years ago
Clone
8163715
From 1989dada7ce07848196991c9ebf25ff9c5f14d4e Mon Sep 17 00:00:00 2001
8163715
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
8163715
Date: Tue, 13 Sep 2016 11:52:37 +0200
8163715
Subject: [PATCH] HID: input: ignore System Control application usages if not
8163715
 System Controls
8163715
8163715
Microsoft is reusing its report descriptor again and again, and part of it
8163715
looks like this:
8163715
8163715
0x05, 0x01,                    // Usage Page (Generic Desktop)        299
8163715
0x09, 0x80,                    // Usage (System Control)              301
8163715
0xa1, 0x01,                    // Collection (Application)            303
8163715
0x85, 0x03,                    //  Report ID (3)                      305
8163715
0x19, 0x00,                    //  Usage Minimum (0)                  307
8163715
0x29, 0xff,                    //  Usage Maximum (255)                309
8163715
0x15, 0x00,                    //  Logical Minimum (0)                311
8163715
0x26, 0xff, 0x00,              //  Logical Maximum (255)              313
8163715
0x81, 0x00,                    //  Input (Data,Arr,Abs)               316
8163715
0xc0,                          // End Collection                      318
8163715
8163715
While there is nothing wrong in term of processing, we do however blindly
8163715
map the full usage range (it's an array) from 0x00 to 0xff, which creates
8163715
some interesting axis, like ABS_X|Y, and a bunch of ABS_MISC + n.
8163715
8163715
While libinput and other stacks don't care that much (we can detect them),
8163715
joydev is very happy and attaches itself to the mouse or keyboard.
8163715
8163715
The problem is that joydev now handles the device as a joystick, but given
8163715
that we have a HID array, it sets all the ABS_* values to 0. And in its
8163715
world, 0 means -32767 (minimum value), which sends spurious events to games
8163715
(think Steam).
8163715
8163715
It looks like hid-microsoft tries to tackle the very same problem with its
8163715
.report_fixup callback. But fixing the report descriptor is an endless task
8163715
and is quite obfuscated.
8163715
8163715
So take the hammer, and decide that if the application is meant to be
8163715
System Control, any other usage not in the System Control range should
8163715
be ignored.
8163715
8163715
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1325354
8163715
Link: https://bugzilla.kernel.org/show_bug.cgi?id=28912
8163715
Link: https://github.com/ValveSoftware/steam-for-linux/issues/3384
8163715
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1325354
8163715
Link: https://bugzilla.kernel.org/show_bug.cgi?id=37982
8163715
8163715
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
8163715
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
8163715
---
8163715
 drivers/hid/hid-input.c | 9 +++++++++
8163715
 1 file changed, 9 insertions(+)
8163715
8163715
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
8163715
index bcfaf32..058919d 100644
8163715
--- a/drivers/hid/hid-input.c
8163715
+++ b/drivers/hid/hid-input.c
8163715
@@ -604,6 +604,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
8163715
 			break;
8163715
 		}
8163715
8163715
+		/*
8163715
+		 * Some lazy vendors declare 255 usages for System Control,
8163715
+		 * leading to the creation of ABS_X|Y axis and too many others.
8163715
+		 * It wouldn't be a problem if joydev doesn't consider the
8163715
+		 * device as a joystick then.
8163715
+		 */
8163715
+		if (field->application == HID_GD_SYSTEM_CONTROL)
8163715
+			goto ignore;
8163715
+
8163715
 		if ((usage->hid & 0xf0) == 0x90) {	/* D-pad */
8163715
 			switch (usage->hid) {
8163715
 			case HID_GD_UP:	   usage->hat_dir = 1; break;
8163715
-- 
8163715
2.7.4
8163715