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