OSDN Git Service

HID: input: tag touchscreens as such if the physical is not there
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 3 Feb 2022 14:32:18 +0000 (15:32 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 Mar 2022 14:46:02 +0000 (15:46 +0100)
Some devices (Elan, Synaptics...) are sometimes not setting a physical
in their finger collections. hid-input will consider them to be pen
devices, leading to some wrong behavior in user space.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-input.c

index 112901d..d256249 100644 (file)
@@ -828,10 +828,31 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
 
                case 0x32: /* InRange */
-                       switch (field->physical & 0xff) {
-                       case 0x21: map_key(BTN_TOOL_MOUSE); break;
-                       case 0x22: map_key(BTN_TOOL_FINGER); break;
-                       default: map_key(BTN_TOOL_PEN); break;
+                       switch (field->physical) {
+                       case HID_DG_PUCK:
+                               map_key(BTN_TOOL_MOUSE);
+                               break;
+                       case HID_DG_FINGER:
+                               map_key(BTN_TOOL_FINGER);
+                               break;
+                       default:
+                               /*
+                                * If the physical is not given,
+                                * rely on the application.
+                                */
+                               if (!field->physical) {
+                                       switch (field->application) {
+                                       case HID_DG_TOUCHSCREEN:
+                                       case HID_DG_TOUCHPAD:
+                                               map_key_clear(BTN_TOOL_FINGER);
+                                               break;
+                                       default:
+                                               map_key_clear(BTN_TOOL_PEN);
+                                       }
+                               } else {
+                                       map_key(BTN_TOOL_PEN);
+                               }
+                               break;
                        }
                        break;