Skip to content

Commit

Permalink
HID: multitouch: handle external buttons for Precision Touchpads
Browse files Browse the repository at this point in the history
According to https://msdn.microsoft.com/en-us/library/windows/hardware/mt604195(v=vs.85).aspx
external buttons have some weird usage mapping:
- Button 2 Indicates Button State for external button for primary
  (default left) clicking.
- Button 3 Indicates Button State for external button for secondary
  (default right) clicking.

So in the current state, the buttons are mapped to right and middle.
Move the usage by one to correctly map the external buttons.

Tested-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Benjamin Tissoires authored and Jiri Kosina committed Nov 28, 2016
1 parent e2b6535 commit 594312b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/hid/hid-multitouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,

case HID_UP_BUTTON:
code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE);
/*
* MS PTP spec says that external buttons left and right have
* usages 2 and 3.
*/
if (cls->name == MT_CLS_WIN_8 &&
field->application == HID_DG_TOUCHPAD &&
(usage->hid & HID_USAGE) > 1)
code--;
hid_map_usage(hi, usage, bit, max, EV_KEY, code);
input_set_capability(hi->input, EV_KEY, code);
return 1;
Expand Down

0 comments on commit 594312b

Please sign in to comment.