diff mbox

HID: multitouch: handle external buttons for Precision Touchpads

Message ID 1501744812-4264-2-git-send-email-acelan.kao@canonical.com
State New
Headers show

Commit Message

AceLan Kao Aug. 3, 2017, 7:20 a.m. UTC
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>

BugLink: https://bugs.launchpad.net/bugs/1708372

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>
(cherry picked from commit 594312b88b0f451912c964c7ff2c0eaa71ad41b4)
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
---
 drivers/hid/hid-multitouch.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Stefan Bader Aug. 3, 2017, 1:36 p.m. UTC | #1
On 03.08.2017 09:20, AceLan Kao wrote:
> From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1708372
> 
> 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>
> (cherry picked from commit 594312b88b0f451912c964c7ff2c0eaa71ad41b4)
> Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---
>  drivers/hid/hid-multitouch.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index f62a9d6..2177721 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -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;
>
Marcelo Henrique Cerri Aug. 7, 2017, 2 p.m. UTC | #2
Clean cherry-pick and testable.

Acked-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Kleber Sacilotto de Souza Aug. 8, 2017, 10:01 a.m. UTC | #3
Applied on xenial/master-next branch. Thanks.
diff mbox

Patch

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index f62a9d6..2177721 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -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;