Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

joy(4) [netbsd man page]

JOY(4)							   BSD Kernel Interfaces Manual 						    JOY(4)

NAME
joy -- game adapter driver SYNOPSIS
joy* at acpi? joy* at eap? joy* at eso? joy0 at isa? port 0x201 joy* at isapnp? joy* at ofisa? joy* at pci? joy* at pnpbios? index ? DESCRIPTION
This driver provides access to the game adapter. The lower bit in the minor device number selects the joystick: 0 is the first joystick and 1 is the second. The game control adapter allows up to two joysticks to be attached to the system. The adapter plus the driver convert the present resistive value to a relative joystick position. On receipt of an output signal, four timing circuits are started. By determining the time required for the circuit to time-out (a function of the resistance), the paddle position can be determined. The adapter could be used as a general purpose I/O card with four analog (resistive) inputs plus four digital input points. Applications may call ioctl(2) on a game adapter driver file descriptor to set and get the offsets of the two potentiometers and the maximum time-out value for the circuit. The ioctl(2) commands are listed in <machine/joystick.h> and currently are: JOY_SETTIMEOUT Sets the maximum time-out for the adapter. JOY_GETTIMEOUT Returns the current maximum time-out. JOY_SET_X_OFFSET Sets an offset on X value. JOY_GET_X_OFFSET Returns the current X offset. JOY_SET_Y_OFFSET Sets an offset on Y value. JOY_GET_Y_OFFSET Returns the current Y offset. All these commands take an integer parameter. read(2) on the file descriptor returns a joystick structure: struct joystick { int x; int y; int b1; int b2; }; The fields have the following functions: x current X coordinate of the joystick (or position of paddle 1) y current Y coordinate of the joystick (or position of paddle 2) b1 current state of button 1 b2 current state of button 2 The b1 and b2 fields in struct joystick are set to 1 if the corresponding button is down, 0 otherwise. The x and y coordinates are supposed to be between 0 and 255 for a good joystick and a good adapter. Unfortunately, because of the hardware hack that is used to measure the position (by measuring the time needed to discharge an RC circuit made from the joystick's potentiometer and a capacitor on the adapter), calibration is needed to determine exactly what values are returned for a specific joystick/adapter combination. Incorrect hardware can yield negative or values greater than 255. A typical calibration procedure uses the values returned at lower left, center and upper right positions of the joystick to compute the rela- tive position. This calibration is not part of the driver. FILES
/dev/joy0 first joystick /dev/joy1 second joystick SEE ALSO
acpi(4), eap(4), eso(4), isa(4), isapnp(4), ofisa(4), pci(4), pnpbios(4) AUTHORS
Jean-Marc Zucconi wrote the FreeBSD driver. Matthieu Herrb ported it to NetBSD and wrote this manual page. BSD
July 22, 2006 BSD

Check Out this Related Man Page

JOY(4)							   BSD Kernel Interfaces Manual 						    JOY(4)

NAME
joy -- joystick device driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device joy Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): joy_load="YES" In /boot/device.hints: hint.joy.0.at="isa" hint.joy.0.port="0x201" hint.joy.1.at="isa" hint.joy.1.port="0x201" #include <sys/joystick.h> DESCRIPTION
The joystick device driver allows applications to read the status of the PC joystick. This device may be opened by only one process at a time. The joystick status is read from a structure via a read() call. The structure is defined in the header file as follows: struct joystick { int x; /* x position */ int y; /* y position */ int b1; /* button 1 status */ int b2; /* button 2 status */ }; Positions are typically in the range 0-2000. One line perl example: perl -e 'open(JOY,"/dev/joy0")||die;while(1) {sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j ";sleep(1);}' ioctl calls Several ioctl() calls are also available. They take an argument of type int * JOY_SETTIMEOUT int *limit Set the time limit (in microseconds) for reading the joystick status. Setting a value too small may prevent to get correct values for the positions (which are then set to -2147483648), however this can be useful if one is only interested by the buttons status. JOY_GETTIMEOUT int *limit Get the time limit (in microseconds) used for reading the joystick status. JOY_SET_X_OFFSET int *offset Set the value to be added to the X position when reading the joystick status. JOY_SET_Y_OFFSET int *offset Set the value to be added to the Y position when reading the joystick status. JOY_GET_X_OFFSET int *offset Get the value which is added to the X position when reading the joystick status. JOY_GET_Y_OFFSET int *offset Get the value which is added to the Y position when reading the joystick status. TECHNICAL SPECIFICATIONS
The pinout of the DB-15 connector is as follow: 1 XY1 (+5v) 2 Switch 1 3 X1 (potentiometer #1) 4 Switch 1 (GND) 5 Switch 2 (GND) 6 Y1 (potentiometer #2) 7 Switch 2 8 N.C. 9 XY2 (+5v) 10 Switch 4 11 X2 (potentiometer #3) 12 Switch 3&4 (GND) 13 Y2 (potentiometer #4) 14 Switch 3 15 N.C. Pots are normally 0-150k variable resistors (0-100k sometimes), and according to the IBM technical reference, the time is given by Time = 24.2e-6s + 0.011e-6s * R/Ohms FILES
/dev/joy? joystick device files HISTORY
The joy driver appeared in FreeBSD 2.0.5. AUTHORS
Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr> BSD
January 23, 1995 BSD
Man Page