summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--include/xkbcommon/xkbcommon-names.h35
-rw-r--r--test/state.c27
3 files changed, 52 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am
index 0b58c70..5e929d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,7 +30,9 @@ AM_CFLAGS = \
AM_YFLAGS = -d
xkbcommonincludedir = $(includedir)/xkbcommon
-xkbcommoninclude_HEADERS = include/xkbcommon/xkbcommon.h
+xkbcommoninclude_HEADERS = \
+ include/xkbcommon/xkbcommon.h \
+ include/xkbcommon/xkbcommon-names.h
lib_LTLIBRARIES = libxkbcommon.la
libxkbcommon_la_LDFLAGS = -no-undefined
diff --git a/include/xkbcommon/xkbcommon-names.h b/include/xkbcommon/xkbcommon-names.h
new file mode 100644
index 0000000..45e9df5
--- /dev/null
+++ b/include/xkbcommon/xkbcommon-names.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ */
+
+#ifndef _XKBCOMMON_NAMES_H
+#define _XKBCOMMON_NAMES_H
+
+#define XKB_MOD_NAME_SHIFT "Shift"
+#define XKB_MOD_NAME_CAPS "Caps Lock"
+#define XKB_MOD_NAME_CTRL "Control"
+#define XKB_MOD_NAME_ALT "Mod1"
+#define XKB_MOD_NAME_LOGO "Mod4"
+
+#endif
diff --git a/test/state.c b/test/state.c
index 1d8d138..c081ba6 100644
--- a/test/state.c
+++ b/test/state.c
@@ -30,6 +30,7 @@
#include <linux/input.h>
#include "xkbcommon/xkbcommon.h"
+#include "xkbcommon/xkbcommon-names.h"
#include "xkb-priv.h"
/* Offset between evdev keycodes (where KEY_ESCAPE is 1), and the evdev XKB
@@ -100,30 +101,30 @@ test_update_key(struct xkb_keymap *xkb)
xkb_state_update_key(state, KEY_LEFTCTRL + EVDEV_OFFSET, XKB_KEY_DOWN);
fprintf(stderr, "dumping state for LCtrl down:\n");
print_state(state);
- assert(xkb_state_mod_name_is_active(state, "Control",
+ assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
XKB_STATE_DEPRESSED));
/* LCtrl + RAlt down */
xkb_state_update_key(state, KEY_RIGHTALT + EVDEV_OFFSET, XKB_KEY_DOWN);
fprintf(stderr, "dumping state for LCtrl + RAlt down:\n");
print_state(state);
- assert(xkb_state_mod_name_is_active(state, "Control",
+ assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
XKB_STATE_DEPRESSED));
- assert(xkb_state_mod_name_is_active(state, "Mod1",
+ assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
XKB_STATE_DEPRESSED));
/* RAlt down */
xkb_state_update_key(state, KEY_LEFTCTRL + EVDEV_OFFSET, XKB_KEY_UP);
fprintf(stderr, "dumping state for RAlt down:\n");
print_state(state);
- assert(!xkb_state_mod_name_is_active(state, "Control",
+ assert(!xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
XKB_STATE_EFFECTIVE));
- assert(xkb_state_mod_name_is_active(state, "Mod1",
+ assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
XKB_STATE_DEPRESSED));
/* none down */
xkb_state_update_key(state, KEY_RIGHTALT + EVDEV_OFFSET, XKB_KEY_UP);
- assert(!xkb_state_mod_name_is_active(state, "Mod1",
+ assert(!xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
XKB_STATE_EFFECTIVE));
/* Caps locked */
@@ -131,18 +132,18 @@ test_update_key(struct xkb_keymap *xkb)
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_UP);
fprintf(stderr, "dumping state for Caps Lock:\n");
print_state(state);
- assert(xkb_state_mod_name_is_active(state, "Caps Lock",
+ assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS,
XKB_STATE_LOCKED));
- assert(xkb_state_led_name_is_active(state, "Caps Lock"));
+ assert(xkb_state_led_name_is_active(state, XKB_MOD_NAME_CAPS));
num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms);
assert(num_syms == 1 && syms[0] == XK_Q);
/* Caps unlocked */
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_DOWN);
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_UP);
- assert(!xkb_state_mod_name_is_active(state, "Caps Lock",
+ assert(!xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS,
XKB_STATE_EFFECTIVE));
- assert(!xkb_state_led_name_is_active(state, "Caps Lock"));
+ assert(!xkb_state_led_name_is_active(state, XKB_MOD_NAME_CAPS));
num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms);
assert(num_syms == 1 && syms[0] == XK_q);
@@ -164,11 +165,11 @@ test_serialisation(struct xkb_keymap *xkb)
assert(state);
- caps = xkb_map_mod_get_index(state->xkb, "Caps Lock");
+ caps = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_CAPS);
assert(caps != XKB_MOD_INVALID);
- shift = xkb_map_mod_get_index(state->xkb, "Shift");
+ shift = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_SHIFT);
assert(shift != XKB_MOD_INVALID);
- ctrl = xkb_map_mod_get_index(state->xkb, "Control");
+ ctrl = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_CTRL);
assert(ctrl != XKB_MOD_INVALID);
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_DOWN);