diff --git a/src/wscons.c b/src/wscons.c index 260c8251..572a6422 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 2124eb21..34ae15de 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;