diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2014-08-05 10:40:46 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-08-05 08:48:39 -0400 |
commit | 4d541b260834db4b610cc6a3c0a0cc2d9ca4282f (patch) | |
tree | 6e2aa5f56dd8753bbe619f2e351bfc0801ee7db3 /src/udev | |
parent | d9a9899974109af8216c879c3c26c31c2f5cb86b (diff) |
udev-builtin-keyboard: Allow numeric key codes
Like with the old udev rules, allow hwdb entries to specify numeric key codes.
Based on a patch from Mircea Miron.
https://launchpad.net/bugs/1247584
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udev-builtin-keyboard.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 9b66bfd0ac..d6b7dbbac0 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -78,7 +78,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) { const char *key; - unsigned int scancode; + unsigned int scancode, keycode_num; char *endptr; const char *keycode; const struct key *k; @@ -110,13 +110,19 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo /* translate identifier to key code */ k = keyboard_lookup_key(keycode, strlen(keycode)); - if (!k) { - log_error("Error, unknown key identifier '%s'", keycode); - continue; + if (k) { + keycode_num = k->id; + } else { + /* check if it's a numeric code already */ + keycode_num = strtoul(keycode, &endptr, 0); + if (endptr[0] !='\0') { + log_error("Error, unknown key identifier '%s'", keycode); + continue; + } } map[map_count].scan = scancode; - map[map_count].key = k->id; + map[map_count].key = keycode_num; if (map_count < ELEMENTSOF(map)-1) map_count++; } |