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