From 7c9fb7bf2956a0664ed64335d5caceef1048a914 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 30 Dec 2011 22:00:07 +0200 Subject: [PATCH] input: don't use 0 to signal lack of unicode value 0 is actually a valid unicode value, so instead we use KMSCON_INPUT_INVALID which is not legal unicode. Signed-off-by: Ran Benita Signed-off-by: David Herrmann --- src/input.h | 4 +++- src/input_xkb.c | 3 +++ tests/test_input.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/input.h b/src/input.h index 825904a..f1fdf72 100644 --- a/src/input.h +++ b/src/input.h @@ -54,11 +54,13 @@ struct kmscon_input; +#define KMSCON_INPUT_INVALID 0xffffffff + struct kmscon_input_event { uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */ uint32_t keysym; /* X keysym - XK_* - X11/keysym.h */ uint8_t modifiers; /* xkbcommon modifiers - XKB_COMMON_*_MASK */ - uint32_t unicode; /* UCS-4 unicode value, 0 if none */ + uint32_t unicode; /* UCS-4 unicode value or KMSCON_INPUT_INVALID */ }; typedef void (*kmscon_input_cb) (struct kmscon_input *input, diff --git a/src/input_xkb.c b/src/input_xkb.c index 9eddc31..8a28c4a 100644 --- a/src/input_xkb.c +++ b/src/input_xkb.c @@ -704,6 +704,9 @@ bool kmscon_xkb_process_evdev_key(struct xkb_desc *desc, out->modifiers = state->mods; out->unicode = KeysymToUcs4(sym); + if (out->unicode == 0) + out->unicode = KMSCON_INPUT_INVALID; + event_filled = true; } diff --git a/tests/test_input.c b/tests/test_input.c index f5523ac..3bda398 100644 --- a/tests/test_input.c +++ b/tests/test_input.c @@ -90,7 +90,7 @@ static void input_arrived(struct kmscon_input *input, char s[16]; char utf8[MB_CUR_MAX + 1]; - if (ev->unicode == 0) { + if (ev->unicode == KMSCON_INPUT_INVALID) { xkb_keysym_to_string(ev->keysym, s, sizeof(s)); printf("sym %s ", s); } else {