summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2009-07-23 19:00:38 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2009-07-23 19:00:38 +0200
commit0dcf1ce1f76325e88be8b1c6cc356a2123c9a757 (patch)
tree6996db5e9cd30434b52208b67612db626d900bb2 /extras
parent53842b53820a0f0b2b0ff5b28caf01e3f7e26f22 (diff)
extras/keymap: Fix crash for unknown keys
The keymap table has some holes in it, which caused the interactive mode to crash for unknown keys. In these cases, print the numeric key code instead.
Diffstat (limited to 'extras')
-rw-r--r--extras/keymap/keymap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/extras/keymap/keymap.c b/extras/keymap/keymap.c
index 18e577a3a4..117a41dbae 100644
--- a/extras/keymap/keymap.c
+++ b/extras/keymap/keymap.c
@@ -258,15 +258,22 @@ static const char* default_keymap_path(const char* path)
static void print_key(struct input_event *event)
{
static int cur_scancode = 0;
+ const char *keyname;
/* save scan code for next EV_KEY event */
if (event->type == EV_MSC && event->code == MSC_SCAN)
cur_scancode = event->value;
/* key press */
- if (event->type == EV_KEY && event->value)
- printf("scan code: 0x%02X key code: %s\n", cur_scancode,
- format_keyname(key_names[event->code]));
+ if (event->type == EV_KEY && event->value) {
+ keyname = key_names[event->code];
+ if (keyname != NULL)
+ printf("scan code: 0x%02X key code: %s\n", cur_scancode,
+ format_keyname(key_names[event->code]));
+ else
+ printf("scan code: 0x%02X key code: %03X\n", cur_scancode,
+ event->code);
+ }
}
static void interactive(int fd)