summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-09-27 20:44:16 +0200
committerRan Benita <ran234@gmail.com>2012-09-27 21:12:08 +0200
commit984ebf983852a66578e933521927beaa364d39ff (patch)
treead6d3dd068a809b0c8955b20d3d2ba8f054f4a7e /test
parent41a7fed3f8a4034ee6b57601d183ced86cbac32b (diff)
test/interactive: allow to set evdev offset
If we want to test a keymap without the usual 8 offset. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/interactive.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/interactive.c b/test/interactive.c
index 3d91dc6..66fffc9 100644
--- a/test/interactive.c
+++ b/test/interactive.c
@@ -44,7 +44,8 @@ struct keyboard {
struct keyboard *next;
};
-bool terminate;
+static bool terminate;
+static int evdev_offset = 8;
#define NLONGS(n) (((n) + LONG_BIT - 1) / LONG_BIT)
@@ -290,8 +291,6 @@ enum {
KEY_STATE_REPEAT = 2,
};
-#define EVDEV_OFFSET 8
-
static void
process_event(struct keyboard *kbd, uint16_t type, uint16_t code, int32_t value)
{
@@ -301,7 +300,7 @@ process_event(struct keyboard *kbd, uint16_t type, uint16_t code, int32_t value)
if (type != EV_KEY)
return;
- keycode = EVDEV_OFFSET + code;
+ keycode = evdev_offset + code;
keymap = xkb_state_get_keymap(kbd->state);
if (value == KEY_STATE_REPEAT && !xkb_keymap_key_repeats(keymap, keycode))
@@ -421,7 +420,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
- while ((opt = getopt(argc, argv, "r:m:l:v:o:k:")) != -1) {
+ while ((opt = getopt(argc, argv, "r:m:l:v:o:k:n:")) != -1) {
switch (opt) {
case 'r':
rules = optarg;
@@ -441,12 +440,21 @@ main(int argc, char *argv[])
case 'k':
keymap_path = optarg;
break;
+ case 'n':
+ errno = 0;
+ evdev_offset = strtol(optarg, NULL, 10);
+ if (errno) {
+ fprintf(stderr, "error: -n option expects a number\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
case '?':
fprintf(stderr, "Usage: %s [-r <rules>] [-m <model>] "
"[-l <layout>] [-v <variant>] [-o <options>]\n",
argv[0]);
fprintf(stderr, " or: %s -k <path to keymap file>\n",
argv[0]);
+ fprintf(stderr, "For both: -n <evdev keycode offset>\n");
exit(EX_USAGE);
}
}