summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/event-debug.c19
-rw-r--r--tools/shared.c7
-rw-r--r--tools/shared.h3
3 files changed, 25 insertions, 4 deletions
diff --git a/tools/event-debug.c b/tools/event-debug.c
index 779b54a..9022e39 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -267,20 +267,31 @@ print_device_notify(struct libinput_event *ev)
}
static void
-print_key_event(struct libinput_event *ev)
+print_key_event(struct libinput *li, struct libinput_event *ev)
{
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(ev);
+ struct tools_context *context;
+ struct tools_options *options;
enum libinput_key_state state;
uint32_t key;
const char *keyname;
+ context = libinput_get_user_data(li);
+ options = &context->options;
+
print_event_time(libinput_event_keyboard_get_time(k));
state = libinput_event_keyboard_get_key_state(k);
key = libinput_event_keyboard_get_key(k);
- keyname = libevdev_event_code_get_name(EV_KEY, key);
+ if (!options->show_keycodes &&
+ (key >= KEY_ESC && key < KEY_ZENKAKUHANKAKU)) {
+ keyname = "***";
+ } else {
+ keyname = libevdev_event_code_get_name(EV_KEY, key);
+ keyname = keyname ? keyname : "???";
+ }
printf("%s (%d) %s\n",
- keyname ? keyname : "???",
+ keyname,
key,
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
}
@@ -754,7 +765,7 @@ handle_and_print_events(struct libinput *li)
&context.options);
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:
- print_key_event(ev);
+ print_key_event(li, ev);
break;
case LIBINPUT_EVENT_POINTER_MOTION:
print_motion_event(ev);
diff --git a/tools/shared.c b/tools/shared.c
index 05fb118..1019184 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -62,6 +62,7 @@ enum options {
OPT_SCROLL_BUTTON,
OPT_SPEED,
OPT_PROFILE,
+ OPT_SHOW_KEYCODES,
};
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
@@ -103,6 +104,7 @@ tools_usage(void)
"--set-profile=[adaptive|flat].... set pointer acceleration profile\n"
"--set-speed=<value>.... set pointer acceleration speed (allowed range [-1, 1]) \n"
"--set-tap-map=[lrm|lmr] ... set button mapping for tapping\n"
+ "--show-keycodes.... show all key codes while typing\n"
"\n"
"These options apply to all applicable devices, if a feature\n"
"is not explicitly specified it is left at each device's default.\n"
@@ -137,6 +139,7 @@ tools_init_context(struct tools_context *context)
options->seat = "seat0";
options->speed = 0.0;
options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
+ options->show_keycodes = false;
}
int
@@ -173,6 +176,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
{ "set-profile", 1, 0, OPT_PROFILE },
{ "set-tap-map", 1, 0, OPT_TAP_MAP },
{ "set-speed", 1, 0, OPT_SPEED },
+ { "show-keycodes", 0, 0, OPT_SHOW_KEYCODES },
{ 0, 0, 0, 0}
};
@@ -337,6 +341,9 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
return 1;
}
break;
+ case OPT_SHOW_KEYCODES:
+ options->show_keycodes = true;
+ break;
default:
tools_usage();
return 1;
diff --git a/tools/shared.h b/tools/shared.h
index 17fdf37..9b1a988 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -24,6 +24,8 @@
#ifndef _SHARED_H_
#define _SHARED_H_
+#include <stdbool.h>
+
#include <libinput.h>
enum tools_backend {
@@ -36,6 +38,7 @@ struct tools_options {
const char *device; /* if backend is BACKEND_DEVICE */
const char *seat; /* if backend is BACKEND_UDEV */
int grab; /* EVIOCGRAB */
+ bool show_keycodes; /* show keycodes */
int verbose;
int tapping;