aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2015-03-11 18:26:41 -0400
committerJiri Kosina <jkosina@suse.cz>2015-03-12 00:04:13 -0400
commit2c6e0277e1eab3df5db81c59e408b7b1c14b1b72 (patch)
tree0e3eac73f8fdbbf4a5effdc90453f800314dd579
parent015fdaa9f8edd89a456b3331088e1b77ebdad9d0 (diff)
HID: multitouch: Add support for button type usage
According to [1], Windows Precision Touchpad devices must supply a button type usage in the device capabilities feature report. A value of 0 indicates that the device contains a depressible button (i.e. it's a click-pad) whereas a value of 1 indicates a non-depressible button. Add support for this usage and set INPUT_PROP_BUTTONPAD on the touchpad input device whenever a depressible button is present. [1] https://msdn.microsoft.com/en-us/library/windows/hardware/dn467314(v=vs.85).aspx Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-debug.c1
-rw-r--r--drivers/hid/hid-multitouch.c16
-rw-r--r--include/linux/hid.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 8bf61d295ffd..4b2a18a8b7ec 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -165,6 +165,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
165 {0, 0x53, "DeviceIndex"}, 165 {0, 0x53, "DeviceIndex"},
166 {0, 0x54, "ContactCount"}, 166 {0, 0x54, "ContactCount"},
167 {0, 0x55, "ContactMaximumNumber"}, 167 {0, 0x55, "ContactMaximumNumber"},
168 {0, 0x59, "ButtonType"},
168 {0, 0x5A, "SecondaryBarrelSwitch"}, 169 {0, 0x5A, "SecondaryBarrelSwitch"},
169 {0, 0x5B, "TransducerSerialNumber"}, 170 {0, 0x5B, "TransducerSerialNumber"},
170 { 15, 0, "PhysicalInterfaceDevice" }, 171 { 15, 0, "PhysicalInterfaceDevice" },
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index ef06dc30b9b1..55e89b16b3da 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -72,6 +72,8 @@ MODULE_LICENSE("GPL");
72#define MT_INPUTMODE_TOUCHSCREEN 0x02 72#define MT_INPUTMODE_TOUCHSCREEN 0x02
73#define MT_INPUTMODE_TOUCHPAD 0x03 73#define MT_INPUTMODE_TOUCHPAD 0x03
74 74
75#define MT_BUTTONTYPE_CLICKPAD 0
76
75struct mt_slot { 77struct mt_slot {
76 __s32 x, y, cx, cy, p, w, h; 78 __s32 x, y, cx, cy, p, w, h;
77 __s32 contactid; /* the device ContactID assigned to this slot */ 79 __s32 contactid; /* the device ContactID assigned to this slot */
@@ -117,6 +119,7 @@ struct mt_device {
117 * 1 means we should use a serial protocol 119 * 1 means we should use a serial protocol
118 * > 1 means hybrid (multitouch) protocol */ 120 * > 1 means hybrid (multitouch) protocol */
119 __u8 buttons_count; /* number of physical buttons per touchpad */ 121 __u8 buttons_count; /* number of physical buttons per touchpad */
122 bool is_buttonpad; /* is this device a button pad? */
120 bool serial_maybe; /* need to check for serial protocol */ 123 bool serial_maybe; /* need to check for serial protocol */
121 bool curvalid; /* is the current contact valid? */ 124 bool curvalid; /* is the current contact valid? */
122 unsigned mt_flags; /* flags to pass to input-mt */ 125 unsigned mt_flags; /* flags to pass to input-mt */
@@ -335,6 +338,16 @@ static void mt_feature_mapping(struct hid_device *hdev,
335 td->maxcontacts = td->mtclass.maxcontacts; 338 td->maxcontacts = td->mtclass.maxcontacts;
336 339
337 break; 340 break;
341 case HID_DG_BUTTONTYPE:
342 if (usage->usage_index >= field->report_count) {
343 dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n");
344 break;
345 }
346
347 if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD)
348 td->is_buttonpad = true;
349
350 break;
338 } 351 }
339} 352}
340 353
@@ -735,6 +748,9 @@ static void mt_touch_input_configured(struct hid_device *hdev,
735 748
736 /* check for clickpads */ 749 /* check for clickpads */
737 if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1)) 750 if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1))
751 td->is_buttonpad = true;
752
753 if (td->is_buttonpad)
738 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 754 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
739 755
740 input_mt_init_slots(input, td->maxcontacts, td->mt_flags); 756 input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index efc7787a41a8..f455c38d7562 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -269,6 +269,7 @@ struct hid_item {
269#define HID_DG_DEVICEINDEX 0x000d0053 269#define HID_DG_DEVICEINDEX 0x000d0053
270#define HID_DG_CONTACTCOUNT 0x000d0054 270#define HID_DG_CONTACTCOUNT 0x000d0054
271#define HID_DG_CONTACTMAX 0x000d0055 271#define HID_DG_CONTACTMAX 0x000d0055
272#define HID_DG_BUTTONTYPE 0x000d0059
272#define HID_DG_BARRELSWITCH2 0x000d005a 273#define HID_DG_BARRELSWITCH2 0x000d005a
273#define HID_DG_TOOLSERIALNUMBER 0x000d005b 274#define HID_DG_TOOLSERIALNUMBER 0x000d005b
274 275