}
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");
}
&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);
OPT_SCROLL_BUTTON,
OPT_SPEED,
OPT_PROFILE,
+ OPT_SHOW_KEYCODES,
};
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
"--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"
options->seat = "seat0";
options->speed = 0.0;
options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
+ options->show_keycodes = false;
}
int
{ "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}
};
return 1;
}
break;
+ case OPT_SHOW_KEYCODES:
+ options->show_keycodes = true;
+ break;
default:
tools_usage();
return 1;
#ifndef _SHARED_H_
#define _SHARED_H_
+#include <stdbool.h>
+
#include <libinput.h>
enum tools_backend {
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;