Skip to content

Commit 5022960

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Correct behavior when processing some confidence == false touches
There appear to be a few different ways that Wacom devices can deal with confidence: 1. If the device looses confidence in a touch, it will first clear the tipswitch flag in one report, and then clear the confidence flag in a second report. This behavior is used by e.g. DTH-2452. 2. If the device looses confidence in a touch, it will clear both the tipswitch and confidence flags within the same report. This behavior is used by some AES devices. 3. If the device looses confidence in a touch, it will clear *only* the confidence bit. The tipswitch bit will remain set so long as the touch is tracked. This behavior may be used in future devices. The driver does not currently handle situation 3 properly. Touches that loose confidence will remain "in prox" and essentially frozen in place until the tipswitch bit is finally cleared. Not only does this result in userspace seeing a stuck touch, but it also prevents pen arbitration from working properly (the pen won't send events until all touches are up, but we don't currently process events from non-confident touches). This commit centralizes the checking of the confidence bit in the wacom_wac_finger_slot() function and has 'prox' depend on it. In the case where situation 3 is encountered, the treat the touch as though it was removed, allowing both userspace and the pen arbitration to act normally. Signed-off-by: Tatsunosuke Tobita <[email protected]> Signed-off-by: Ping Cheng <[email protected]> Signed-off-by: Jason Gerecke <[email protected]> Fixes: 7fb0413 ("HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts") Cc: [email protected] Signed-off-by: Jiri Kosina <[email protected]>
1 parent fd2a9b2 commit 5022960

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

drivers/hid/wacom_wac.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,8 +2659,8 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
26592659
{
26602660
struct hid_data *hid_data = &wacom_wac->hid_data;
26612661
bool mt = wacom_wac->features.touch_max > 1;
2662-
bool prox = hid_data->tipswitch &&
2663-
report_touch_events(wacom_wac);
2662+
bool touch_down = hid_data->tipswitch && hid_data->confidence;
2663+
bool prox = touch_down && report_touch_events(wacom_wac);
26642664

26652665
if (touch_is_muted(wacom_wac)) {
26662666
if (!wacom_wac->shared->touch_down)
@@ -2710,24 +2710,6 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
27102710
}
27112711
}
27122712

2713-
static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2714-
{
2715-
struct input_mt *mt = dev->mt;
2716-
struct input_mt_slot *s;
2717-
2718-
if (!mt)
2719-
return false;
2720-
2721-
for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2722-
if (s->key == key &&
2723-
input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2724-
return true;
2725-
}
2726-
}
2727-
2728-
return false;
2729-
}
2730-
27312713
static void wacom_wac_finger_event(struct hid_device *hdev,
27322714
struct hid_field *field, struct hid_usage *usage, __s32 value)
27332715
{
@@ -2778,14 +2760,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
27782760
}
27792761

27802762
if (usage->usage_index + 1 == field->report_count) {
2781-
if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2782-
bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2783-
wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2784-
2785-
if (wacom_wac->hid_data.confidence || touch_removed) {
2786-
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2787-
}
2788-
}
2763+
if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
2764+
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
27892765
}
27902766
}
27912767

0 commit comments

Comments
 (0)