scripts: update makeheader script for the _EVDEVK keysym defines As of xorgproto commit 5dbb5b76597f [1], the 0x10081XXX keycode range is defined for direct evdev kernel keycode mapping. For example, KEY_MACRO1 (0x290) is mapped to 0x10081290. The format of the #define lines for these keys is stable to allow for parsing: #define XF86XK_FooBar _EVDEVK(0x123) /* optional comment */ Update our script so we detect these new lines. Our keysym generation is a two-step process: makeheader and then makekeys. Replacing the key with its full value in the makeheader script means we don't have to update makekeys to handle the _EVDEVK macro and our header file is fully resolved. [1] https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/23 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
diff --git a/scripts/makeheader b/scripts/makeheader
index 600b565..52d1375 100755
--- a/scripts/makeheader
+++ b/scripts/makeheader
@@ -3,6 +3,9 @@ from __future__ import print_function
import re
import os
+# expected format:
+# #define XF86XK_FooBar _EVDEVK(0x123) /* some optional comment */
+evdev_pattern = re.compile(r'^#define\s+XF86XK_(?P<name>\w+)\s+_EVDEVK\((?P<value>0x[0-9A-Fa-f]+)\)')
prefix = os.environ.get('X11_HEADERS_PREFIX', '/usr')
HEADERS = [
@@ -35,6 +38,14 @@ for path in HEADERS:
if 'XK_Ydiaeresis' in line and '0x100000ee' in line:
continue
+ # Replace the xorgproto _EVDEVK macro with the actual value
+ # 0x10081000 is the base, the evdev hex code is added to that.
+ # We replace to make parsing of the keys later easier.
+ match = re.match(evdev_pattern, line)
+ if match:
+ value = 0x10081000 + int(match.group('value'), 16)
+ line = re.sub(r'_EVDEVK\(0x([0-9A-Fa-f]+)\)', '{:#x}'.format(value), line)
+
line = re.sub(r'#define\s*(\w*)XK_', r'#define XKB_KEY_\1', line)
print(line, end='')