xref: /netbsd-src/share/man/man4/joy.4 (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1.\" $NetBSD: joy.4,v 1.7 2004/12/02 15:02:37 wiz Exp $
2.\"
3.\" Copyright (c) 1996 Matthieu Herrb
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"      This product includes software developed by Christopher G. Demetriou.
17.\" 4. The name of the author may not be used to endorse or promote products
18.\"    derived from this software without specific prior written permission
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd December 2, 2004
32.Dt JOY 4
33.Os
34.Sh NAME
35.Nm joy
36.Nd game adapter driver
37.Sh SYNOPSIS
38.Cd "joy* at acpi?"
39.Cd "joy* at eso?"
40.Cd "joy0 at isa? port 0x201"
41.Cd "joy* at isapnp?"
42.Cd "joy* at ofisa?"
43.Cd "joy* at pci?"
44.Cd "joy* at pnpbios? index ?"
45.Sh DESCRIPTION
46This driver provides access to the game adapter.
47The lower bit in the minor device number selects the joystick: 0
48is the first joystick and 1 is the second.
49.Pp
50The game control adapter allows up to two joysticks to be attached to
51the system.
52The adapter plus the driver convert the present resistive value to
53a relative joystick position.
54On receipt of an output signal, four timing circuits are started.
55By determining the time required for the circuit to time-out (a
56function of the resistance), the paddle position can be determined.
57The adapter could be used as a general purpose I/O card with four
58analog (resistive) inputs plus four digital input points.
59.Pp
60Applications may call
61.Xr ioctl 2
62on a game adapter driver file descriptor
63to set and get the offsets of the two potentiometers and the maximum
64time-out value for the circuit.
65The
66.Xr ioctl 2
67commands are listed in
68.Aq Pa machine/joystick.h
69and currently are:
70.Pp
71.Bl -tag -width JOY_GET_X_OFFSET -compact
72.It Dv JOY_SETTIMEOUT
73Sets the maximum time-out for the adapter.
74.It Dv JOY_GETTIMEOUT
75Returns the current maximum time-out.
76.It Dv JOY_SET_X_OFFSET
77Sets an offset on X value.
78.It Dv JOY_GET_X_OFFSET
79Returns the current X offset.
80.It Dv JOY_SET_Y_OFFSET
81Sets an offset on Y value.
82.It Dv JOY_GET_Y_OFFSET
83Returns the current Y offset.
84.El
85.Pp
86All these commands take an integer parameter.
87.Pp
88.Xr read 2
89on the file descriptor returns a
90.Fa joystick
91structure:
92.Bd -literal -offset indent
93struct joystick {
94	int x;
95	int y;
96	int b1;
97	int b2;
98};
99.Ed
100.Pp
101The fields have the following functions:
102.Bl -tag -width xxx
103.It Fa x
104current X coordinate of the joystick (or position of paddle 1)
105.It Fa y
106current Y coordinate of the joystick (or position of paddle 2)
107.It Fa b1
108current state of button 1
109.It Fa b2
110current state of button 2
111.El
112.Pp
113The b1 and b2 fields in struct joystick are set to 1 if the
114corresponding button is down, 0 otherwise.
115.Pp
116The x and y coordinates are supposed to be between 0 and 255 for a
117good joystick and a good adapter.
118Unfortunately, because of the
119hardware hack that is used to measure the position (by measuring the
120time needed to discharge an RC circuit made from the joystick's
121potentiometer and a capacitor on the adapter), calibration
122is needed to determine exactly what values are returned for a specific
123joystick/adapter combination.
124Incorrect hardware can yield negative or values greater than 255.
125.Pp
126A typical calibration procedure uses the values returned at lower
127left, center and upper right positions of the joystick to compute the
128relative position.
129.Pp
130This calibration is not part of the driver.
131.Sh FILES
132.Bl -tag -width Pa -compact
133.It Pa /dev/joy0
134first joystick
135.It Pa /dev/joy1
136second joystick
137.El
138.Sh SEE ALSO
139.Xr acpi 4 ,
140.Xr eso 4 ,
141.Xr isa 4 ,
142.Xr isapnp 4 ,
143.Xr ofisa 4 ,
144.Xr pci 4 ,
145.Xr pnpbios 4
146.Sh AUTHORS
147Jean-Marc Zucconi wrote the
148.Fx
149driver.
150Matthieu Herrb ported it to
151.Nx
152and wrote this manual page.
153