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 <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
Ran Benita 2011-12-30 22:00:07 +02:00 committed by David Herrmann
parent c3912b23a2
commit 7c9fb7bf29
3 changed files with 7 additions and 2 deletions

View File

@ -54,11 +54,13 @@
struct kmscon_input; struct kmscon_input;
#define KMSCON_INPUT_INVALID 0xffffffff
struct kmscon_input_event { struct kmscon_input_event {
uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */ uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */
uint32_t keysym; /* X keysym - XK_* - X11/keysym.h */ uint32_t keysym; /* X keysym - XK_* - X11/keysym.h */
uint8_t modifiers; /* xkbcommon modifiers - XKB_COMMON_*_MASK */ 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, typedef void (*kmscon_input_cb) (struct kmscon_input *input,

View File

@ -704,6 +704,9 @@ bool kmscon_xkb_process_evdev_key(struct xkb_desc *desc,
out->modifiers = state->mods; out->modifiers = state->mods;
out->unicode = KeysymToUcs4(sym); out->unicode = KeysymToUcs4(sym);
if (out->unicode == 0)
out->unicode = KMSCON_INPUT_INVALID;
event_filled = true; event_filled = true;
} }

View File

@ -90,7 +90,7 @@ static void input_arrived(struct kmscon_input *input,
char s[16]; char s[16];
char utf8[MB_CUR_MAX + 1]; 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)); xkb_keysym_to_string(ev->keysym, s, sizeof(s));
printf("sym %s ", s); printf("sym %s ", s);
} else { } else {