#!/bin/bash set -e INPUT_HEADER="/usr/include/linux/input.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 "$LOCAL_INPUT_HEADER" ]; then if [ ! -e "$INPUT_HEADER" ]; then echo "Can't find input header: $INPUT_HEADER" >&2 exit 1 fi cp "$INPUT_HEADER" "$LOCAL_INPUT_HEADER" fi cat > "$OUTPUT_MAPH" < #include #include #include "$LOCAL_INPUT_HEADER" struct linux_input_keycode { const char *name; 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 "$LOCAL_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\", $NAME, $ALIAS, NULL }," >> "$OUTPUT_MAPC" done cat >> "$OUTPUT_MAPC" << EOF { NULL, 0, false, NULL } }; EOF exit 0