diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-04-15 18:20:50 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-04-15 18:20:50 +0200 |
commit | 5737cf1d24c868a55eafc59a51c000dc7f4f63f6 (patch) | |
tree | ef9c8e8fa95723b586fa882b1222e0daac91ad3d /kbdtest.c | |
parent | 168c57b57f2fb4440943d4e672dee4ca34f060b8 (diff) | |
download | fbida-5737cf1d24c868a55eafc59a51c000dc7f4f63f6.tar.gz |
use xkbcommon
Diffstat (limited to 'kbdtest.c')
-rw-r--r-- | kbdtest.c | 56 |
1 files changed, 51 insertions, 5 deletions
@@ -13,17 +13,61 @@ /* ---------------------------------------------------------------------- */ -static const char *keyname[KEY_CNT] = { -#include "KEY.h" +static struct { + uint32_t code; + const char *name; +} xkbname_list[] = { +#include "xkbname.h" }; +const char *xkbname(uint32_t code) +{ + int keycount = sizeof(xkbname_list)/sizeof(xkbname_list[0]); + int i; + + for (i = 0; i < keycount; i++) + if (xkbname_list[i].code == code) + return xkbname_list[i].name; + return "unknown"; +} + +static void usage(FILE *fp) +{ + fprintf(fp, + "\n" + "usage: kbdtest [ options ]\n" + "\n" + "options:\n" + " -h print this text\n" + " -i use libinput\n" + "\n"); +} + int main(int argc, char *argv[]) { uint32_t code, mod; char key[32]; - int rc,i; + bool use_libinput = false; + int rc, i, c; + + for (;;) { + c = getopt(argc, argv, "hi"); + if (c == -1) + break; + switch (c) { + case 'i': + use_libinput = true; + break; + case 'h': + usage(stdout); + exit(0); + default: + usage(stderr); + exit(1); + } + } - kbd_init(0, 0); + kbd_init(use_libinput, 0); for (;;) { kbd_wait(10); @@ -33,12 +77,14 @@ int main(int argc, char *argv[]) /* EOF */ break; } + if (code == XKB_KEY_VoidSymbol) + continue; fprintf(stderr, "key: \""); for (i = 0; key[i] != 0; i++) { fprintf(stderr, "%c", isprint(key[i]) ? key[i] : '.'); } - fprintf(stderr, "\" -> %s", keyname[code]); + fprintf(stderr, "\" -> %s", xkbname(code)); if (mod & KEY_MOD_SHIFT) fprintf(stderr, " +shift"); if (mod & KEY_MOD_CTRL) |