From fbe17f9017e785dd564ce7fc5553a9136d3a0b03 Mon Sep 17 00:00:00 2001 From: Vladimir Kondratyev Date: Wed, 25 Aug 2021 01:45:16 +0300 Subject: [PATCH] evdev: Send first active rather than 0-th slot state as ST report MFC after: 2 weeks --- sys/dev/evdev/evdev_mt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/dev/evdev/evdev_mt.c b/sys/dev/evdev/evdev_mt.c index a28b034884ba..0ededf053f36 100644 --- a/sys/dev/evdev/evdev_mt.c +++ b/sys/dev/evdev/evdev_mt.c @@ -205,20 +205,21 @@ static void evdev_mt_send_st_compat(struct evdev_dev *evdev) { struct evdev_mt *mt = evdev->ev_mt; - int nfingers, i; + int nfingers, i, st_slot; EVDEV_LOCK_ASSERT(evdev); nfingers = bitcount(mt->touches); evdev_send_event(evdev, EV_KEY, BTN_TOUCH, nfingers > 0); - if ((mt->touches & 1U << 0) != 0) - /* Echo 0-th MT-slot as ST-slot */ + /* Send first active MT-slot state as single touch report */ + st_slot = ffs(mt->touches) - 1; + if (st_slot != -1) for (i = 0; i < nitems(evdev_mtstmap); i++) if (bit_test(evdev->ev_abs_flags, evdev_mtstmap[i][1])) evdev_send_event(evdev, EV_ABS, evdev_mtstmap[i][1], - evdev_mt_get_value(evdev, 0, + evdev_mt_get_value(evdev, st_slot, evdev_mtstmap[i][0])); /* Touchscreens should not report tool taps */