Skip to content

Commit df03e9b

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Ignore the confidence flag when a touch is removed
AES hardware may internally re-classify a contact that it thought was intentional as a palm. Intentional contacts are reported as "down" with the confidence bit set. When this re-classification occurs, however, the state transitions to "up" with the confidence bit cleared. This kind of transition appears to be legal according to Microsoft docs, but we do not handle it correctly. Because the confidence bit is clear, we don't call `wacom_wac_finger_slot` and update userspace. This causes hung touches that confuse userspace and interfere with pen arbitration. This commit adds a special case to ignore the confidence flag if a contact is reported as removed. This ensures we do not leave a hung touch if one of these re-classification events occured. Ideally we'd have some way to also let userspace know that the touch has been re-classified as a palm and needs to be canceled, but that's not possible right now :) Link: linuxwacom/input-wacom#288 Fixes: 7fb0413 (HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts) CC: stable@vger.kernel.org Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Ping Cheng <ping.cheng@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 546e41a commit df03e9b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

drivers/hid/wacom_wac.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,24 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
25882588
}
25892589
}
25902590

2591+
static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2592+
{
2593+
struct input_mt *mt = dev->mt;
2594+
struct input_mt_slot *s;
2595+
2596+
if (!mt)
2597+
return false;
2598+
2599+
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2600+
if (s->key == key &&
2601+
input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2602+
return true;
2603+
}
2604+
}
2605+
2606+
return false;
2607+
}
2608+
25912609
static void wacom_wac_finger_event(struct hid_device *hdev,
25922610
struct hid_field *field, struct hid_usage *usage, __s32 value)
25932611
{
@@ -2638,9 +2656,14 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
26382656
}
26392657

26402658
if (usage->usage_index + 1 == field->report_count) {
2641-
if (equivalent_usage == wacom_wac->hid_data.last_slot_field &&
2642-
wacom_wac->hid_data.confidence)
2643-
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2659+
if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2660+
bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2661+
wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2662+
2663+
if (wacom_wac->hid_data.confidence || touch_removed) {
2664+
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2665+
}
2666+
}
26442667
}
26452668
}
26462669

0 commit comments

Comments
 (0)