@@ -64,6 +64,7 @@ struct mt_device {
64
64
struct mt_class * mtclass ; /* our mt device class */
65
65
unsigned last_field_index ; /* last field index of the report */
66
66
unsigned last_slot_field ; /* the last field of a slot */
67
+ int last_mt_collection ; /* last known mt-related collection */
67
68
__s8 inputmode ; /* InputMode HID feature, -1 if non-existent */
68
69
__u8 num_received ; /* how many contacts we received */
69
70
__u8 num_expected ; /* expected last contact index */
@@ -225,8 +226,10 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
225
226
cls -> sn_move );
226
227
/* touchscreen emulation */
227
228
set_abs (hi -> input , ABS_X , field , cls -> sn_move );
228
- td -> last_slot_field = usage -> hid ;
229
- td -> last_field_index = field -> index ;
229
+ if (td -> last_mt_collection == usage -> collection_index ) {
230
+ td -> last_slot_field = usage -> hid ;
231
+ td -> last_field_index = field -> index ;
232
+ }
230
233
return 1 ;
231
234
case HID_GD_Y :
232
235
if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP )
@@ -237,40 +240,51 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
237
240
cls -> sn_move );
238
241
/* touchscreen emulation */
239
242
set_abs (hi -> input , ABS_Y , field , cls -> sn_move );
240
- td -> last_slot_field = usage -> hid ;
241
- td -> last_field_index = field -> index ;
243
+ if (td -> last_mt_collection == usage -> collection_index ) {
244
+ td -> last_slot_field = usage -> hid ;
245
+ td -> last_field_index = field -> index ;
246
+ }
242
247
return 1 ;
243
248
}
244
249
return 0 ;
245
250
246
251
case HID_UP_DIGITIZER :
247
252
switch (usage -> hid ) {
248
253
case HID_DG_INRANGE :
249
- td -> last_slot_field = usage -> hid ;
250
- td -> last_field_index = field -> index ;
254
+ if (td -> last_mt_collection == usage -> collection_index ) {
255
+ td -> last_slot_field = usage -> hid ;
256
+ td -> last_field_index = field -> index ;
257
+ }
251
258
return 1 ;
252
259
case HID_DG_CONFIDENCE :
253
- td -> last_slot_field = usage -> hid ;
254
- td -> last_field_index = field -> index ;
260
+ if (td -> last_mt_collection == usage -> collection_index ) {
261
+ td -> last_slot_field = usage -> hid ;
262
+ td -> last_field_index = field -> index ;
263
+ }
255
264
return 1 ;
256
265
case HID_DG_TIPSWITCH :
257
266
hid_map_usage (hi , usage , bit , max , EV_KEY , BTN_TOUCH );
258
267
input_set_capability (hi -> input , EV_KEY , BTN_TOUCH );
259
- td -> last_slot_field = usage -> hid ;
260
- td -> last_field_index = field -> index ;
268
+ if (td -> last_mt_collection == usage -> collection_index ) {
269
+ td -> last_slot_field = usage -> hid ;
270
+ td -> last_field_index = field -> index ;
271
+ }
261
272
return 1 ;
262
273
case HID_DG_CONTACTID :
263
274
input_mt_init_slots (hi -> input , td -> maxcontacts );
264
275
td -> last_slot_field = usage -> hid ;
265
276
td -> last_field_index = field -> index ;
277
+ td -> last_mt_collection = usage -> collection_index ;
266
278
return 1 ;
267
279
case HID_DG_WIDTH :
268
280
hid_map_usage (hi , usage , bit , max ,
269
281
EV_ABS , ABS_MT_TOUCH_MAJOR );
270
282
set_abs (hi -> input , ABS_MT_TOUCH_MAJOR , field ,
271
283
cls -> sn_width );
272
- td -> last_slot_field = usage -> hid ;
273
- td -> last_field_index = field -> index ;
284
+ if (td -> last_mt_collection == usage -> collection_index ) {
285
+ td -> last_slot_field = usage -> hid ;
286
+ td -> last_field_index = field -> index ;
287
+ }
274
288
return 1 ;
275
289
case HID_DG_HEIGHT :
276
290
hid_map_usage (hi , usage , bit , max ,
@@ -279,8 +293,10 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
279
293
cls -> sn_height );
280
294
input_set_abs_params (hi -> input ,
281
295
ABS_MT_ORIENTATION , 0 , 1 , 0 , 0 );
282
- td -> last_slot_field = usage -> hid ;
283
- td -> last_field_index = field -> index ;
296
+ if (td -> last_mt_collection == usage -> collection_index ) {
297
+ td -> last_slot_field = usage -> hid ;
298
+ td -> last_field_index = field -> index ;
299
+ }
284
300
return 1 ;
285
301
case HID_DG_TIPPRESSURE :
286
302
if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP )
@@ -292,16 +308,20 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
292
308
/* touchscreen emulation */
293
309
set_abs (hi -> input , ABS_PRESSURE , field ,
294
310
cls -> sn_pressure );
295
- td -> last_slot_field = usage -> hid ;
296
- td -> last_field_index = field -> index ;
311
+ if (td -> last_mt_collection == usage -> collection_index ) {
312
+ td -> last_slot_field = usage -> hid ;
313
+ td -> last_field_index = field -> index ;
314
+ }
297
315
return 1 ;
298
316
case HID_DG_CONTACTCOUNT :
299
- td -> last_field_index = field -> index ;
317
+ if (td -> last_mt_collection == usage -> collection_index )
318
+ td -> last_field_index = field -> index ;
300
319
return 1 ;
301
320
case HID_DG_CONTACTMAX :
302
321
/* we don't set td->last_slot_field as contactcount and
303
322
* contact max are global to the report */
304
- td -> last_field_index = field -> index ;
323
+ if (td -> last_mt_collection == usage -> collection_index )
324
+ td -> last_field_index = field -> index ;
305
325
return -1 ;
306
326
}
307
327
/* let hid-input decide for the others */
@@ -516,6 +536,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
516
536
}
517
537
td -> mtclass = mtclass ;
518
538
td -> inputmode = -1 ;
539
+ td -> last_mt_collection = -1 ;
519
540
hid_set_drvdata (hdev , td );
520
541
521
542
ret = hid_parse (hdev );
0 commit comments