History

HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts

The HID descriptor of many of Wacom's touch input devices include a "Confidence" usage that signals if a particular touch collection contains useful data. The driver does not look at this flag, however, which causes even invalid contacts to be reported to userspace. A lucky combination of kernel event filtering and device behavior (specifically: contact ID 0 == invalid, contact ID >0 == valid; and order all data so that all valid contacts are reported before any invalid contacts) spare most devices from any visibly-bad behavior. The DTH-2452 is one example of an unlucky device that misbehaves. It uses ID 0 for both the first valid contact and all invalid contacts. Because we report both the valid and invalid contacts, the kernel reports that contact 0 first goes down (valid) and then goes up (invalid) in every report. This causes ~100 clicks per second simply by touching the screen. This patch inroduces new `confidence` flag in our `hid_data` structure. The value is initially set to `true` at the start of a report and can be set to `false` if an invalid touch usage is seen.

Jason Gerecke committed 5 years ago

Commit 7fb04131 parent 304dd362 files · +8 −1Browse files

Unified · Split

2 files
  1. drivers/hid/wacom_wac.c +7 −1
  2. drivers/hid/wacom_wac.h +1 −0
drivers/hid/wacom_wac.c+7−1
@@ -2603,6 +2603,9 @@ static void wacom_wac_finger_event(struct hid_device *hdev, · 2602 unmodified lines
26032603 return;
26042604
26052605 switch (equivalent_usage) {
2606+ case HID_DG_CONFIDENCE:
2607+ wacom_wac->hid_data.confidence = value;
2608+ break;
26062609 case HID_GD_X:
26072610 wacom_wac->hid_data.x = value;
26082611 break;
@@ -2635,7 +2638,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev, · 26 unmodified lines
26352638 }
26362639
26372640 if (usage->usage_index + 1 == field->report_count) {
2638− if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
2641+ if (equivalent_usage == wacom_wac->hid_data.last_slot_field &&
2642+ wacom_wac->hid_data.confidence)
26392643 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
26402644 }
26412645 }
@@ -2653,6 +2657,8 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, · 11 unmodified lines
26532657
26542658 wacom_wac->is_invalid_bt_frame = false;
26552659
2660+ hid_data->confidence = true;
2661+
26562662 for (i = 0; i < report->maxfield; i++) {
26572663 struct hid_field *field = report->field[i];
26582664 int j;
drivers/hid/wacom_wac.h+1−0
@@ -301,6 +301,7 @@ struct hid_data { · 300 unmodified lines
301301 bool barrelswitch;
302302 bool barrelswitch2;
303303 bool serialhi;
304+ bool confidence;
304305 int x;
305306 int y;
306307 int pressure;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t