Skip to content

Commit

Permalink
Backport: HID: wacom: Correct behavior when processing some confidenc…
Browse files Browse the repository at this point in the history
…e == 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: 7fb0413baa7f ("HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts")
Cc: [email protected]
Signed-off-by: Jiri Kosina <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
[[email protected]: Imported into input-wacom (502296030ec6)]
Signed-off-by: Tatsunosuke Tobita <[email protected]>
[[email protected]: Backported into input-wacom (ab32e0b)]
Signed-off-by: Tatsunosuke Tobita <[email protected]>
  • Loading branch information
flying-elephant authored Jan 4, 2024
1 parent 4d7449a commit b58f92e
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions 3.17/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2640,8 +2640,8 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
{
struct hid_data *hid_data = &wacom_wac->hid_data;
bool mt = wacom_wac->features.touch_max > 1;
bool prox = hid_data->tipswitch &&
report_touch_events(wacom_wac);
bool touch_down = hid_data->tipswitch && hid_data->confidence;
bool prox = touch_down && report_touch_events(wacom_wac);

if (touch_is_muted(wacom_wac)) {
if (!wacom_wac->shared->touch_down)
Expand Down Expand Up @@ -2691,24 +2691,6 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
}
}

static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
{
struct input_mt *mt = dev->mt;
struct input_mt_slot *s;

if (!mt)
return false;

for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
if (s->key == key &&
input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
return true;
}
}

return false;
}

static void wacom_wac_finger_event(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage, __s32 value)
{
Expand Down Expand Up @@ -2759,14 +2741,8 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
}

if (usage->usage_index + 1 == field->report_count) {
if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;

if (wacom_wac->hid_data.confidence || touch_removed) {
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
}
}
if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
}
}

Expand Down

0 comments on commit b58f92e

Please sign in to comment.