From 99e62dcd905edcc3d1e4301eb883b6eae0f44571 Mon Sep 17 00:00:00 2001 From: lamp Date: Thu, 13 Aug 2026 16:29:04 +0100 Subject: [PATCH] wscons: Fix repeat key handling for multiple keys Using a single old_value for repeat suppression fails if several keys are held; releasing one clears the repeat state for _all_ of the keys so the next repeat from another held key is reported as a new press. To fix, track key state for every key instead --- src/wscons.c | 20 ++++++++++++-------- src/wscons.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/wscons.c b/src/wscons.c index 260c82519..572a64229 100644 --- a/src/wscons.c +++ b/src/wscons.c @@ -119,6 +119,7 @@ wscons_process(struct libinput_device *device, struct wscons_event *wsevent) struct wscons_device *dev = wscons_device(device); uint64_t time; uint32_t button; + uint32_t code; int key; keycode_t keycode; @@ -128,19 +129,24 @@ wscons_process(struct libinput_device *device, struct wscons_event *wsevent) case WSCONS_EVENT_KEY_UP: case WSCONS_EVENT_KEY_DOWN: key = wsevent->value; + code = wskey_transcode(dev->scanCodeMap, key); + if (code >= KEY_CNT) + return; + keycode = keycode_from_uint32_t(code); + if (wsevent->type == WSCONS_EVENT_KEY_UP) { kstate = LIBINPUT_KEY_STATE_RELEASED; - dev->old_value = -1; + dev->key_down[code] = 0; } else { kstate = LIBINPUT_KEY_STATE_PRESSED; + /* ignore auto-repeat */ - if (key == dev->old_value) + if (dev->key_down[code]) return; - dev->old_value = key; + + dev->key_down[code] = 1; } - keycode = keycode_from_uint32_t( - wskey_transcode( - wscons_device(device)->scanCodeMap, key)); + keyboard_notify_key(device, time, keycode, kstate); break; @@ -539,8 +545,6 @@ wscons_device_init(struct wscons_device *wscons_device) { struct libinput_device *device = &wscons_device->base; - wscons_device->old_value = -1; - if (strncmp(device->devname, "/dev/wsmouse", 12) == 0) { /* XXX handle tablets and touchpanel */ wscons_device->capability = LIBINPUT_DEVICE_CAP_POINTER; diff --git a/src/wscons.h b/src/wscons.h index 2124eb214..34ae15de3 100644 --- a/src/wscons.h +++ b/src/wscons.h @@ -18,7 +18,7 @@ struct wscons_device { struct libinput_device base; enum libinput_device_capability capability; struct TransMapRec *scanCodeMap; - int old_value; + unsigned char key_down[KEY_CNT]; struct { struct libinput_device_config_accel config; struct motion_filter *filter;