Skip to content

Commit 3c2b0db

Browse files
bentissJiri Kosina
authored andcommitted
HID: input: tag touchscreens as such if the physical is not there
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>
1 parent b79c1ab commit 3c2b0db

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

drivers/hid/hid-input.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,31 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
828828
break;
829829

830830
case 0x32: /* InRange */
831-
switch (field->physical & 0xff) {
832-
case 0x21: map_key(BTN_TOOL_MOUSE); break;
833-
case 0x22: map_key(BTN_TOOL_FINGER); break;
834-
default: map_key(BTN_TOOL_PEN); break;
831+
switch (field->physical) {
832+
case HID_DG_PUCK:
833+
map_key(BTN_TOOL_MOUSE);
834+
break;
835+
case HID_DG_FINGER:
836+
map_key(BTN_TOOL_FINGER);
837+
break;
838+
default:
839+
/*
840+
* If the physical is not given,
841+
* rely on the application.
842+
*/
843+
if (!field->physical) {
844+
switch (field->application) {
845+
case HID_DG_TOUCHSCREEN:
846+
case HID_DG_TOUCHPAD:
847+
map_key_clear(BTN_TOOL_FINGER);
848+
break;
849+
default:
850+
map_key_clear(BTN_TOOL_PEN);
851+
}
852+
} else {
853+
map_key(BTN_TOOL_PEN);
854+
}
855+
break;
835856
}
836857
break;
837858

0 commit comments

Comments
 (0)