Skip to content

Commit f41d736

Browse files
kekrbyJiri Kosina
authored andcommitted
HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar
In Apple Touch Bar, the contact ID is contained in fields with the HID_DG_TRANSDUCER_INDEX usage rather than HID_DG_CONTACTID, thus differing from the HID spec. Add a quirk for the same. Acked-by: Benjamin Tissoires <[email protected]> Signed-off-by: Kerem Karabay <[email protected]> Co-developed-by: Aditya Garg <[email protected]> Signed-off-by: Aditya Garg <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 2043ae9 commit f41d736

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/hid/hid-multitouch.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL");
7373
#define MT_QUIRK_FORCE_MULTI_INPUT BIT(20)
7474
#define MT_QUIRK_DISABLE_WAKEUP BIT(21)
7575
#define MT_QUIRK_ORIENTATION_INVERT BIT(22)
76+
#define MT_QUIRK_APPLE_TOUCHBAR BIT(23)
7677

7778
#define MT_INPUTMODE_TOUCHSCREEN 0x02
7879
#define MT_INPUTMODE_TOUCHPAD 0x03
@@ -625,6 +626,7 @@ static struct mt_application *mt_find_application(struct mt_device *td,
625626
static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
626627
struct hid_report *report)
627628
{
629+
struct mt_class *cls = &td->mtclass;
628630
struct mt_report_data *rdata;
629631
struct hid_field *field;
630632
int r, n;
@@ -649,7 +651,11 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
649651

650652
if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) {
651653
for (n = 0; n < field->report_count; n++) {
652-
if (field->usage[n].hid == HID_DG_CONTACTID) {
654+
unsigned int hid = field->usage[n].hid;
655+
656+
if (hid == HID_DG_CONTACTID ||
657+
(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR &&
658+
hid == HID_DG_TRANSDUCER_INDEX)) {
653659
rdata->is_mt_collection = true;
654660
break;
655661
}
@@ -827,6 +833,14 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
827833
EV_KEY, BTN_TOUCH);
828834
MT_STORE_FIELD(tip_state);
829835
return 1;
836+
case HID_DG_TRANSDUCER_INDEX:
837+
/*
838+
* Contact ID in case of Apple Touch Bars is contained
839+
* in fields with HID_DG_TRANSDUCER_INDEX usage.
840+
*/
841+
if (!(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR))
842+
return 0;
843+
fallthrough;
830844
case HID_DG_CONTACTID:
831845
MT_STORE_FIELD(contactid);
832846
app->touches_by_report++;

0 commit comments

Comments
 (0)