test: rename test/interactive to interactive-evdev
And share the key-printing functions. In preparation for adding more interactive-* variants. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
917c751523
commit
d63e0ab838
|
@ -162,10 +162,10 @@ TESTS += \
|
|||
|
||||
test_keyseq_LDADD = $(TESTS_LDADD)
|
||||
test_state_LDADD = $(TESTS_LDADD)
|
||||
test_interactive_LDADD = $(TESTS_LDADD)
|
||||
test_interactive_evdev_LDADD = $(TESTS_LDADD)
|
||||
|
||||
check_PROGRAMS += \
|
||||
test/interactive
|
||||
test/interactive-evdev
|
||||
|
||||
endif BUILD_LINUX_TESTS
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ stringcomp
|
|||
buffercomp
|
||||
keyseq
|
||||
log
|
||||
interactive
|
||||
interactive-evdev
|
||||
rmlvo-to-kccgst
|
||||
print-compiled-keymap
|
||||
bench-key-proc
|
||||
|
|
102
test/common.c
102
test/common.c
|
@ -339,3 +339,105 @@ test_compile_rules(struct xkb_context *context, const char *rules,
|
|||
|
||||
return keymap;
|
||||
}
|
||||
|
||||
void
|
||||
test_print_keycode_state(struct xkb_state *state, xkb_keycode_t keycode)
|
||||
{
|
||||
struct xkb_keymap *keymap;
|
||||
|
||||
const xkb_keysym_t *syms;
|
||||
int nsyms;
|
||||
char s[16];
|
||||
xkb_layout_index_t layout;
|
||||
|
||||
keymap = xkb_state_get_keymap(state);
|
||||
|
||||
nsyms = xkb_state_key_get_syms(state, keycode, &syms);
|
||||
|
||||
if (nsyms <= 0)
|
||||
return;
|
||||
|
||||
if (nsyms == 1) {
|
||||
xkb_keysym_t sym = xkb_state_key_get_one_sym(state, keycode);
|
||||
xkb_keysym_get_name(sym, s, sizeof(s));
|
||||
printf("keysym [ %-*s ] ", (int) sizeof(s), s);
|
||||
}
|
||||
else {
|
||||
printf("keysyms [ ");
|
||||
for (int i = 0; i < nsyms; i++) {
|
||||
xkb_keysym_get_name(syms[i], s, sizeof(s));
|
||||
printf("%-*s ", (int) sizeof(s), s);
|
||||
}
|
||||
printf("] ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Only do this if wchar_t is UCS-4, so we can be lazy and print
|
||||
* with %lc.
|
||||
*/
|
||||
#ifdef __STDC_ISO_10646__
|
||||
printf("unicode [ ");
|
||||
for (int i = 0; i < nsyms; i++) {
|
||||
uint32_t unicode = xkb_keysym_to_utf32(syms[i]);
|
||||
printf("%lc ", (int)(unicode ? unicode : L' '));
|
||||
}
|
||||
printf("] ");
|
||||
#endif
|
||||
|
||||
layout = xkb_state_key_get_layout(state, keycode);
|
||||
printf("layout [ %s (%d) ] ",
|
||||
xkb_keymap_layout_get_name(keymap, layout), layout);
|
||||
|
||||
printf("level [ %d ] ",
|
||||
xkb_state_key_get_level(state, keycode, layout));
|
||||
|
||||
printf("mods [ ");
|
||||
for (xkb_mod_index_t mod = 0; mod < xkb_keymap_num_mods(keymap); mod++) {
|
||||
if (xkb_state_mod_index_is_active(state, mod,
|
||||
XKB_STATE_MODS_EFFECTIVE) <= 0)
|
||||
continue;
|
||||
if (xkb_state_mod_index_is_consumed(state, keycode, mod))
|
||||
printf("-%s ", xkb_keymap_mod_get_name(keymap, mod));
|
||||
else
|
||||
printf("%s ", xkb_keymap_mod_get_name(keymap, mod));
|
||||
}
|
||||
printf("] ");
|
||||
|
||||
printf("leds [ ");
|
||||
for (xkb_led_index_t led = 0; led < xkb_keymap_num_leds(keymap); led++) {
|
||||
if (xkb_state_led_index_is_active(state, led) <= 0)
|
||||
continue;
|
||||
printf("%s ", xkb_keymap_led_get_name(keymap, led));
|
||||
}
|
||||
printf("] ");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
test_print_state_changes(enum xkb_state_component changed)
|
||||
{
|
||||
if (changed == 0)
|
||||
return;
|
||||
|
||||
printf("changed [ ");
|
||||
if (changed & XKB_STATE_LAYOUT_EFFECTIVE)
|
||||
printf("effective-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_DEPRESSED)
|
||||
printf("depressed-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_LATCHED)
|
||||
printf("latched-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_LOCKED)
|
||||
printf("locked-layout ");
|
||||
if (changed & XKB_STATE_MODS_EFFECTIVE)
|
||||
printf("effective-mods ");
|
||||
if (changed & XKB_STATE_MODS_DEPRESSED)
|
||||
printf("depressed-mods ");
|
||||
if (changed & XKB_STATE_MODS_LATCHED)
|
||||
printf("latched-mods ");
|
||||
if (changed & XKB_STATE_MODS_LOCKED)
|
||||
printf("locked-mods ");
|
||||
if (changed & XKB_STATE_LEDS)
|
||||
printf("leds ");
|
||||
printf("]\n");
|
||||
}
|
||||
|
|
|
@ -213,110 +213,6 @@ free_keyboards(struct keyboard *kbds)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_keycode(struct keyboard *kbd, xkb_keycode_t keycode)
|
||||
{
|
||||
struct xkb_keymap *keymap;
|
||||
struct xkb_state *state;
|
||||
|
||||
const xkb_keysym_t *syms;
|
||||
int nsyms;
|
||||
char s[16];
|
||||
xkb_layout_index_t layout;
|
||||
|
||||
state = kbd->state;
|
||||
keymap = xkb_state_get_keymap(state);
|
||||
|
||||
nsyms = xkb_state_key_get_syms(state, keycode, &syms);
|
||||
|
||||
if (nsyms <= 0)
|
||||
return;
|
||||
|
||||
if (nsyms == 1) {
|
||||
xkb_keysym_t sym = xkb_state_key_get_one_sym(state, keycode);
|
||||
xkb_keysym_get_name(sym, s, sizeof(s));
|
||||
printf("keysym [ %-*s ] ", (int) sizeof(s), s);
|
||||
}
|
||||
else {
|
||||
printf("keysyms [ ");
|
||||
for (int i = 0; i < nsyms; i++) {
|
||||
xkb_keysym_get_name(syms[i], s, sizeof(s));
|
||||
printf("%-*s ", (int) sizeof(s), s);
|
||||
}
|
||||
printf("] ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Only do this if wchar_t is UCS-4, so we can be lazy and print
|
||||
* with %lc.
|
||||
*/
|
||||
#ifdef __STDC_ISO_10646__
|
||||
printf("unicode [ ");
|
||||
for (int i = 0; i < nsyms; i++) {
|
||||
uint32_t unicode = xkb_keysym_to_utf32(syms[i]);
|
||||
printf("%lc ", (int)(unicode ? unicode : L' '));
|
||||
}
|
||||
printf("] ");
|
||||
#endif
|
||||
|
||||
layout = xkb_state_key_get_layout(state, keycode);
|
||||
printf("layout [ %s (%d) ] ",
|
||||
xkb_keymap_layout_get_name(keymap, layout), layout);
|
||||
|
||||
printf("level [ %d ] ",
|
||||
xkb_state_key_get_level(state, keycode, layout));
|
||||
|
||||
printf("mods [ ");
|
||||
for (xkb_mod_index_t mod = 0; mod < xkb_keymap_num_mods(keymap); mod++) {
|
||||
if (xkb_state_mod_index_is_active(state, mod,
|
||||
XKB_STATE_MODS_EFFECTIVE) <= 0)
|
||||
continue;
|
||||
if (xkb_state_mod_index_is_consumed(state, keycode, mod))
|
||||
printf("-%s ", xkb_keymap_mod_get_name(keymap, mod));
|
||||
else
|
||||
printf("%s ", xkb_keymap_mod_get_name(keymap, mod));
|
||||
}
|
||||
printf("] ");
|
||||
|
||||
printf("leds [ ");
|
||||
for (xkb_led_index_t led = 0; led < xkb_keymap_num_leds(keymap); led++) {
|
||||
if (xkb_state_led_index_is_active(state, led) <= 0)
|
||||
continue;
|
||||
printf("%s ", xkb_keymap_led_get_name(keymap, led));
|
||||
}
|
||||
printf("] ");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_state_changes(enum xkb_state_component changed)
|
||||
{
|
||||
if (changed == 0)
|
||||
return;
|
||||
|
||||
printf("changed [ ");
|
||||
if (changed & XKB_STATE_LAYOUT_EFFECTIVE)
|
||||
printf("effective-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_DEPRESSED)
|
||||
printf("depressed-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_LATCHED)
|
||||
printf("latched-layout ");
|
||||
if (changed & XKB_STATE_LAYOUT_LOCKED)
|
||||
printf("locked-layout ");
|
||||
if (changed & XKB_STATE_MODS_EFFECTIVE)
|
||||
printf("effective-mods ");
|
||||
if (changed & XKB_STATE_MODS_DEPRESSED)
|
||||
printf("depressed-mods ");
|
||||
if (changed & XKB_STATE_MODS_LATCHED)
|
||||
printf("latched-mods ");
|
||||
if (changed & XKB_STATE_MODS_LOCKED)
|
||||
printf("locked-mods ");
|
||||
if (changed & XKB_STATE_LEDS)
|
||||
printf("leds ");
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
/* The meaning of the input_event 'value' field. */
|
||||
enum {
|
||||
KEY_STATE_RELEASE = 0,
|
||||
|
@ -341,7 +237,7 @@ process_event(struct keyboard *kbd, uint16_t type, uint16_t code, int32_t value)
|
|||
return;
|
||||
|
||||
if (value != KEY_STATE_RELEASE)
|
||||
print_keycode(kbd, keycode);
|
||||
test_print_keycode_state(kbd->state, keycode);
|
||||
|
||||
if (value == KEY_STATE_RELEASE)
|
||||
changed = xkb_state_update_key(kbd->state, keycode, XKB_KEY_UP);
|
||||
|
@ -349,7 +245,7 @@ process_event(struct keyboard *kbd, uint16_t type, uint16_t code, int32_t value)
|
|||
changed = xkb_state_update_key(kbd->state, keycode, XKB_KEY_DOWN);
|
||||
|
||||
if (report_state_changes)
|
||||
print_state_changes(changed);
|
||||
test_print_state_changes(changed);
|
||||
}
|
||||
|
||||
static int
|
|
@ -76,3 +76,9 @@ struct xkb_keymap *
|
|||
test_compile_rules(struct xkb_context *context, const char *rules,
|
||||
const char *model, const char *layout, const char *variant,
|
||||
const char *options);
|
||||
|
||||
void
|
||||
test_print_keycode_state(struct xkb_state *state, xkb_keycode_t keycode);
|
||||
|
||||
void
|
||||
test_print_state_changes(enum xkb_state_component changed);
|
||||
|
|
Loading…
Reference in New Issue