touchpad: handle serial synaptics slot confusion on TRIPLETAP
Synatics touchpads only have 2 slots, but support TRIPLETAP and above. When
the third finger touches, the kernel may end the second slot and re-start it
with the coordinates of the third touch in the next frame. The event sequence
is something like:
ABS_MT_SLOT 0
ABS_MT_POSITION_X 4000
ABS_MT_POSITION_Y 4000
ABS_MT_PRESSURE 78
ABS_MT_SLOT 1
ABS_MT_TRACKING_ID -1
ABS_X 4000
ABS_Y 4000
ABS_PRESSURE 78
BTN_TOOL_DOUBLETAP 0
BTN_TOOL_TRIPLETAP 1
--- SYN_REPORT (0) ----------
ABS_MT_SLOT 0
ABS_MT_POSITION_X 4000
ABS_MT_POSITION_Y 4000
ABS_MT_PRESSURE 78
ABS_MT_SLOT 1
ABS_MT_TRACKING_ID 55
ABS_MT_POSITION_X 2000
ABS_MT_POSITION_Y 2000
ABS_MT_PRESSURE 72
ABS_X 4000
ABS_Y 4000
ABS_PRESSURE 78
--- SYN_REPORT (0) ----------
libinput usually ignores any BTN_TOOL_* <= num_slots since we expect
that the slot values are valid. Make an exception for the serial synaptics
touchpads. If a touch has ended when the fake touch goes above active-slots
(but still within num-slots), move that touch back to UPDATE. This ensures the
right number of nfingers_down. When the touch restarts again in the next
frame, tp_begin_touch() will skip over re-initializing it because it's already
in UPDATE anyway.
Note that at this point this only handles the transition _to_ TRIPLETAP, not
from TRIPLETAP to DOUBLETAP. Need to wait for this to be seen in the wild
first.
https://bugs.freedesktop.org/show_bug.cgi?id=91352
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Hallelujah-expressed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>