joy.4 revision 9311
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_SET_TIMEOUT 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_GET_TIMEOUT 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.Sh FILES
58.Bl -tag -width /dev/joy?
59.It Pa /dev/joy?
60joystick device files
61.Sh AUTHOR
62Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr>
63.Sh HISTORY
64The joystick driver appeared in FreeBSD 2.0.5.
65