From d893fc74d2521da3c5ef8cbe57a3e7c2e6c7c684 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Oct 2024 14:33:05 +1000 Subject: [PATCH] Map some specific high keycodes into the FK20-23 range These mappings have been part of xkeyboard-config for over a decade and the likely reason they were introduced is that the corresponding evdev keycode is > 255. Let's forcibly remap those in the driver here so the rest of the system can switch to the real keycodes instead of having to map them to the whatever X expects. See https://github.com/systemd/systemd/pull/34325/ Part-of: --- src/evdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 6d7d377..584134c 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -282,7 +282,7 @@ EvdevNextInQueue(InputInfoPtr pInfo) void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) { - int code = ev->code + MIN_KEYCODE; + int code = ev->code; EventQueuePtr pQueue; /* Filter all repeated events from device. @@ -290,10 +290,18 @@ EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) if (value == 2) return; + /* keycodes > 256 that have a historical mapping in xkeyboard-config */ + switch (code) { + case KEY_TOUCHPAD_TOGGLE: code = KEY_F21; break; + case KEY_TOUCHPAD_ON: code = KEY_F22; break; + case KEY_TOUCHPAD_OFF: code = KEY_F23; break; + case KEY_MICMUTE: code = KEY_F20; break; + } + if ((pQueue = EvdevNextInQueue(pInfo))) { pQueue->type = EV_QUEUE_KEY; - pQueue->detail.key = code; + pQueue->detail.key = code + MIN_KEYCODE; pQueue->val = value; } }