Skip to content

Commit 2c6e027

Browse files
Seth ForsheeJiri Kosina
authored andcommitted
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 <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 015fdaa commit 2c6e027

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

drivers/hid/hid-debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
165165
{0, 0x53, "DeviceIndex"},
166166
{0, 0x54, "ContactCount"},
167167
{0, 0x55, "ContactMaximumNumber"},
168+
{0, 0x59, "ButtonType"},
168169
{0, 0x5A, "SecondaryBarrelSwitch"},
169170
{0, 0x5B, "TransducerSerialNumber"},
170171
{ 15, 0, "PhysicalInterfaceDevice" },

drivers/hid/hid-multitouch.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ MODULE_LICENSE("GPL");
7272
#define MT_INPUTMODE_TOUCHSCREEN 0x02
7373
#define MT_INPUTMODE_TOUCHPAD 0x03
7474

75+
#define MT_BUTTONTYPE_CLICKPAD 0
76+
7577
struct mt_slot {
7678
__s32 x, y, cx, cy, p, w, h;
7779
__s32 contactid; /* the device ContactID assigned to this slot */
@@ -117,6 +119,7 @@ struct mt_device {
117119
* 1 means we should use a serial protocol
118120
* > 1 means hybrid (multitouch) protocol */
119121
__u8 buttons_count; /* number of physical buttons per touchpad */
122+
bool is_buttonpad; /* is this device a button pad? */
120123
bool serial_maybe; /* need to check for serial protocol */
121124
bool curvalid; /* is the current contact valid? */
122125
unsigned mt_flags; /* flags to pass to input-mt */
@@ -334,6 +337,16 @@ static void mt_feature_mapping(struct hid_device *hdev,
334337
/* check if the maxcontacts is given by the class */
335338
td->maxcontacts = td->mtclass.maxcontacts;
336339

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+
337350
break;
338351
}
339352
}
@@ -735,6 +748,9 @@ static void mt_touch_input_configured(struct hid_device *hdev,
735748

736749
/* check for clickpads */
737750
if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1))
751+
td->is_buttonpad = true;
752+
753+
if (td->is_buttonpad)
738754
__set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
739755

740756
input_mt_init_slots(input, td->maxcontacts, td->mt_flags);

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ struct hid_item {
269269
#define HID_DG_DEVICEINDEX 0x000d0053
270270
#define HID_DG_CONTACTCOUNT 0x000d0054
271271
#define HID_DG_CONTACTMAX 0x000d0055
272+
#define HID_DG_BUTTONTYPE 0x000d0059
272273
#define HID_DG_BARRELSWITCH2 0x000d005a
273274
#define HID_DG_TOOLSERIALNUMBER 0x000d005b
274275

0 commit comments

Comments
 (0)