62a6bef
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
62a6bef
Date: Fri, 6 Mar 2015 11:14:42 -0500
62a6bef
Subject: [PATCH] HID: multitouch: add support of clickpads
62a6bef
62a6bef
Touchpads that have only one button are called clickpads and should
62a6bef
be advertised as such by the kernel.
62a6bef
62a6bef
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
62a6bef
Tested-by: Jason Ekstrand <jason@jlekstrand.net>
62a6bef
---
62a6bef
 drivers/hid/hid-multitouch.c | 9 +++++++++
62a6bef
 1 file changed, 9 insertions(+)
62a6bef
62a6bef
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
62a6bef
index f65e78b46999..ef06dc30b9b1 100644
62a6bef
--- a/drivers/hid/hid-multitouch.c
62a6bef
+++ b/drivers/hid/hid-multitouch.c
62a6bef
@@ -116,6 +116,7 @@ struct mt_device {
62a6bef
 	__u8 touches_by_report;	/* how many touches are present in one report:
62a6bef
 				* 1 means we should use a serial protocol
62a6bef
 				* > 1 means hybrid (multitouch) protocol */
62a6bef
+	__u8 buttons_count;	/* number of physical buttons per touchpad */
62a6bef
 	bool serial_maybe;	/* need to check for serial protocol */
62a6bef
 	bool curvalid;		/* is the current contact valid? */
62a6bef
 	unsigned mt_flags;	/* flags to pass to input-mt */
62a6bef
@@ -379,6 +380,10 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
62a6bef
 		td->inputmode_value = MT_INPUTMODE_TOUCHPAD;
62a6bef
 	}
62a6bef
 
62a6bef
+	/* count the buttons on touchpads */
62a6bef
+	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)
62a6bef
+		td->buttons_count++;
62a6bef
+
62a6bef
 	if (usage->usage_index)
62a6bef
 		prev_usage = &field->usage[usage->usage_index - 1];
62a6bef
 
62a6bef
@@ -728,6 +733,10 @@ static void mt_touch_input_configured(struct hid_device *hdev,
62a6bef
 	if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
62a6bef
 		td->mt_flags |= INPUT_MT_DROP_UNUSED;
62a6bef
 
62a6bef
+	/* check for clickpads */
62a6bef
+	if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1))
62a6bef
+		__set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
62a6bef
+
62a6bef
 	input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
62a6bef
 
62a6bef
 	td->mt_flags = 0;
62a6bef
-- 
62a6bef
2.1.0
62a6bef