8 .Nd joystick device driver
10 .Cd device joy0 at isa? port "IO_GAME"
11 .Fd #include <machine/joystick.h>
13 The joystick device driver allows applications to read the status of
16 This device may be opened by only one process at a time.
18 The joystick status is read from a structure via a read()
19 call. The structure is defined in the header file as follows:
21 .Bd -literal -offset indent
23 int x; /* x position */
24 int y; /* y position */
25 int b1; /* button 1 status */
26 int b2; /* button 2 status */
30 Positions are typically in the range 0-2000.
31 .Ss One line perl example:
32 perl -e 'open(JOY,"/dev/joy0")||die;while(1)
34 {sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}'
36 Several ioctl() calls are also available. They take an argument of
38 .Bl -tag -width JOY_SET_X_OFFSET
39 .It Dv JOY_SETTIMEOUT Fa int *limit
40 Set the time limit (in microseconds) for reading the joystick
41 status. Setting a value
42 too small may prevent to get correct values for the positions (which
43 are then set to -2147483648), however this can be useful if one is
44 only interested by the buttons status.
45 .It Dv JOY_GETTIMEOUT Fa int *limit
46 Get the time limit (in microseconds) used for reading the joystick
48 .It Dv JOY_SET_X_OFFSET Fa int *offset
49 Set the value to be added to the X position when reading the joystick
51 .It Dv JOY_SET_Y_OFFSET Fa int *offset
52 Set the value to be added to the Y position when reading the joystick
54 .It Dv JOY_GET_X_OFFSET Fa int *offset
55 Get the value which is added to the X position when reading the joystick
57 .It Dv JOY_GET_Y_OFFSET Fa int *offset
58 Get the value which is added to the Y position when reading the joystick
61 .Sh TECHNICAL SPECIFICATIONS
63 The pinout of the DB-15 connector is as follow:
67 3 X1 (potentiometer #1)
70 6 Y1 (potentiometer #2)
75 11 X2 (potentiometer #3)
77 13 Y2 (potentiometer #4)
81 Pots are normally 0-150k variable resistors (0-100k sometimes), and
82 according to the IBM techref, the time is given by
83 Time = 24.2e-6s + 0.011e-6s * R/Ohms
86 .Bl -tag -width /dev/joy?
90 .An Jean-Marc Zucconi Aq jmz@cabri.obs-besancon.fr
92 The joystick driver appeared in