joy.4 revision 17762
1.Dd January 23, 1995 2.Dt JOY 4 3.Sh NAME 4.Nm joy 5.Nd joystick device driver 6.Sh SYNOPSIS 7.Cd device joy0 at isa? port "IO_GAME" 8.Fd #include <machine/joystick.h> 9.Sh DESCRIPTION 10The joystick device driver allows applications to read the status of 11the PC joystick. 12.Pp 13This device may be opened by only one process at a time. 14.Pp 15The joystick status is get in an structure joystick via a read() 16call. The structure is defined in the header file as follows: 17.Pp 18.Bd -literal -offset indent 19 struct joystick { 20 int x; /* x position */ 21 int y; /* y position */ 22 int b1; /* button 1 status */ 23 int b2; /* button 2 status */ 24 }; 25.Ed 26.Pp 27Positions are typically in the range 0-2000. 28.Ss One line perl example: 29perl -e 'open(JOY,"/dev/joy0")||die;while(1) 30.br 31{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}' 32.Ss ioctl calls 33Several ioctl() calls are also available. They take an argument of 34type int * 35.Bl -tag -width JOY_SET_X_OFFSET 36.It Dv JOY_SETTIMEOUT Fa int *limit 37Set the time limit (in microseconds) for reading the joystick 38status. Setting a value 39too small may prevent to get correct values for the positions (which 40are then set to -2147483648), however this can be useful if one is 41only interested by the buttons status. 42.It Dv JOY_GETTIMEOUT Fa int *limit 43Get the time limit (in microseconds) used for reading the joystick 44status. 45.It Dv JOY_SET_X_OFFSET Fa int *offset 46Set the value to be added to the X position when reading the joystick 47status. 48.It Dv JOY_SET_Y_OFFSET Fa int *offset 49Set the value to be added to the Y position when reading the joystick 50status. 51.It Dv JOY_GET_X_OFFSET Fa int *offset 52Get the value which is added to the X position when reading the joystick 53status. 54.It Dv JOY_GET_Y_OFFSET Fa int *offset 55Get the value which is added to the Y position when reading the joystick 56status. 57 58.Sh TECHNICAL SPECIFICATIONS 59 60The pinout of the DB-15 connector is as follow: 61.Pp 62 1 XY1 (+5v) 63 2 Switch 1 64 3 X1 (potentiometer #1) 65 4 Switch 1 (GND) 66 5 Switch 2 (GND) 67 6 Y1 (potentiometer #2) 68 7 Switch 2 69 8 N.C. 70 9 XY2 (+5v) 71 10 Switch 4 72 11 X2 (potentiometer #3) 73 12 Switch 3&4 (GND) 74 13 Y2 (potentiometer #4) 75 14 Switch 3 76 15 N.C. 77.Pp 78Pots are normally 0-150k variable resistors (0-100k sometimes), and 79according to the IBM techref, the time is given by 80Time = 24.2e-6s + 0.011e-6s * R/Ohms 81 82.Sh FILES 83.Bl -tag -width /dev/joy? 84.It Pa /dev/joy? 85joystick device files 86.Sh AUTHOR 87Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr> 88.Sh HISTORY 89The joystick driver appeared in 90.Fx 2.0.5 . 91