1 /* Title: USB Joystick library
3 Written by Puck2099 (puck2099@gmail.com), (c) 2006.
4 <http://www.gp32wip.com>
6 If you use this library or a part of it, please, let it know.
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 /* notaz: my Logitech has different button layout, and I want it to match gp2x's */
33 Enumeration: Axes values
34 This enumeration contains shortcuts to the values used on axes.
38 JOYDOWN - Joystick Down
39 JOYLEFT - Joystick Left
40 JOYRIGHT - Joystick Right
54 Contains all Joystick needed information.
57 fd - File descriptor used.
58 name - Joystick's name.
59 device - /dev/input/jsX device.
60 numbuttons - Joystick's buttons.
61 numaxes - Joystick's axes.
62 numhats - Joystick's hats.
63 statebuttons - Current state of each button.
64 stateaxes - Current state of each direction.
83 Opens a USB joystick and fills its information.
87 joynumber - Joystick's identifier (0 reserved for GP2X's builtin Joystick).
91 Filled usbjoy structure.
93 struct usbjoy * joy_open (int joynumber);
99 Returns Joystick's name.
103 joy - Selected joystick.
107 Joystick's name or NULL if <usbjoy> struct is empty.
109 char * joy_name (struct usbjoy * joy);
115 Returns Joystick's device.
119 joy - Selected joystick.
123 Joystick's device or NULL if <usbjoy> struct is empty.
125 char * joy_device (struct usbjoy * joy);
128 Function: joy_buttons
130 Returns Joystick's buttons number.
134 joy - Selected joystick.
138 Joystick's buttons or 0 if <usbjoy> struct is empty.
140 int joy_buttons (struct usbjoy * joy);
145 Returns Joystick's axes number.
149 joy - Selected joystick.
153 Joystick's axes or 0 if <usbjoy> struct is empty.
155 int joy_axes (struct usbjoy * joy);
161 Updates Joystick's internal information (<statebuttons> and <stateaxes> fields).
165 joy - Selected joystick.
169 0 - No events registered (no need to update).
170 1 - Events registered (a button or axe has been pushed).
171 -1 - Error: <usbjoy> struct is empty.
173 int joy_update (struct usbjoy * joy);
177 Function: joy_getbutton
179 Returns Joystick's button information.
183 button - Button which value you want to know (from 0 to 31).
184 joy - Selected joystick.
188 0 - Button NOT pushed.
190 -1 - Error: <usbjoy> struct is empty.
192 int joy_getbutton (int button, struct usbjoy * joy);
198 Returns Joystick's axes information.
202 axe - Axe which value you want to know (see <Axes values>).
203 joy - Selected joystick.
207 0 - Direction NOT pushed.
208 1 - Direction pushed.
209 -1 - Error: <usbjoy> struct is empty.
211 int joy_getaxe (int axe, struct usbjoy * joy);
216 Closes selected joystick's file descriptor and detroys it's fields.
220 joy - Selected joystick.
224 0 - Joystick successfully closed.
225 -1 - Error: <usbjoy> struct is empty.
227 int joy_close (struct usbjoy * joy);
232 extern int num_of_joys;
233 extern struct usbjoy *joys[4];
235 void usbjoy_update(void);
236 void usbjoy_init(void);
237 int usbjoy_check(int joyno);
238 int usbjoy_check2(int joyno);
239 void usbjoy_deinit(void);