# Re: \[PATCH 2/3\] HID: hid-multitouch: support arrays for the split of the touches in a report

- From: Henrik Rydberg \<hidden\>
- Date: 2012-06-20 16:51:17 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2012/06/3882419
- Thread: https://ratatoskr.run/linux-input/2012/06/3881664/t.md

```text
Hi Benjamin,

> Win8 certification introduced the ability to transmit two X and two Y per
> touch. The specification precises that it must be in an array, with a
> report count == 2.
> 
> This test guarantees that we split the touches on the last element
> in this array.
> 
> Signed-off-by: Benjamin Tissoires <redacted>
> ---
>  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 9a3891e..a5ef877 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -601,7 +601,10 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
>  			return 0;
>  		}
>  
> -		if (usage->hid == td->last_slot_field)
> +		if (usage->hid == td->last_slot_field &&
> +			usage == &field->usage[field->maxusage - 1])
> +			/* we only take into account the last report
> +			 * of a field if report_count > 1 */

This just looks so fragile... The report index should really be amount
the arguments to mt_event(). Since we rely on the pointer to reveal
the index, why not try something like (usage - &field->usage[0]) ==
(field->report_count - 1)? At least it shows clearly what we use the
point for.

>  			mt_complete_slot(td);
>  
>  		if (field->index == td->last_field_index
> -- 
> 1.7.10.2
> 

Thanks,
Henrik
```
