Last active
October 5, 2017 20:59
-
-
Save jigpu/45e9e1625d4512d4da5282e794963002 to your computer and use it in GitHub Desktop.
AWK script to format evemu-record output for live display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NOTE: When run in an environment which uses 'mawk' (e.g. Ubuntu), it is | |
| # recommended to set the environment variable WHINY_USERS to ensur the | |
| # output is sorted: `sudo evemu-record | WHINY_USERS=1 awk -f evemu-live.awk` | |
| BEGIN { | |
| SUBSEP="\t"; | |
| PROCINFO["sorted_in"]="@ind_str_asc"; | |
| "tput clear" | getline Clear; | |
| "tput cup 0 0" | getline Home; | |
| printf Clear; | |
| CODE["00010100"]="BTN_0"; | |
| CODE["00010101"]="BTN_1"; | |
| CODE["00010102"]="BTN_2"; | |
| CODE["00010103"]="BTN_3"; | |
| CODE["00010104"]="BTN_4"; | |
| CODE["00010105"]="BTN_5"; | |
| CODE["00010106"]="BTN_6"; | |
| CODE["00010107"]="BTN_7"; | |
| CODE["00010108"]="BTN_8"; | |
| CODE["00010109"]="BTN_9"; | |
| CODE["00010110"]="BTN_LEFT"; | |
| CODE["00010111"]="BTN_RIGHT"; | |
| CODE["00010112"]="BTN_MIDDLE"; | |
| CODE["00010113"]="BTN_SIDE"; | |
| CODE["00010114"]="BTN_EXTRA"; | |
| CODE["00010115"]="BTN_FORWARD"; | |
| CODE["00010116"]="BTN_BACK"; | |
| CODE["00010140"]="BTN_TOOL_PEN"; | |
| CODE["00010141"]="BTN_TOOL_RUBBER"; | |
| CODE["00010142"]="BTN_TOOL_BRUSH"; | |
| CODE["00010143"]="BTN_TOOL_PENCIL"; | |
| CODE["00010144"]="BTN_TOOL_AIRBRUSH"; | |
| CODE["00010145"]="BTN_TOOL_FINGER"; | |
| CODE["00010146"]="BTN_TOOL_MOUSE"; | |
| CODE["00010147"]="BTN_TOOL_LENS"; | |
| CODE["00010148"]="BTN_TOOL_QUINTTAP"; | |
| CODE["00010149"]="BTN_STYLUS3"; | |
| CODE["0001014a"]="BTN_TOUCH"; | |
| CODE["0001014b"]="BTN_STYLUS"; | |
| CODE["0001014c"]="BTN_STYLUS2"; | |
| CODE["0001014d"]="BTN_TOOL_DOUBLETAP"; | |
| CODE["0001014e"]="BTN_TOOL_TRIPLETAP"; | |
| CODE["0001014f"]="BTN_TOOL_QUADTAP"; | |
| CODE["00030000"]="ABS_X"; | |
| CODE["00030001"]="ABS_Y"; | |
| CODE["00030002"]="ABS_Z"; | |
| CODE["00030008"]="ABS_WHEEL"; | |
| CODE["00030018"]="ABS_PRESSURE"; | |
| CODE["00030019"]="ABS_DISTANCE"; | |
| CODE["0003001a"]="ABS_TILT_X"; | |
| CODE["0003001b"]="ABS_TILT_Y"; | |
| CODE["00030028"]="ABS_MISC"; | |
| CODE["00040000"]="MSC_SERIAL"; | |
| } | |
| /^A: / { | |
| KEY="000300"$2; | |
| DATA[KEY]=0; | |
| MIN[KEY]=$3; | |
| MAX[KEY]=$4; | |
| } | |
| /# EV_/ { | |
| KEY=$3$4; | |
| DATA[KEY]=$10 | |
| } | |
| /SYN_REPORT/ { | |
| printf Home; | |
| for(k in DATA) { | |
| VALUE=DATA[k]; | |
| MINIMUM=""; | |
| MAXIMUM=""; | |
| if (k in MIN) { | |
| MINIMUM=MIN[k]; | |
| MAXIMUM=MAX[k]; | |
| } | |
| printf("%15s (%8s) %10d [%d, %d]\n", CODE[k], k, VALUE, MINIMUM, MAXIMUM); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment