joy.4 revision 5909
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 array of 4 integers via a read()
16call. 
17.br
18The X and Y positions are stored in values 0 and 1 of the array,
19and the state of the 2 buttons are stores in values 2 and 3 of the
20array. Positions are typically in the range 0-2000.
21.Ss One line perl example:
22perl -e 'open(JOY,"/dev/joy0")||die;while(1)
23.br
24{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}'
25.Ss ioctl calls
26Several ioctl() calls are also available. They take an argument of
27type int *
28.Bl -tag -width JOY_SET_X_OFFSET 
29.It Dv JOY_SET_TIMEOUT Fa int *limit
30Set the time limit (in microseconds) for reading the joystick
31status. Setting a value
32too small may prevent to get correct values for the positions (which
33are then set to -2147483648), however this can be useful if one is
34only interested by the buttons status. 
35.It Dv JOY_GET_TIMEOUT Fa int *limit
36Get the time limit (in microseconds) used for reading the joystick
37status. 
38.It Dv JOY_SET_X_OFFSET Fa int *offset
39Set the value to be added to the X position  when reading the joystick
40status. 
41.It Dv JOY_SET_Y_OFFSET Fa int *offset
42Set the value to be added to the Y position  when reading the joystick
43status. 
44.It Dv JOY_GET_X_OFFSET Fa int *offset
45Get the value which is added to the X position  when reading the joystick
46status. 
47.It Dv JOY_GET_Y_OFFSET Fa int *offset
48Get the value which is added to the Y position  when reading the joystick
49status. 
50.Sh FILES
51.Bl -tag -width /dev/joy?
52.It Pa /dev/joy?
53joystick device files
54.Sh AUTHOR
55Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr>
56.Sh HISTORY
57The joystick driver appeared in FreeBSD 2.1
58