| 1 |
/* Copyright (C) 2007 L. Donnie Smith <wiimote@abstrakraft.org> |
|---|
| 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 |
* ChangeLog: |
|---|
| 18 |
* 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> |
|---|
| 19 |
* * added param rules |
|---|
| 20 |
* |
|---|
| 21 |
* 2007-03-04 L. Donnie Smith <cwiid@abstrakraft.org> |
|---|
| 22 |
* * Initial ChangeLog |
|---|
| 23 |
*/ |
|---|
| 24 |
|
|---|
| 25 |
%{ |
|---|
| 26 |
#include <stdarg.h> |
|---|
| 27 |
#include <stdio.h> |
|---|
| 28 |
#include <linux/input.h> |
|---|
| 29 |
#include "conf.h" |
|---|
| 30 |
#include "util.h" |
|---|
| 31 |
|
|---|
| 32 |
int yylex(void); |
|---|
| 33 |
void yyerror(char const *, ...); |
|---|
| 34 |
|
|---|
| 35 |
extern struct conf *cur_conf; |
|---|
| 36 |
%} |
|---|
| 37 |
|
|---|
| 38 |
%union { |
|---|
| 39 |
int Int; |
|---|
| 40 |
float Float; |
|---|
| 41 |
char *String; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
%error-verbose |
|---|
| 45 |
%locations |
|---|
| 46 |
|
|---|
| 47 |
%token <Int> INT ON_OFF WM_BTN NC_BTN CC_BTN BTN_ACTION AXIS ABS_AXIS_ACTION |
|---|
| 48 |
REL_AXIS_ACTION |
|---|
| 49 |
%token <Float> FLOAT |
|---|
| 50 |
%token <String> ID |
|---|
| 51 |
%token WM_RUMBLE PLUGIN |
|---|
| 52 |
|
|---|
| 53 |
%start conf_list |
|---|
| 54 |
|
|---|
| 55 |
%type <Int> sign pointer |
|---|
| 56 |
%% |
|---|
| 57 |
|
|---|
| 58 |
conf_list: |
|---|
| 59 |
/* empty */ |
|---|
| 60 |
| conf_list conf_line |
|---|
| 61 |
; |
|---|
| 62 |
|
|---|
| 63 |
conf_line: |
|---|
| 64 |
'\n' |
|---|
| 65 |
| conf_item '\n' |
|---|
| 66 |
; |
|---|
| 67 |
|
|---|
| 68 |
conf_item: |
|---|
| 69 |
WM_RUMBLE '=' ON_OFF |
|---|
| 70 |
{ conf_ff(cur_conf, $3); } |
|---|
| 71 |
| WM_BTN '=' BTN_ACTION |
|---|
| 72 |
{ conf_button(cur_conf, CONF_WM, $1, $3); } |
|---|
| 73 |
| NC_BTN '=' BTN_ACTION |
|---|
| 74 |
{ conf_button(cur_conf, CONF_NC, $1, $3); } |
|---|
| 75 |
| CC_BTN '=' BTN_ACTION |
|---|
| 76 |
{ conf_button(cur_conf, CONF_CC, $1, $3); } |
|---|
| 77 |
| AXIS '=' sign pointer ABS_AXIS_ACTION |
|---|
| 78 |
{ conf_axis(cur_conf, $1, CONF_ABS, $5, $3 | $4); } |
|---|
| 79 |
| AXIS '=' sign REL_AXIS_ACTION |
|---|
| 80 |
{ conf_axis(cur_conf, $1, CONF_REL, $4, $3); } |
|---|
| 81 |
| PLUGIN ID '.' ID '=' BTN_ACTION |
|---|
| 82 |
{ conf_plugin_button(cur_conf, $2, $4, $6); } |
|---|
| 83 |
| PLUGIN ID '.' ID '=' sign pointer ABS_AXIS_ACTION |
|---|
| 84 |
{ conf_plugin_axis(cur_conf, $2, $4, CONF_ABS, $8, $6 | $7); } |
|---|
| 85 |
| PLUGIN ID '.' ID '=' sign REL_AXIS_ACTION |
|---|
| 86 |
{ conf_plugin_axis(cur_conf, $2, $4, CONF_REL, $7, $6); } |
|---|
| 87 |
| PLUGIN ID '.' ID '=' INT |
|---|
| 88 |
{ conf_plugin_param_int(cur_conf, $2, $4, $6); } |
|---|
| 89 |
| PLUGIN ID '.' ID '=' FLOAT |
|---|
| 90 |
{ conf_plugin_param_float(cur_conf, $2, $4, $6); } |
|---|
| 91 |
; |
|---|
| 92 |
|
|---|
| 93 |
sign: |
|---|
| 94 |
/* empty */ |
|---|
| 95 |
{ $$ = 0; } |
|---|
| 96 |
| '-' { $$ = CONF_INVERT; } |
|---|
| 97 |
; |
|---|
| 98 |
|
|---|
| 99 |
pointer: |
|---|
| 100 |
/* empty */ |
|---|
| 101 |
{ $$ = 0; } |
|---|
| 102 |
| '~' { $$ = CONF_POINTER; } |
|---|
| 103 |
%% |
|---|
| 104 |
|
|---|
| 105 |
void yyerror(char const *s, ...) |
|---|
| 106 |
{ |
|---|
| 107 |
va_list ap; |
|---|
| 108 |
|
|---|
| 109 |
va_start(ap, s); |
|---|
| 110 |
wminput_err("%s: line %d, column %d:", cur_conf->current_config_filename, |
|---|
| 111 |
yylloc.first_line, yylloc.first_column); |
|---|
| 112 |
wminput_err((char *)s, ap); |
|---|
| 113 |
va_end(ap); |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|