summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-14 14:50:25 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-14 14:50:25 +0200
commit071cc70f0586e7296ed22baafb67149f76e6620a (patch)
tree0146c78213982e03f6d281531c2ee923bbddb9a4 /tools
parent165ba73d1ee88661cac144cda605e1d18d6f5928 (diff)
Change remote to use GtkButtons
Diffstat (limited to 'tools')
-rwxr-xr-xtools/generate-input-keycodes.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/tools/generate-input-keycodes.sh b/tools/generate-input-keycodes.sh
new file mode 100755
index 0000000..96f28ff
--- /dev/null
+++ b/tools/generate-input-keycodes.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+INPUT_HEADER="/usr/include/linux/input.h"
+OUTPUT_ENUM="linux-input-enum.h"
+OUTPUT_MAP="linux-input-keycodes.h"
+SKIP="KEY_MIN_INTERESTING KEY_MAX KEY_CNT"
+
+if [ ! -e "$INPUT_HEADER" ]; then
+ echo "Can't find input header: $INPUT_HEADER" >&2
+ exit 1
+fi
+
+cat > "$OUTPUT_ENUM" <<EOF
+#ifndef foolinuxinputenumhfoo
+#define foolinuximputenumhfoo
+
+/* AUTOGENERATED: DO NOT EDIT */
+
+enum linux_input_keyval {
+EOF
+
+cat > "$OUTPUT_MAP" <<EOF
+#ifndef foolinuxinputkeycodesfoo
+#define foolinuxinputkeycodesfoo
+
+/* AUTOGENERATED: DO NOT EDIT */
+
+#include "$OUTPUT_ENUM"
+
+struct linux_input_keycode {
+ const char *name;
+ enum linux_input_keyval value;
+ bool alias;
+ GtkWidget *img;
+};
+
+struct linux_input_keycode linux_input_keycodes[] = {
+EOF
+
+cat "$INPUT_HEADER" | grep "^#define[[:space:]]*KEY_" | while read DEF NAME VALUE COMMENTS; do
+ for WORD in $SKIP; do
+ if [ "$NAME" = "$WORD" ]; then
+ continue
+ fi
+ done
+
+ if [ "${VALUE##KEY_}" != "$VALUE" ]; then
+ ALIAS="true"
+ else
+ ALIAS="false"
+ fi
+
+ echo " $NAME = $VALUE," >> "$OUTPUT_ENUM"
+ echo " { \"$NAME\", $NAME, $ALIAS, NULL }," >> "$OUTPUT_MAP"
+done
+
+cat >> "$OUTPUT_ENUM" << EOF
+};
+#endif
+EOF
+
+cat >> "$OUTPUT_MAP" << EOF
+ { NULL, 0, false, NULL }
+};
+#endif
+EOF
+
+
+exit 0
+
+