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
10 #include <asm/types.h>
11 #include <linux/module.h>
17 #define JS_VERSION 0x01020a
20 * Types and constants for reading from /dev/js
23 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */
24 #define JS_EVENT_AXIS 0x02 /* joystick moved */
25 #define JS_EVENT_INIT 0x80 /* initial state of device */
28 __u32 time; /* event timestamp in miliseconds */
29 __s16 value; /* value */
30 __u8 type; /* event type */
31 __u8 number; /* axis/button number */
35 * IOCTL commands for joystick driver
38 #define JSIOCGVERSION _IOR('j', 0x01, __u32) /* get driver version */
40 #define JSIOCGAXES _IOR('j', 0x11, __u8) /* get number of axes */
41 #define JSIOCGBUTTONS _IOR('j', 0x12, __u8) /* get number of buttons */
42 #define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */
44 #define JSIOCSCORR _IOW('j', 0x21, struct js_corr) /* set correction values */
45 #define JSIOCGCORR _IOR('j', 0x22, struct js_corr) /* get correction values */
48 * Types and constants for get/set correction
51 #define JS_CORR_NONE 0x00 /* returns raw values */
52 #define JS_CORR_BROKEN 0x01 /* broken line */
61 * v0.x compatibility definitions
64 #define JS_RETURN sizeof(struct JS_DATA_TYPE)
73 #define JS_DEF_TIMEOUT 0x1300
75 #define JS_DEF_TIMELIMIT 10L
79 #define JS_SET_TIMEOUT 3
80 #define JS_GET_TIMEOUT 4
81 #define JS_SET_TIMELIMIT 5
82 #define JS_GET_TIMELIMIT 6
92 struct JS_DATA_SAVE_TYPE {
97 struct JS_DATA_TYPE JS_SAVE;
98 struct JS_DATA_TYPE JS_CORR;
102 * Internal definitions
107 #define JS_BUFF_SIZE 64 /* output buffer size */
109 #include <linux/version.h>
111 #ifndef KERNEL_VERSION
112 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
115 #ifndef LINUX_VERSION_CODE
116 #error "You need to use at least 2.0 Linux kernel."
119 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,0)
120 #error "You need to use at least 2.0 Linux kernel."
123 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
124 #define JS_HAS_RDTSC (current_cpu_data.x86_capability & 0x10)
125 #include <linux/init.h>
128 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,0,35)
129 #define JS_HAS_RDTSC (x86_capability & 0x10)
131 #define JS_HAS_RDTSC 0
134 #define JS_HAS_RDTSC (x86_capability & 0x10)
138 #define MODULE_AUTHOR(x)
139 #define MODULE_PARM(x,y)
140 #define MODULE_SUPPORTED_DEVICE(x)
141 #define signal_pending(x) (((x)->signal) & ~((x)->blocked))
148 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
153 #include <linux/parport.h>
154 #define JS_PAR_STATUS(y) parport_read_status(y->port)
155 #define JS_PAR_DATA_IN(y) parport_read_data(y->port)
156 #define JS_PAR_DATA_OUT(x,y) parport_write_data(y->port, x)
157 #define JS_PAR_CTRL_OUT(x,y) parport_write_control(y->port, x)
159 #define JS_PAR_STATUS(y) inb(y+1)
160 #define JS_PAR_DATA_IN(y) inb(y)
161 #define JS_PAR_DATA_OUT(x,y) outb(x,y)
162 #define JS_PAR_CTRL_OUT(x,y) outb(x,y+2)
165 #define JS_PAR_STATUS_INVERT (0x80)
173 typedef int (*js_read_func)(void *info, int **axes, int **buttons);
174 typedef unsigned int (*js_time_func)(void);
175 typedef int (*js_delta_func)(unsigned int x, unsigned int y);
176 typedef int (*js_ops_func)(struct js_dev *dev);
185 struct js_list *list;
186 struct js_port *port;
187 struct wait_queue *wait;
190 struct js_corr *corr;
191 struct js_event buff[JS_BUFF_SIZE];
203 struct js_list *next;
210 struct js_port *next;
211 struct js_port *prev;
213 struct js_dev **devs;
216 struct js_corr **corr;
222 * Sub-module interface
225 extern unsigned int js_time_speed;
226 extern js_time_func js_get_time;
227 extern js_delta_func js_delta;
229 extern unsigned int js_time_speed_a;
230 extern js_time_func js_get_time_a;
231 extern js_delta_func js_delta_a;
233 extern struct js_port *js_register_port(struct js_port *port, void *info,
234 int devs, int infos, js_read_func read);
235 extern struct js_port *js_unregister_port(struct js_port *port);
237 extern int js_register_device(struct js_port *port, int number, int axes,
238 int buttons, char *name, js_ops_func open, js_ops_func close);
239 extern void js_unregister_device(struct js_dev *dev);
245 extern int js_init(void);
246 extern int js_am_init(void);
247 extern int js_an_init(void);
248 extern int js_as_init(void);
249 extern int js_console_init(void);
250 extern int js_db9_init(void);
251 extern int js_gr_init(void);
252 extern int js_l4_init(void);
253 extern int js_lt_init(void);
254 extern int js_sw_init(void);
255 extern int js_tm_init(void);
257 extern void js_am_setup(char *str, int *ints);
258 extern void js_an_setup(char *str, int *ints);
259 extern void js_as_setup(char *str, int *ints);
260 extern void js_console_setup(char *str, int *ints);
261 extern void js_db9_setup(char *str, int *ints);
262 extern void js_l4_setup(char *str, int *ints);
264 #endif /* __KERNEL__ */
266 #endif /* _LINUX_JOYSTICK_H */