Skip to content

Commit 2955cae

Browse files
Benjamin TissoiresJiri Kosina
authored andcommitted
HID: hid-multitouch: refactor last_field_index
the current implementation requires the devices to report HID_DG_CONTACTCOUNT to set the last_field_index value. However, devices reporting in serial mode (DWAV and PenMount) do not send this field. Other devices (3M) add other fields in the reports descriptor that are not multitouch related at the end, thus the need to add a special case in the default case when handling events. A first work around has been set up but with PenMount devices, we have reached the limit. The idea is to calculate the last_field_index by relying only on multitouch fields the device send. This allows us to remove the handling of non-multitouch events in hid-multitouch, and guarantee that the function mt_emit_event is always called. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Reviewed-and-tested-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent f786bba commit 2955cae

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎drivers/hid/hid-multitouch.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
210210
/* touchscreen emulation */
211211
set_abs(hi->input, ABS_X, field, cls->sn_move);
212212
td->last_slot_field = usage->hid;
213+
td->last_field_index = field->index;
213214
return 1;
214215
case HID_GD_Y:
215216
if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
@@ -221,6 +222,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
221222
/* touchscreen emulation */
222223
set_abs(hi->input, ABS_Y, field, cls->sn_move);
223224
td->last_slot_field = usage->hid;
225+
td->last_field_index = field->index;
224226
return 1;
225227
}
226228
return 0;
@@ -229,25 +231,30 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
229231
switch (usage->hid) {
230232
case HID_DG_INRANGE:
231233
td->last_slot_field = usage->hid;
234+
td->last_field_index = field->index;
232235
return 1;
233236
case HID_DG_CONFIDENCE:
234237
td->last_slot_field = usage->hid;
238+
td->last_field_index = field->index;
235239
return 1;
236240
case HID_DG_TIPSWITCH:
237241
hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
238242
input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
239243
td->last_slot_field = usage->hid;
244+
td->last_field_index = field->index;
240245
return 1;
241246
case HID_DG_CONTACTID:
242247
input_mt_init_slots(hi->input, td->maxcontacts);
243248
td->last_slot_field = usage->hid;
249+
td->last_field_index = field->index;
244250
return 1;
245251
case HID_DG_WIDTH:
246252
hid_map_usage(hi, usage, bit, max,
247253
EV_ABS, ABS_MT_TOUCH_MAJOR);
248254
set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
249255
cls->sn_width);
250256
td->last_slot_field = usage->hid;
257+
td->last_field_index = field->index;
251258
return 1;
252259
case HID_DG_HEIGHT:
253260
hid_map_usage(hi, usage, bit, max,
@@ -257,6 +264,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
257264
input_set_abs_params(hi->input,
258265
ABS_MT_ORIENTATION, 0, 1, 0, 0);
259266
td->last_slot_field = usage->hid;
267+
td->last_field_index = field->index;
260268
return 1;
261269
case HID_DG_TIPPRESSURE:
262270
if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
@@ -269,13 +277,15 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
269277
set_abs(hi->input, ABS_PRESSURE, field,
270278
cls->sn_pressure);
271279
td->last_slot_field = usage->hid;
280+
td->last_field_index = field->index;
272281
return 1;
273282
case HID_DG_CONTACTCOUNT:
274-
td->last_field_index = field->report->maxfield - 1;
283+
td->last_field_index = field->index;
275284
return 1;
276285
case HID_DG_CONTACTMAX:
277286
/* we don't set td->last_slot_field as contactcount and
278287
* contact max are global to the report */
288+
td->last_field_index = field->index;
279289
return -1;
280290
}
281291
/* let hid-input decide for the others */
@@ -424,23 +434,12 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
424434
break;
425435

426436
default:
427-
if (td->last_field_index
428-
&& field->index == td->last_field_index)
429-
/* we reach here when the last field in the
430-
* report is not related to multitouch.
431-
* This is not good. As a temporary solution,
432-
* we trigger our mt event completion and
433-
* ignore the field.
434-
*/
435-
break;
436437
/* fallback to the generic hidinput handling */
437438
return 0;
438439
}
439440

440441
if (usage->hid == td->last_slot_field) {
441442
mt_complete_slot(td);
442-
if (!td->last_field_index)
443-
mt_emit_event(td, field->hidinput->input);
444443
}
445444

446445
if (field->index == td->last_field_index

0 commit comments

Comments
 (0)