Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/wscons.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/wscons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down