1 /*#include <linux/version.h>*/ 2 3 #if 0 /*( LINUX_VESION_CODE >= 131584) */ 4 #include <linux/joystick.h> 5 #else 6 /* Joystick interface modeled after svgalibs keyboard and mouse interfaces 7 * Copyright 1998 Daniel Engstr�m <daniel.engstrom@riksnett.no> 8 * Partly based on code from 9 * joystick-0.7.3 Copyright (C) 1992, 1993 Author C. Smith 10 * and 11 * joystick-1.0.6 Copyright (C) 1997 Vojtech Pavlik 12 */ 13 14 #include <sys/ioctl.h> /* for _IOR(x) and _IOW(x) macros */ 15 #include <sys/types.h> 16 /* 17 * IOCTL commands for joystick driver 18 */ 19 /* get driver version */ 20 #define JSIOCGVERSION _IOR('j', 0x01, u_int32_t) 21 22 /* get number of axes */ 23 #define JSIOCGAXES _IOR('j', 0x11, u_int8_t) 24 /* get number of buttons */ 25 #define JSIOCGBUTTONS _IOR('j', 0x12, u_int8_t) 26 27 /* set correction values */ 28 #define JSIOCSCORR _IOW('j', 0x21, struct js_corr[4]) 29 /* get correction values */ 30 #define JSIOCGCORR _IOR('j', 0x22, struct js_corr[4]) 31 32 /* 33 * Types and constants for get/set correction 34 */ 35 36 #define JS_CORR_NONE 0x00 /* returns raw values */ 37 #define JS_CORR_BROKEN 0x01 /* broken line */ 38 39 struct js_corr { 40 int32_t coef[8]; 41 u_int16_t prec; 42 u_int16_t type; 43 }; 44 45 /* 46 * Types and constants for reading from /dev/js 47 */ 48 49 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */ 50 #define JS_EVENT_AXIS 0x02 /* joystick moved */ 51 #define JS_EVENT_INIT 0x80 /* initial state of device */ 52 53 struct js_event { 54 u_int32_t time; /* time when event happened in miliseconds 55 * since open */ 56 u_int16_t value; /* new value */ 57 u_int8_t type; /* type of event, see above */ 58 u_int8_t number; /* axis/button number */ 59 }; 60 61 /* 62 * Backward (version 0.x) compatibility definitions 63 */ 64 65 #define JS_RETURN sizeof(struct JS_DATA_TYPE) 66 #define JS_TRUE 1 67 #define JS_FALSE 0 68 #define JS_X_0 0x01 /* bit mask for x-axis js0 */ 69 #define JS_Y_0 0x02 /* bit mask for y-axis js0 */ 70 #define JS_X_1 0x04 /* bit mask for x-axis js1 */ 71 #define JS_Y_1 0x08 /* bit mask for y-axis js1 */ 72 #define JS_MAX 2 /* max number of joysticks */ 73 74 #define JS_SET_CAL 0x01 /*ioctl cmd to set joystick correction factor*/ 75 #define JS_GET_CAL 0x02 /*ioctl cmd to get joystick correction factor*/ 76 #define JS_SET_TIMEOUT 0x03 /*ioctl cmd to set maximum number of iterations 77 to wait for a timeout*/ 78 #define JS_GET_TIMEOUT 0x04 /*as above, to get*/ 79 #define JS_SET_TIMELIMIT 0x05 /*set data retention time*/ 80 #define JS_GET_TIMELIMIT 0x06 /*get data retention time*/ 81 #define JS_GET_ALL 0x07 /*get the whole JS_DATA[minor] struct*/ 82 #define JS_SET_ALL 0x08 /*set the whole JS_DATA[minor] struct 83 except JS_BUSY!*/ 84 85 /* version 0.x struct */ 86 struct JS_DATA_TYPE { 87 int buttons; /* immediate button state */ 88 int x; /* immediate x axis value */ 89 int y; /* immediate y axis value */ 90 }; 91 #endif 92