tools: add --verbose to interactive-evdev

master
Peter Hutterer 2024-02-14 10:23:15 +10:00 committed by Wismill
parent ed2dc978b1
commit 89ceb3515b
1 changed files with 12 additions and 0 deletions

View File

@ -53,6 +53,7 @@ struct keyboard {
struct keyboard *next; struct keyboard *next;
}; };
static bool verbose = false;
static bool terminate; static bool terminate;
static int evdev_offset = 8; static int evdev_offset = 8;
static bool report_state_changes; static bool report_state_changes;
@ -383,6 +384,7 @@ usage(FILE *fp, char *progname)
fprintf(fp, " or: %s --keymap <path to keymap file>\n", fprintf(fp, " or: %s --keymap <path to keymap file>\n",
progname); progname);
fprintf(fp, "For both:\n" fprintf(fp, "For both:\n"
" --verbose (enable verbose debugging output)\n"
#ifdef ENABLE_PRIVATE_APIS #ifdef ENABLE_PRIVATE_APIS
" --print-modmaps (print real & virtual key modmaps)\n" " --print-modmaps (print real & virtual key modmaps)\n"
#endif #endif
@ -415,6 +417,7 @@ main(int argc, char *argv[])
const char *locale; const char *locale;
struct sigaction act; struct sigaction act;
enum options { enum options {
OPT_VERBOSE,
OPT_INCLUDE, OPT_INCLUDE,
OPT_INCLUDE_DEFAULTS, OPT_INCLUDE_DEFAULTS,
OPT_RULES, OPT_RULES,
@ -434,6 +437,7 @@ main(int argc, char *argv[])
}; };
static struct option opts[] = { static struct option opts[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, OPT_VERBOSE},
{"include", required_argument, 0, OPT_INCLUDE}, {"include", required_argument, 0, OPT_INCLUDE},
{"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS}, {"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS},
{"rules", required_argument, 0, OPT_RULES}, {"rules", required_argument, 0, OPT_RULES},
@ -464,6 +468,9 @@ main(int argc, char *argv[])
break; break;
switch (opt) { switch (opt) {
case OPT_VERBOSE:
verbose = true;
break;
case OPT_INCLUDE: case OPT_INCLUDE:
if (num_includes >= ARRAY_SIZE(includes)) { if (num_includes >= ARRAY_SIZE(includes)) {
fprintf(stderr, "error: too many includes\n"); fprintf(stderr, "error: too many includes\n");
@ -539,6 +546,11 @@ main(int argc, char *argv[])
goto out; goto out;
} }
if (verbose) {
xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
xkb_context_set_log_verbosity(ctx, 10);
}
if (num_includes == 0) if (num_includes == 0)
includes[num_includes++] = DEFAULT_INCLUDE_PATH_PLACEHOLDER; includes[num_includes++] = DEFAULT_INCLUDE_PATH_PLACEHOLDER;