From c23c6bb99615658600376a5f88cd646d986638a4 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Mon, 18 Sep 2023 12:06:45 +0200 Subject: [PATCH] Interactive tools: always print keycode --- tools/tools-common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/tools-common.c b/tools/tools-common.c index a94466c..3403ea6 100644 --- a/tools/tools-common.c +++ b/tools/tools-common.c @@ -50,6 +50,17 @@ #include "tools-common.h" +static void +print_keycode(struct xkb_keymap *keymap, const char* prefix, + xkb_keycode_t keycode, const char *suffix) { + const char *keyname = xkb_keymap_key_get_name(keymap, keycode); + if (keyname) { + printf("%s%-4s%s", prefix, keyname, suffix); + } else { + printf("%s%-4d%s", prefix, keycode, suffix); + } +} + void tools_print_keycode_state(struct xkb_state *state, struct xkb_compose_state *compose_state, @@ -89,6 +100,8 @@ tools_print_keycode_state(struct xkb_state *state, syms = &sym; } + print_keycode(keymap, "keycode [ ", keycode, " ] "); + printf("keysyms [ "); for (int i = 0; i < nsyms; i++) { xkb_keysym_get_name(syms[i], s, sizeof(s)); -- 2.7.4