diff mbox series

[v5,4/10] HID: multitouch: support getting the contact ID from HID_DG_TRANSDUCER_INDEX fields

Message ID BD919A98-0D44-42F9-867F-B936BBB8267A@live.com
State New
Headers show
Series Touch Bar support for T2 Macs | expand

Commit Message

Aditya Garg Aug. 17, 2024, 11:48 a.m. UTC
From: Kerem Karabay <kekrby@gmail.com>

This is needed to support Apple Touch Bars, where the contact ID is
contained in fields with the HID_DG_TRANSDUCER_INDEX usage.

Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/hid/hid-multitouch.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Benjamin Tissoires Sept. 27, 2024, 3:56 p.m. UTC | #1
On Aug 17 2024, Aditya Garg wrote:
> From: Kerem Karabay <kekrby@gmail.com>
> 
> This is needed to support Apple Touch Bars, where the contact ID is
> contained in fields with the HID_DG_TRANSDUCER_INDEX usage.
> 
> Signed-off-by: Kerem Karabay <kekrby@gmail.com>
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
>  drivers/hid/hid-multitouch.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 56fc78841..3e92789ed 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -635,7 +635,9 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
>  
>  		if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) {
>  			for (n = 0; n < field->report_count; n++) {
> -				if (field->usage[n].hid == HID_DG_CONTACTID) {
> +				unsigned int hid = field->usage[n].hid;
> +
> +				if (hid == HID_DG_CONTACTID || hid == HID_DG_TRANSDUCER_INDEX) {

I'm not super happy about this. The HID spec specifically mentions
CONTACTID to be related to multitouch, when TRANSDUCER is not
specifically for multitouch. I would rather have this hidden behind a
quirk, because I don't think this is standard (the device comes from an
environment where both the hardware and the software stack is
controlled, which already gave some fun decisions from Apple).

Cheers,
Benjamin

>  					rdata->is_mt_collection = true;
>  					break;
>  				}
> @@ -814,6 +816,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
>  			MT_STORE_FIELD(tip_state);
>  			return 1;
>  		case HID_DG_CONTACTID:
> +		case HID_DG_TRANSDUCER_INDEX:
>  			MT_STORE_FIELD(contactid);
>  			app->touches_by_report++;
>  			return 1;
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 56fc78841..3e92789ed 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -635,7 +635,9 @@  static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
 
 		if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) {
 			for (n = 0; n < field->report_count; n++) {
-				if (field->usage[n].hid == HID_DG_CONTACTID) {
+				unsigned int hid = field->usage[n].hid;
+
+				if (hid == HID_DG_CONTACTID || hid == HID_DG_TRANSDUCER_INDEX) {
 					rdata->is_mt_collection = true;
 					break;
 				}
@@ -814,6 +816,7 @@  static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 			MT_STORE_FIELD(tip_state);
 			return 1;
 		case HID_DG_CONTACTID:
+		case HID_DG_TRANSDUCER_INDEX:
 			MT_STORE_FIELD(contactid);
 			app->touches_by_report++;
 			return 1;