From 84c3fe7ba6dd38a127bd7002f0a348f0193951fd Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 18 Jan 2012 00:14:16 +0200 Subject: [PATCH] test_input: simplify and drop xkbcommon dependency Signed-off-by: Ran Benita --- Makefile.am | 7 +------ tests/test_input.c | 19 ++++--------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/Makefile.am b/Makefile.am index 63987f0..02ac51f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -102,11 +102,6 @@ test_terminal_SOURCES = tests/test_terminal.c test_terminal_LDADD = libkmscon-core.la test_input_SOURCES = tests/test_input.c -test_input_LDADD = \ - libkmscon-core.la \ - $(XKBCOMMON_LIBS) -test_input_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(XKBCOMMON_CFLAGS) +test_input_LDADD = libkmscon-core.la EXTRA_DIST = README TODO COPYING diff --git a/tests/test_input.c b/tests/test_input.c index 0d349cc..a4500b2 100644 --- a/tests/test_input.c +++ b/tests/test_input.c @@ -32,13 +32,12 @@ #include #include #include -#include -#include #include #include "eloop.h" #include "input.h" +#include "kbd.h" #include "log.h" static bool terminate; @@ -86,27 +85,17 @@ static void print_modifiers(unsigned int mods) static void input_arrived(struct kmscon_input *input, struct kmscon_input_event *ev, void *data) { - int len; char s[16]; - char utf8[MB_CUR_MAX + 1]; if (ev->unicode == KMSCON_INPUT_INVALID) { - xkb_keysym_to_string(ev->keysym, s, sizeof(s)); + kmscon_kbd_keysym_to_string(ev->keysym, s, sizeof(s)); printf("sym %s ", s); } else { /* * Just a proof-of-concept hack. This works because glibc uses * UTF-32 (= UCS-4) as the internal wchar_t encoding. */ - len = wctomb(utf8, (wchar_t)ev->unicode); - if (len <= 0) { - log_info("Bad unicode char\n"); - return; - } else { - utf8[len] = '\0'; - } - - printf("utf8 %s ", utf8); + printf("unicode %lc ", ev->unicode); } print_modifiers(ev->mods); } @@ -118,7 +107,7 @@ int main(int argc, char **argv) struct kmscon_input *input; struct kmscon_signal *sigint, *sigquit; - if (!setlocale(LC_ALL, "en_US.UTF-8")) { + if (!setlocale(LC_ALL, "")) { log_err("Cannot set locale: %m\n"); ret = -EFAULT; goto err_out;