summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-21 23:40:10 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-21 23:40:10 +0200
commit5655eb321535c288325f6fff47b60f680d08ce21 (patch)
tree2519dad860aeee6234c4213bea1756e1a9efec56 /tools
parentf685878d4eb057d29c2b8087a1c55eb027bb7dda (diff)
Add input reading capabilities to server
Diffstat (limited to 'tools')
-rwxr-xr-xtools/generate-input-keycodes.sh60
1 files changed, 32 insertions, 28 deletions
diff --git a/tools/generate-input-keycodes.sh b/tools/generate-input-keycodes.sh
index 51d09e8..988940d 100755
--- a/tools/generate-input-keycodes.sh
+++ b/tools/generate-input-keycodes.sh
@@ -1,43 +1,55 @@
#!/bin/bash
+set -e
+
INPUT_HEADER="/usr/include/linux/input.h"
-OUTPUT_ENUM="linux-input-enum.h"
-OUTPUT_MAP="linux-input-keycodes.h"
+LOCAL_INPUT_HEADER="linux-input.h"
+OUTPUT_MAPH="linux-input-keycodes.h"
+OUTPUT_MAPC="linux-input-keycodes.c"
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 */
+if [ ! -e "$LOCAL_INPUT_HEADER" ]; then
+ if [ ! -e "$INPUT_HEADER" ]; then
+ echo "Can't find input header: $INPUT_HEADER" >&2
+ exit 1
+ fi
-enum linux_input_keyval {
-EOF
+ cp "$INPUT_HEADER" "$LOCAL_INPUT_HEADER"
+fi
-cat > "$OUTPUT_MAP" <<EOF
+cat > "$OUTPUT_MAPH" <<EOF
#ifndef foolinuxinputkeycodesfoo
#define foolinuxinputkeycodesfoo
/* AUTOGENERATED: DO NOT EDIT */
-#include "$OUTPUT_ENUM"
+#include <unistd.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include "$LOCAL_INPUT_HEADER"
struct linux_input_keycode {
const char *name;
- enum linux_input_keyval value;
+ uint32_t value;
bool alias;
void *cairo_surface;
};
+extern struct linux_input_keycode linux_input_keycodes[];
+
+#endif
+EOF
+
+cat > "$OUTPUT_MAPC" << EOF
+/* AUTOGENERATED: DO NOT EDIT */
+
+#include "$LOCAL_INPUT_HEADER"
+#include "$OUTPUT_MAPH"
+
struct linux_input_keycode linux_input_keycodes[] = {
EOF
-cat "$INPUT_HEADER" | grep "^#define[[:space:]]*KEY_" | while read DEF NAME VALUE COMMENTS; do
+cat "$LOCAL_INPUT_HEADER" | grep "^#define[[:space:]]*KEY_" | while read DEF NAME VALUE COMMENTS; do
for WORD in $SKIP; do
if [ "$NAME" = "$WORD" ]; then
continue
@@ -50,22 +62,14 @@ cat "$INPUT_HEADER" | grep "^#define[[:space:]]*KEY_" | while read DEF NAME VALU
ALIAS="false"
fi
- echo " $NAME = $VALUE," >> "$OUTPUT_ENUM"
- echo " { \"$NAME\", $NAME, $ALIAS, NULL }," >> "$OUTPUT_MAP"
+ echo " { \"$NAME\", $NAME, $ALIAS, NULL }," >> "$OUTPUT_MAPC"
done
-cat >> "$OUTPUT_ENUM" << EOF
-};
-#endif
-EOF
-
-cat >> "$OUTPUT_MAP" << EOF
+cat >> "$OUTPUT_MAPC" << EOF
{ NULL, 0, false, NULL }
};
-#endif
EOF
-
exit 0