@@ -75,7 +75,6 @@ struct mt_device {
75
75
struct mt_class mtclass ; /* our mt device class */
76
76
unsigned last_field_index ; /* last field index of the report */
77
77
unsigned last_slot_field ; /* the last field of a slot */
78
- int last_mt_collection ; /* last known mt-related collection */
79
78
__s8 inputmode ; /* InputMode HID feature, -1 if non-existent */
80
79
__s8 maxcontact_report_id ; /* Maximum Contact Number HID feature,
81
80
-1 if non-existent */
@@ -273,6 +272,13 @@ static void set_abs(struct input_dev *input, unsigned int code,
273
272
input_set_abs_params (input , code , fmin , fmax , fuzz , 0 );
274
273
}
275
274
275
+ static void set_last_slot_field (struct hid_usage * usage , struct mt_device * td ,
276
+ struct hid_input * hi )
277
+ {
278
+ if (!test_bit (usage -> hid , hi -> input -> absbit ))
279
+ td -> last_slot_field = usage -> hid ;
280
+ }
281
+
276
282
static int mt_input_mapping (struct hid_device * hdev , struct hid_input * hi ,
277
283
struct hid_field * field , struct hid_usage * usage ,
278
284
unsigned long * * bit , int * max )
@@ -321,10 +327,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
321
327
cls -> sn_move );
322
328
/* touchscreen emulation */
323
329
set_abs (hi -> input , ABS_X , field , cls -> sn_move );
324
- if (td -> last_mt_collection == usage -> collection_index ) {
325
- td -> last_slot_field = usage -> hid ;
326
- td -> last_field_index = field -> index ;
327
- }
330
+ set_last_slot_field (usage , td , hi );
331
+ td -> last_field_index = field -> index ;
328
332
return 1 ;
329
333
case HID_GD_Y :
330
334
hid_map_usage (hi , usage , bit , max ,
@@ -333,53 +337,42 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
333
337
cls -> sn_move );
334
338
/* touchscreen emulation */
335
339
set_abs (hi -> input , ABS_Y , field , cls -> sn_move );
336
- if (td -> last_mt_collection == usage -> collection_index ) {
337
- td -> last_slot_field = usage -> hid ;
338
- td -> last_field_index = field -> index ;
339
- }
340
+ set_last_slot_field (usage , td , hi );
341
+ td -> last_field_index = field -> index ;
340
342
return 1 ;
341
343
}
342
344
return 0 ;
343
345
344
346
case HID_UP_DIGITIZER :
345
347
switch (usage -> hid ) {
346
348
case HID_DG_INRANGE :
347
- if (td -> last_mt_collection == usage -> collection_index ) {
348
- td -> last_slot_field = usage -> hid ;
349
- td -> last_field_index = field -> index ;
350
- }
349
+ set_last_slot_field (usage , td , hi );
350
+ td -> last_field_index = field -> index ;
351
351
return 1 ;
352
352
case HID_DG_CONFIDENCE :
353
- if (td -> last_mt_collection == usage -> collection_index ) {
354
- td -> last_slot_field = usage -> hid ;
355
- td -> last_field_index = field -> index ;
356
- }
353
+ set_last_slot_field (usage , td , hi );
354
+ td -> last_field_index = field -> index ;
357
355
return 1 ;
358
356
case HID_DG_TIPSWITCH :
359
357
hid_map_usage (hi , usage , bit , max , EV_KEY , BTN_TOUCH );
360
358
input_set_capability (hi -> input , EV_KEY , BTN_TOUCH );
361
- if (td -> last_mt_collection == usage -> collection_index ) {
362
- td -> last_slot_field = usage -> hid ;
363
- td -> last_field_index = field -> index ;
364
- }
359
+ set_last_slot_field (usage , td , hi );
360
+ td -> last_field_index = field -> index ;
365
361
return 1 ;
366
362
case HID_DG_CONTACTID :
367
363
if (!td -> maxcontacts )
368
364
td -> maxcontacts = MT_DEFAULT_MAXCONTACT ;
369
365
input_mt_init_slots (hi -> input , td -> maxcontacts );
370
366
td -> last_slot_field = usage -> hid ;
371
367
td -> last_field_index = field -> index ;
372
- td -> last_mt_collection = usage -> collection_index ;
373
368
return 1 ;
374
369
case HID_DG_WIDTH :
375
370
hid_map_usage (hi , usage , bit , max ,
376
371
EV_ABS , ABS_MT_TOUCH_MAJOR );
377
372
set_abs (hi -> input , ABS_MT_TOUCH_MAJOR , field ,
378
373
cls -> sn_width );
379
- if (td -> last_mt_collection == usage -> collection_index ) {
380
- td -> last_slot_field = usage -> hid ;
381
- td -> last_field_index = field -> index ;
382
- }
374
+ set_last_slot_field (usage , td , hi );
375
+ td -> last_field_index = field -> index ;
383
376
return 1 ;
384
377
case HID_DG_HEIGHT :
385
378
hid_map_usage (hi , usage , bit , max ,
@@ -388,10 +381,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
388
381
cls -> sn_height );
389
382
input_set_abs_params (hi -> input ,
390
383
ABS_MT_ORIENTATION , 0 , 1 , 0 , 0 );
391
- if (td -> last_mt_collection == usage -> collection_index ) {
392
- td -> last_slot_field = usage -> hid ;
393
- td -> last_field_index = field -> index ;
394
- }
384
+ set_last_slot_field (usage , td , hi );
385
+ td -> last_field_index = field -> index ;
395
386
return 1 ;
396
387
case HID_DG_TIPPRESSURE :
397
388
hid_map_usage (hi , usage , bit , max ,
@@ -401,20 +392,16 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
401
392
/* touchscreen emulation */
402
393
set_abs (hi -> input , ABS_PRESSURE , field ,
403
394
cls -> sn_pressure );
404
- if (td -> last_mt_collection == usage -> collection_index ) {
405
- td -> last_slot_field = usage -> hid ;
406
- td -> last_field_index = field -> index ;
407
- }
395
+ set_last_slot_field (usage , td , hi );
396
+ td -> last_field_index = field -> index ;
408
397
return 1 ;
409
398
case HID_DG_CONTACTCOUNT :
410
- if (td -> last_mt_collection == usage -> collection_index )
411
- td -> last_field_index = field -> index ;
399
+ td -> last_field_index = field -> index ;
412
400
return 1 ;
413
401
case HID_DG_CONTACTMAX :
414
402
/* we don't set td->last_slot_field as contactcount and
415
403
* contact max are global to the report */
416
- if (td -> last_mt_collection == usage -> collection_index )
417
- td -> last_field_index = field -> index ;
404
+ td -> last_field_index = field -> index ;
418
405
return -1 ;
419
406
}
420
407
case HID_DG_TOUCH :
@@ -670,7 +657,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
670
657
td -> mtclass = * mtclass ;
671
658
td -> inputmode = -1 ;
672
659
td -> maxcontact_report_id = -1 ;
673
- td -> last_mt_collection = -1 ;
674
660
hid_set_drvdata (hdev , td );
675
661
676
662
ret = hid_parse (hdev );
0 commit comments