From c6dce245735076ae2eb09aaca946e226f722581c Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Wed, 7 Jun 2017 15:28:18 +0200 Subject: [PATCH] hwdb: support pressing buttons on a keyboard Support BTN_* codes with btn_ prefix and keys with KEY_ prefix optionally removed. --- hwdb/60-keyboard.hwdb | 2 ++ hwdb/parse_hwdb.py | 4 +++- src/udev/generate-keyboard-keys-gperf.sh | 1 + src/udev/generate-keyboard-keys-list.sh | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hwdb/60-keyboard.hwdb b/hwdb/60-keyboard.hwdb index e8be567..43cb23d 100644 --- a/hwdb/60-keyboard.hwdb +++ b/hwdb/60-keyboard.hwdb @@ -58,6 +58,8 @@ # KEYBOARD_KEY_= # The scan code should be expressed in hex lowercase. The key codes # are retrieved and normalized from the kernel input API header. +# Keycodes are either KEY_* defines in lowercase with the key_ prefix +# optionally removed or BTN_ defines in lowercase with btn_ preserved. # # An '!' as the first character of the key identifier string # will add the scan code to the AT keyboard's list of scan codes diff --git a/hwdb/parse_hwdb.py b/hwdb/parse_hwdb.py index 23809a9..c7b49b8 100755 --- a/hwdb/parse_hwdb.py +++ b/hwdb/parse_hwdb.py @@ -172,7 +172,9 @@ def check_one_keycode(prop, value): if value != '!' and ecodes is not None: key = 'KEY_' + value.upper() if key not in ecodes: - error('Keycode {} unknown', key) + key = value.upper() + if key not in ecodes: + error('Keycode {} unknown', key) def check_properties(groups): grammar = property_grammar() diff --git a/src/udev/generate-keyboard-keys-gperf.sh b/src/udev/generate-keyboard-keys-gperf.sh index 36ce0bd..5724e4e 100755 --- a/src/udev/generate-keyboard-keys-gperf.sh +++ b/src/udev/generate-keyboard-keys-gperf.sh @@ -6,4 +6,5 @@ awk ' BEGIN { } /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } + { print tolower($1) ", " $1 } ' < "$1" diff --git a/src/udev/generate-keyboard-keys-list.sh b/src/udev/generate-keyboard-keys-list.sh index 479e493..83bf4a9 100755 --- a/src/udev/generate-keyboard-keys-list.sh +++ b/src/udev/generate-keyboard-keys-list.sh @@ -1,4 +1,4 @@ #!/bin/sh -eu $1 -dM -include linux/input.h -