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