From e3842046742e3d01b0a4a292b9c64f5156e49612 Mon Sep 17 00:00:00 2001 From: cipharius Date: Tue, 26 Sep 2023 01:52:46 +0300 Subject: [PATCH] Keeps track of each multi-touch coordinate state Apparently evdev MT events out of laziness might update only one of coordinates on multi-touch slot update, thus causing residual coordinate from last parsed touch leak into the partially updated touch event. --- src/platform/evdev/event.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/platform/evdev/event.c b/src/platform/evdev/event.c index 54852c55a..78bedf5d0 100644 --- a/src/platform/evdev/event.c +++ b/src/platform/evdev/event.c @@ -123,6 +123,8 @@ static const char* envopts[] = { */ #define MAX_DEVICES 256 +#define MAX_MT_SLOTS 5 + struct devnode; #include "device_db.h" @@ -199,8 +201,8 @@ struct devnode { struct { bool active; bool pending; - int x; - int y; + int x[MAX_MT_SLOTS]; + int y[MAX_MT_SLOTS]; int pressure; int size; int ind; @@ -1588,8 +1590,8 @@ static void flush_pending( verbose_print("kind=touch:device=%d:base=%d", node->devnum, node->touch.ind); newev.io.input.touch.active = node->touch.active; - newev.io.input.touch.x = node->touch.x; - newev.io.input.touch.y = node->touch.y; + newev.io.input.touch.x = node->touch.x[MIN(MAX_MT_SLOTS-1, node->touch.ind)]; + newev.io.input.touch.y = node->touch.y[MIN(MAX_MT_SLOTS-1, node->touch.ind)]; newev.io.input.touch.pressure = node->touch.pressure; newev.io.input.touch.size = node->touch.size; @@ -1612,7 +1614,7 @@ static void decode_mt(struct arcan_evctx* ctx, flush_pending(ctx, node); node->touch.ind = 0; - node->touch.x = val; + node->touch.x[0] = val; node->touch.pending = true; break; case ABS_Y: @@ -1620,18 +1622,18 @@ static void decode_mt(struct arcan_evctx* ctx, flush_pending(ctx, node); node->touch.ind = 0; - node->touch.y = val; + node->touch.y[0] = val; node->touch.pending = true; break; case ABS_MT_PRESSURE: node->touch.pressure = val; break; case ABS_MT_POSITION_X: - node->touch.x = val; + node->touch.x[MIN(MAX_MT_SLOTS-1, node->touch.ind)] = val; node->touch.pending = true; break; case ABS_MT_POSITION_Y: - node->touch.y = val; + node->touch.y[MIN(MAX_MT_SLOTS-1, node->touch.ind)] = val; node->touch.pending = true; break; case ABS_DISTANCE: