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