root/wminput/conf.h

Revision 2100f14c612471084434b364501e3818c7f4144e, 5.2 kB (checked in by L. Donnie Smith <donnie.smith@…>, 3 years ago)

Various administrative updates

change email addresses
remove individual file changelogs (that's what version control is for)

  • Property mode set to 100644
Line 
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#ifndef CONF_H
20#define CONF_H
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include <stdint.h>
27#include <stdio.h>
28#include <linux/input.h>
29#include <linux/uinput.h>
30
31#include "cwiid.h"
32#include "wmplugin.h"
33#include "y.tab.h"
34
35#define CONF_WM 1
36#define CONF_NC 2
37#define CONF_CC 3
38
39#define CONF_WM_BTN_UP          0
40#define CONF_WM_BTN_DOWN        1
41#define CONF_WM_BTN_LEFT        2
42#define CONF_WM_BTN_RIGHT       3
43#define CONF_WM_BTN_A           4
44#define CONF_WM_BTN_B           5
45#define CONF_WM_BTN_MINUS       6
46#define CONF_WM_BTN_PLUS        7
47#define CONF_WM_BTN_HOME        8
48#define CONF_WM_BTN_1           9
49#define CONF_WM_BTN_2           10
50
51#define CONF_NC_BTN_C           0
52#define CONF_NC_BTN_Z           1
53
54#define CONF_CC_BTN_UP          0
55#define CONF_CC_BTN_DOWN        1
56#define CONF_CC_BTN_LEFT        2
57#define CONF_CC_BTN_RIGHT       3
58#define CONF_CC_BTN_MINUS       4
59#define CONF_CC_BTN_PLUS        5
60#define CONF_CC_BTN_HOME        6
61#define CONF_CC_BTN_A           7
62#define CONF_CC_BTN_B           8
63#define CONF_CC_BTN_X           9
64#define CONF_CC_BTN_Y           10
65#define CONF_CC_BTN_ZL          11
66#define CONF_CC_BTN_ZR          12
67#define CONF_CC_BTN_L           13
68#define CONF_CC_BTN_R           14
69
70#define CONF_WM_BTN_COUNT       11
71#define CONF_NC_BTN_COUNT       2
72#define CONF_CC_BTN_COUNT       15
73
74#define CONF_WM_AXIS_DPAD_X             0
75#define CONF_WM_AXIS_DPAD_Y             1
76#define CONF_NC_AXIS_STICK_X    2
77#define CONF_NC_AXIS_STICK_Y    3
78#define CONF_CC_AXIS_DPAD_X             4
79#define CONF_CC_AXIS_DPAD_Y             5
80#define CONF_CC_AXIS_L_STICK_X  6
81#define CONF_CC_AXIS_L_STICK_Y  7
82#define CONF_CC_AXIS_R_STICK_X  8
83#define CONF_CC_AXIS_R_STICK_Y  9
84#define CONF_CC_AXIS_L                  10
85#define CONF_CC_AXIS_R                  11
86
87#define CONF_AXIS_COUNT         12
88
89#define CONF_MAX_PLUGINS        6
90
91#define CONF_ABS        EV_ABS
92#define CONF_REL        EV_REL
93
94/* flags */
95#define CONF_INVERT             0x01
96#define CONF_POINTER    0x02
97
98#define UINPUT_NAME             "Nintendo Wiimote"
99#ifdef BUS_BLUETOOTH
100#define UINPUT_BUSTYPE  BUS_BLUETOOTH
101#else
102#define UINPUT_BUSTYPE BUS_USB
103#endif
104#define UINPUT_VENDOR   0x0001
105#define UINPUT_PRODUCT  0x0001
106#ifndef UINPUT_VERSION
107#define UINPUT_VERSION  0x0001
108#endif
109
110struct lookup_enum {
111        const char *name;
112        __u16 value;
113};
114
115struct btn_map {
116        unsigned char active;
117        uint16_t mask;
118        __u16 action;
119};
120
121struct axis_map {
122        unsigned char active;
123        __u16 axis_type;
124        __u16 action;
125        uint8_t flags;
126};
127
128enum plugin_type {
129        PLUGIN_C,
130#ifdef HAVE_PYTHON
131        PLUGIN_PYTHON
132#endif
133};
134
135struct plugin {
136        char *name;
137        enum plugin_type type;
138        uint8_t rpt_mode_flags;
139        struct wmplugin_info *info;
140        struct wmplugin_data *data;
141        uint16_t prev_buttons;
142        struct btn_map bmap[WMPLUGIN_MAX_BUTTON_COUNT];
143        struct axis_map amap[WMPLUGIN_MAX_AXIS_COUNT];
144        void *p;
145};
146
147#define CONF_MAX_INCLUDE_DEPTH  10
148
149struct conf {
150        int fd;
151        char **config_search_dirs;
152        char **plugin_search_dirs;
153        char *current_config_filename;
154        int stack_index;
155        char *config_filename_stack[CONF_MAX_INCLUDE_DEPTH];
156        YYLTYPE yyloc_stack[CONF_MAX_INCLUDE_DEPTH];
157        uint8_t rpt_mode_flags;
158        struct uinput_user_dev dev;
159        unsigned char ff;
160        struct btn_map wiimote_bmap[CONF_WM_BTN_COUNT];
161        struct btn_map nunchuk_bmap[CONF_NC_BTN_COUNT];
162        struct btn_map classic_bmap[CONF_CC_BTN_COUNT];
163        struct axis_map amap[CONF_AXIS_COUNT];
164        struct plugin plugins[CONF_MAX_PLUGINS];
165};
166
167struct uinput_listen_data {
168        cwiid_wiimote_t *wiimote;
169        struct conf *conf;
170};
171
172int conf_load(struct conf *conf, const char *conf_name,
173              char *config_search_dirs[], char *plugin_search_dirs[]);
174int conf_unload(struct conf *conf);
175
176int conf_ff(struct conf *conf, unsigned char enabled);
177int conf_button(struct conf *conf, int source, __u16 button, __u16 action);
178int conf_axis(struct conf *conf, int axis, __u16 axis_type, __u16 action,
179              char flags);
180int conf_plugin_button(struct conf *conf, const char *name, const char *button,
181                       __u16 action);
182int conf_plugin_axis(struct conf *conf, const char *name, const char *axis,
183                     __u16 axis_type, __u16 action, char flags);
184int conf_plugin_param_int(struct conf *conf, const char *name,
185                          const char *param, int value);
186int conf_plugin_param_float(struct conf *conf, const char *name,
187                            const char *param, float value);
188
189void conf_init(struct conf *conf);
190FILE *conf_push_config(struct conf *conf, const char *filename, YYLTYPE *yyloc);
191int conf_pop_config(struct conf *conf, YYLTYPE *yyloc);
192int lookup_action(const char *str_action);
193
194int uinput_open(struct conf *conf);
195int uinput_close(struct conf *conf);
196int send_event(struct conf *conf, __u16 type, __u16 code, __s32 value);
197void *uinput_listen(struct uinput_listen_data *data);
198
199#endif
Note: See TracBrowser for help on using the browser.