1 #ifndef _LINUX_JOYSTICK_H
2 #define _LINUX_JOYSTICK_H
5 * /usr/include/linux/joystick.h Version 1.2
7 * Copyright (C) 1996-1998 Vojtech Pavlik
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Should you need to contact me, the author, you can do so either by
26 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
27 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
30 #include <asm/types.h>
31 #include <linux/module.h>
37 #define JS_VERSION 0x01020d
40 * Types and constants for reading from /dev/js
43 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */
44 #define JS_EVENT_AXIS 0x02 /* joystick moved */
45 #define JS_EVENT_INIT 0x80 /* initial state of device */
48 __u32 time
; /* event timestamp in miliseconds */
49 __s16 value
; /* value */
50 __u8 type
; /* event type */
51 __u8 number
; /* axis/button number */
55 * IOCTL commands for joystick driver
58 #define JSIOCGVERSION _IOR('j', 0x01, __u32) /* get driver version */
60 #define JSIOCGAXES _IOR('j', 0x11, __u8) /* get number of axes */
61 #define JSIOCGBUTTONS _IOR('j', 0x12, __u8) /* get number of buttons */
62 #define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */
64 #define JSIOCSCORR _IOW('j', 0x21, struct js_corr) /* set correction values */
65 #define JSIOCGCORR _IOR('j', 0x22, struct js_corr) /* get correction values */
68 * Types and constants for get/set correction
71 #define JS_CORR_NONE 0x00 /* returns raw values */
72 #define JS_CORR_BROKEN 0x01 /* broken line */
81 * v0.x compatibility definitions
84 #define JS_RETURN sizeof(struct JS_DATA_TYPE)
93 #define JS_DEF_TIMEOUT 0x1300
95 #define JS_DEF_TIMELIMIT 10L
99 #define JS_SET_TIMEOUT 3
100 #define JS_GET_TIMEOUT 4
101 #define JS_SET_TIMELIMIT 5
102 #define JS_GET_TIMELIMIT 6
106 struct JS_DATA_TYPE
{
112 struct JS_DATA_SAVE_TYPE
{
117 struct JS_DATA_TYPE JS_SAVE
;
118 struct JS_DATA_TYPE JS_CORR
;
122 * Internal definitions
127 #define JS_BUFF_SIZE 64 /* output buffer size */
129 #include <linux/version.h>
131 #ifndef KERNEL_VERSION
132 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
135 #ifndef LINUX_VERSION_CODE
136 #error "You need to use at least 2.0 Linux kernel."
139 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,0)
140 #error "You need to use at least 2.0 Linux kernel."
143 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
144 #define JS_HAS_RDTSC (current_cpu_data.x86_capability & 0x10)
145 #include <linux/init.h>
148 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,35)
149 #define JS_HAS_RDTSC (x86_capability & 0x10)
151 #define JS_HAS_RDTSC 0
154 #define JS_HAS_RDTSC (x86_capability & 0x10)
159 #define __save_flags(flags) save_flags(flags)
160 #define __restore_flags(flags) restore_flags(flags)
161 #define spin_lock_irqsave(x, flags) do { save_flags(flags); cli(); } while (0)
162 #define spin_unlock_irqrestore(x, flags) restore_flags(flags)
163 #define spin_lock_init(x) do { } while (0)
164 typedef struct { int something
; } spinlock_t
;
165 #define SPIN_LOCK_UNLOCKED { 0 }
166 #define MODULE_AUTHOR(x)
167 #define MODULE_PARM(x,y)
168 #define MODULE_SUPPORTED_DEVICE(x)
169 #define signal_pending(x) (((x)->signal) & ~((x)->blocked))
176 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
181 #include <linux/parport.h>
182 #define JS_PAR_DATA_IN(y) parport_read_data(y->port)
183 #define JS_PAR_DATA_OUT(x,y) parport_write_data(y->port, x)
184 #define JS_PAR_STATUS(y) parport_read_status(y->port)
185 #define JS_PAR_CTRL_IN(y) parport_read_control(y->port)
186 #define JS_PAR_CTRL_OUT(x,y) parport_write_control(y->port, x)
187 #define JS_PAR_ECTRL_OUT(x,y) parport_write_econtrol(y->port, x)
189 #define JS_PAR_DATA_IN(y) inb(y)
190 #define JS_PAR_DATA_OUT(x,y) outb(x,y)
191 #define JS_PAR_STATUS(y) inb(y+1)
192 #define JS_PAR_CTRL_IN(y) inb(y+2)
193 #define JS_PAR_CTRL_OUT(x,y) outb(x,y+2)
194 #define JS_PAR_ECTRL_OUT(x,y) outb(x,y+0x402)
197 #define JS_PAR_STATUS_INVERT (0x80)
198 #define JS_PAR_CTRL_INVERT (0x04)
206 typedef int (*js_read_func
)(void *info
, int **axes
, int **buttons
);
207 typedef unsigned int (*js_time_func
)(void);
208 typedef int (*js_delta_func
)(unsigned int x
, unsigned int y
);
209 typedef int (*js_ops_func
)(struct js_dev
*dev
);
218 struct js_list
*list
;
219 struct js_port
*port
;
220 wait_queue_head_t wait
;
223 struct js_corr
*corr
;
224 struct js_event buff
[JS_BUFF_SIZE
];
236 struct js_list
*next
;
243 struct js_port
*next
;
244 struct js_port
*prev
;
246 struct js_dev
**devs
;
249 struct js_corr
**corr
;
255 * Sub-module interface
258 extern unsigned int js_time_speed
;
259 extern js_time_func js_get_time
;
260 extern js_delta_func js_delta
;
262 extern unsigned int js_time_speed_a
;
263 extern js_time_func js_get_time_a
;
264 extern js_delta_func js_delta_a
;
266 extern struct js_port
*js_register_port(struct js_port
*port
, void *info
,
267 int devs
, int infos
, js_read_func read
);
268 extern struct js_port
*js_unregister_port(struct js_port
*port
);
270 extern int js_register_device(struct js_port
*port
, int number
, int axes
,
271 int buttons
, char *name
, js_ops_func open
, js_ops_func close
);
272 extern void js_unregister_device(struct js_dev
*dev
);
278 extern int js_init(void);
279 extern int js_am_init(void);
280 extern int js_an_init(void);
281 extern int js_as_init(void);
282 extern int js_console_init(void);
283 extern int js_db9_init(void);
284 extern int js_gr_init(void);
285 extern int js_l4_init(void);
286 extern int js_lt_init(void);
287 extern int js_sw_init(void);
288 extern int js_tm_init(void);
290 extern void js_am_setup(char *str
, int *ints
);
291 extern void js_an_setup(char *str
, int *ints
);
292 extern void js_as_setup(char *str
, int *ints
);
293 extern void js_console_setup(char *str
, int *ints
);
294 extern void js_db9_setup(char *str
, int *ints
);
295 extern void js_l4_setup(char *str
, int *ints
);
297 #endif /* __KERNEL__ */
299 #endif /* _LINUX_JOYSTICK_H */