1.\" $NetBSD: joy.4,v 1.3 2002/04/25 00:59:25 kleink 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 games 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 games adapter. The lower bit in the 46minor device number selects the joystick: 0 is the first joystick and 471 is the second. 48.Pp 49The game control adapter allows up to two joysticks to be attached to 50the system. The adapter plus the driver convert the present resistive 51value to a relative joystick position. On receipt of an output signal, 52four timing circuits are started. By determining the time required for 53the circuit to time-out (a function of the resistance), the paddle 54position can be determined. The adapter could be used as a general 55purpose I/O card with four analog (resistive) inputs plus four digital 56input points. 57.Pp 58Applications may call 59.Xr ioctl 2 60on a game adapter driver file descriptor 61to set and get the offsets of the two potentiometers and the maximum 62time-out value for the circuit. The 63.Xr ioctl 2 64commands are listed in 65.Pa Aq machine/joystick.h 66and currently are: 67.Pp 68.Bl -tag -width JOY_GET_X_OFFSET -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 this commands take an integer parameter. 84.Pp 85.Xr read 2 86on the file descriptor returns a 87.Fa joystick 88structure: 89.Bd -literal -offset indent 90struct joystick { 91 int x; 92 int y; 93 int b1; 94 int b2; 95}; 96.Ed 97.Pp 98The fields have the following functions: 99.Bl -tag -width xxx 100.It Fa x 101current X coordinate of the joystick (or position of paddle 1) 102.It Fa y 103current Y coordinate of the joystick (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 b1 and b2 fields in struct joystick are set to 1 if the 111corresponding button is down, 0 otherwise. 112.Pp 113The x and y coordinates are supposed to be between 0 and 255 for a 114good joystick and a good adapter. Unfortunately, because of the 115hardware hack that is used to measure the position (by measuring the 116time needed to discharge an RC circuit made from the joystick's 117potentiometer and a capacitor on the adapter), calibration 118is needed to determine exactly what values are returned for a specific 119joystick/adapter combination. Incorrect hardware can yield negative or 120> 255 values. 121.Pp 122A typical calibration procedure uses the values returned at lower 123left, center and upper right positions of the joystick to compute the 124relative position. 125.Pp 126This calibration is not part of the driver. 127.Sh FILES 128.Bl -tag -width Pa -compact 129.It Pa /dev/joy0 130first joystick 131.It Pa /dev/joy1 132second joystick 133.El 134.Sh SEE ALSO 135.Xr eso 4 , 136.Xr isa 4 , 137.Xr isapnp 4 , 138.Xr ofisa 4 , 139.Xr pci 4 , 140.Xr pnpbios 4 141.Sh AUTHORS 142Jean-Marc Zucconi wrote the 143.Fx 144driver. Matthieu Herrb ported it to 145.Nx 146and wrote this manual page. 147