| 1 | /* Copyright (C) 2007 L. Donnie Smith <donnie.smith@gatech.edu> |
|---|
| 2 | * |
|---|
| 3 | * This program is free software; you can redistribute it and/or modify |
|---|
| 4 | * it under the terms of the GNU General Public License as published by |
|---|
| 5 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 6 | * (at your option) any later version. |
|---|
| 7 | * |
|---|
| 8 | * This program is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * GNU General Public License for more details. |
|---|
| 12 | * |
|---|
| 13 | * You should have received a copy of the GNU General Public License |
|---|
| 14 | * along with this program; if not, write to the Free Software |
|---|
| 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 16 | * |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | %{ |
|---|
| 20 | #include <stdarg.h> |
|---|
| 21 | #include <stdio.h> |
|---|
| 22 | #include <linux/input.h> |
|---|
| 23 | #include "conf.h" |
|---|
| 24 | #include "util.h" |
|---|
| 25 | |
|---|
| 26 | int yylex(void); |
|---|
| 27 | void yyerror(char const *, ...); |
|---|
| 28 | |
|---|
| 29 | extern struct conf *cur_conf; |
|---|
| 30 | %} |
|---|
| 31 | |
|---|
| 32 | %union { |
|---|
| 33 | int Int; |
|---|
| 34 | float Float; |
|---|
| 35 | char *String; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | %error-verbose |
|---|
| 39 | %locations |
|---|
| 40 | |
|---|
| 41 | %token <Int> INT ON_OFF WM_BTN NC_BTN CC_BTN BTN_ACTION AXIS ABS_AXIS_ACTION |
|---|
| 42 | REL_AXIS_ACTION |
|---|
| 43 | %token <Float> FLOAT |
|---|
| 44 | %token <String> ID |
|---|
| 45 | %token WM_RUMBLE PLUGIN |
|---|
| 46 | |
|---|
| 47 | %start conf_list |
|---|
| 48 | |
|---|
| 49 | %type <Int> sign pointer |
|---|
| 50 | %% |
|---|
| 51 | |
|---|
| 52 | conf_list: |
|---|
| 53 | /* empty */ |
|---|
| 54 | | conf_list conf_line |
|---|
| 55 | ; |
|---|
| 56 | |
|---|
| 57 | conf_line: |
|---|
| 58 | '\n' |
|---|
| 59 | | conf_item '\n' |
|---|
| 60 | ; |
|---|
| 61 | |
|---|
| 62 | conf_item: |
|---|
| 63 | WM_RUMBLE '=' ON_OFF |
|---|
| 64 | { conf_ff(cur_conf, $3); } |
|---|
| 65 | | WM_BTN '=' BTN_ACTION |
|---|
| 66 | { conf_button(cur_conf, CONF_WM, $1, $3); } |
|---|
| 67 | | NC_BTN '=' BTN_ACTION |
|---|
| 68 | { conf_button(cur_conf, CONF_NC, $1, $3); } |
|---|
| 69 | | CC_BTN '=' BTN_ACTION |
|---|
| 70 | { conf_button(cur_conf, CONF_CC, $1, $3); } |
|---|
| 71 | | AXIS '=' sign pointer ABS_AXIS_ACTION |
|---|
| 72 | { conf_axis(cur_conf, $1, CONF_ABS, $5, $3 | $4); } |
|---|
| 73 | | AXIS '=' sign REL_AXIS_ACTION |
|---|
| 74 | { conf_axis(cur_conf, $1, CONF_REL, $4, $3); } |
|---|
| 75 | | PLUGIN ID '.' ID '=' BTN_ACTION |
|---|
| 76 | { conf_plugin_button(cur_conf, $2, $4, $6); } |
|---|
| 77 | | PLUGIN ID '.' ID '=' sign pointer ABS_AXIS_ACTION |
|---|
| 78 | { conf_plugin_axis(cur_conf, $2, $4, CONF_ABS, $8, $6 | $7); } |
|---|
| 79 | | PLUGIN ID '.' ID '=' sign REL_AXIS_ACTION |
|---|
| 80 | { conf_plugin_axis(cur_conf, $2, $4, CONF_REL, $7, $6); } |
|---|
| 81 | | PLUGIN ID '.' ID '=' INT |
|---|
| 82 | { conf_plugin_param_int(cur_conf, $2, $4, $6); } |
|---|
| 83 | | PLUGIN ID '.' ID '=' FLOAT |
|---|
| 84 | { conf_plugin_param_float(cur_conf, $2, $4, $6); } |
|---|
| 85 | ; |
|---|
| 86 | |
|---|
| 87 | sign: |
|---|
| 88 | /* empty */ |
|---|
| 89 | { $$ = 0; } |
|---|
| 90 | | '-' { $$ = CONF_INVERT; } |
|---|
| 91 | ; |
|---|
| 92 | |
|---|
| 93 | pointer: |
|---|
| 94 | /* empty */ |
|---|
| 95 | { $$ = 0; } |
|---|
| 96 | | '~' { $$ = CONF_POINTER; } |
|---|
| 97 | %% |
|---|
| 98 | |
|---|
| 99 | void yyerror(char const *s, ...) |
|---|
| 100 | { |
|---|
| 101 | va_list ap; |
|---|
| 102 | |
|---|
| 103 | va_start(ap, s); |
|---|
| 104 | wminput_err("%s: line %d, column %d:", cur_conf->current_config_filename, |
|---|
| 105 | yylloc.first_line, yylloc.first_column); |
|---|
| 106 | wminput_err((char *)s, ap); |
|---|
| 107 | va_end(ap); |
|---|
| 108 | } |
|---|