xref: /netbsd-src/share/man/man4/joy.4 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\" $NetBSD: joy.4,v 1.5 2004/05/11 22:42:47 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 January 7, 1996
32.Dt JOY 4
33.Os
34.Sh NAME
35.Nm joy
36.Nd game adapter driver
37.Sh SYNOPSIS
38.Cd "joy0 at isa? port 0x201"
39.Cd "joy* at isapnp?"
40.Cd "joy* at ofisa?"
41.Cd "joy* at pci?"
42.Cd "joy* at pnpbios? index ?"
43.Cd "joy* at eso?"
44.Sh DESCRIPTION
45This driver provides access to the game adapter.
46The lower bit in the
47minor device number selects the joystick: 0 is the first joystick and
481 is the second.
49.Pp
50The game control adapter allows up to two joysticks to be attached to
51the system.  The adapter plus the driver convert the present resistive
52value to a relative joystick position.  On receipt of an output signal,
53four timing circuits are started.  By determining the time required for
54the circuit to time-out (a function of the resistance), the paddle
55position can be determined.  The adapter could be used as a general
56purpose I/O card with four analog (resistive) inputs plus four digital
57input points.
58.Pp
59Applications may call
60.Xr ioctl 2
61on a game adapter driver file descriptor
62to set and get the offsets of the two potentiometers and the maximum
63time-out value for the circuit.  The
64.Xr ioctl 2
65commands are listed in
66.Aq Pa machine/joystick.h
67and currently are:
68.Pp
69.Bl -tag -width JOY_GET_X_OFFSET -compact
70.It JOY_SETTIMEOUT
71Sets the maximum time-out for the adapter.
72.It JOY_GETTIMEOUT
73Returns the current maximum time-out.
74.It JOY_SET_X_OFFSET
75Sets an offset on X value.
76.It JOY_GET_X_OFFSET
77Returns the current X offset.
78.It JOY_SET_Y_OFFSET
79Sets an offset on Y value.
80.It JOY_GET_Y_OFFSET
81Returns the current Y offset.
82.El
83.Pp
84All this commands take an integer parameter.
85.Pp
86.Xr read 2
87on the file descriptor returns a
88.Fa joystick
89structure:
90.Bd -literal -offset indent
91struct joystick {
92	int x;
93	int y;
94	int b1;
95	int b2;
96};
97.Ed
98.Pp
99The fields have the following functions:
100.Bl -tag -width xxx
101.It Fa x
102current X coordinate of the joystick (or position of paddle 1)
103.It Fa y
104current Y coordinate of the joystick (or position of paddle 2)
105.It Fa b1
106current state of button 1
107.It Fa b2
108current state of button 2
109.El
110.Pp
111The b1 and b2 fields in struct joystick are set to 1 if the
112corresponding button is down, 0 otherwise.
113.Pp
114The x and y coordinates are supposed to be between 0 and 255 for a
115good joystick and a good adapter.  Unfortunately, because of the
116hardware hack that is used to measure the position (by measuring the
117time needed to discharge an RC circuit made from the joystick's
118potentiometer and a capacitor on the adapter), calibration
119is needed to determine exactly what values are returned for a specific
120joystick/adapter combination.  Incorrect hardware can yield negative or
121> 255 values.
122.Pp
123A typical calibration procedure uses the values returned at lower
124left, center and upper right positions of the joystick to compute the
125relative position.
126.Pp
127This calibration is not part of the driver.
128.Sh FILES
129.Bl -tag -width Pa -compact
130.It Pa /dev/joy0
131first joystick
132.It Pa /dev/joy1
133second joystick
134.El
135.Sh SEE ALSO
136.Xr eso 4 ,
137.Xr isa 4 ,
138.Xr isapnp 4 ,
139.Xr ofisa 4 ,
140.Xr pci 4 ,
141.Xr pnpbios 4
142.Sh AUTHORS
143Jean-Marc Zucconi wrote the
144.Fx
145driver.  Matthieu Herrb ported it to
146.Nx
147and wrote this manual page.
148