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