Commit 2c6e0277 authored by Seth Forshee's avatar Seth Forshee Committed by Jiri Kosina

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).aspxSigned-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 015fdaa9
...@@ -165,6 +165,7 @@ static const struct hid_usage_entry hid_usage_table[] = { ...@@ -165,6 +165,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
{0, 0x53, "DeviceIndex"}, {0, 0x53, "DeviceIndex"},
{0, 0x54, "ContactCount"}, {0, 0x54, "ContactCount"},
{0, 0x55, "ContactMaximumNumber"}, {0, 0x55, "ContactMaximumNumber"},
{0, 0x59, "ButtonType"},
{0, 0x5A, "SecondaryBarrelSwitch"}, {0, 0x5A, "SecondaryBarrelSwitch"},
{0, 0x5B, "TransducerSerialNumber"}, {0, 0x5B, "TransducerSerialNumber"},
{ 15, 0, "PhysicalInterfaceDevice" }, { 15, 0, "PhysicalInterfaceDevice" },
......
...@@ -72,6 +72,8 @@ MODULE_LICENSE("GPL"); ...@@ -72,6 +72,8 @@ MODULE_LICENSE("GPL");
#define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHSCREEN 0x02
#define MT_INPUTMODE_TOUCHPAD 0x03 #define MT_INPUTMODE_TOUCHPAD 0x03
#define MT_BUTTONTYPE_CLICKPAD 0
struct mt_slot { struct mt_slot {
__s32 x, y, cx, cy, p, w, h; __s32 x, y, cx, cy, p, w, h;
__s32 contactid; /* the device ContactID assigned to this slot */ __s32 contactid; /* the device ContactID assigned to this slot */
...@@ -117,6 +119,7 @@ struct mt_device { ...@@ -117,6 +119,7 @@ struct mt_device {
* 1 means we should use a serial protocol * 1 means we should use a serial protocol
* > 1 means hybrid (multitouch) protocol */ * > 1 means hybrid (multitouch) protocol */
__u8 buttons_count; /* number of physical buttons per touchpad */ __u8 buttons_count; /* number of physical buttons per touchpad */
bool is_buttonpad; /* is this device a button pad? */
bool serial_maybe; /* need to check for serial protocol */ bool serial_maybe; /* need to check for serial protocol */
bool curvalid; /* is the current contact valid? */ bool curvalid; /* is the current contact valid? */
unsigned mt_flags; /* flags to pass to input-mt */ unsigned mt_flags; /* flags to pass to input-mt */
...@@ -334,6 +337,16 @@ static void mt_feature_mapping(struct hid_device *hdev, ...@@ -334,6 +337,16 @@ static void mt_feature_mapping(struct hid_device *hdev,
/* check if the maxcontacts is given by the class */ /* check if the maxcontacts is given by the class */
td->maxcontacts = td->mtclass.maxcontacts; td->maxcontacts = td->mtclass.maxcontacts;
break;
case HID_DG_BUTTONTYPE:
if (usage->usage_index >= field->report_count) {
dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n");
break;
}
if (field->value[usage->usage_index] == MT_BUTTONTYPE_CLICKPAD)
td->is_buttonpad = true;
break; break;
} }
} }
...@@ -735,6 +748,9 @@ static void mt_touch_input_configured(struct hid_device *hdev, ...@@ -735,6 +748,9 @@ static void mt_touch_input_configured(struct hid_device *hdev,
/* check for clickpads */ /* check for clickpads */
if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1)) if ((td->mt_flags & INPUT_MT_POINTER) && (td->buttons_count == 1))
td->is_buttonpad = true;
if (td->is_buttonpad)
__set_bit(INPUT_PROP_BUTTONPAD, input->propbit); __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
input_mt_init_slots(input, td->maxcontacts, td->mt_flags); input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
......
...@@ -269,6 +269,7 @@ struct hid_item { ...@@ -269,6 +269,7 @@ struct hid_item {
#define HID_DG_DEVICEINDEX 0x000d0053 #define HID_DG_DEVICEINDEX 0x000d0053
#define HID_DG_CONTACTCOUNT 0x000d0054 #define HID_DG_CONTACTCOUNT 0x000d0054
#define HID_DG_CONTACTMAX 0x000d0055 #define HID_DG_CONTACTMAX 0x000d0055
#define HID_DG_BUTTONTYPE 0x000d0059
#define HID_DG_BARRELSWITCH2 0x000d005a #define HID_DG_BARRELSWITCH2 0x000d005a
#define HID_DG_TOOLSERIALNUMBER 0x000d005b #define HID_DG_TOOLSERIALNUMBER 0x000d005b
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment