Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

joy(4) [netbsd man page]

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

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

joystick_getaxis(3)						Svgalib User Manual					       joystick_getaxis(3)

joystick_getaxis, joystick_getbutton - query the current state of a joystick. SYNOPSIS
#include <vgajoystick.h> char joystick_getaxis(int joydev, int a); char joystick_getbutton(int joydev, int b); DESCRIPTION
These functions query the current state of the joystick joydev. Actually this is the state found during the last call to joy- stick_update(3) with the default joystick event handler active. joystick_getaxis(joydev, a) return the current state of the given axis (usually it is x - 0, y - 1, z - 1, ...) in range -128 .. 127. Some effort is made such that the center position is close to 0. Note that especially the version 0.* protocol joystick calibration is very bad. You won't usually see the extrem values on the extreme position. Also, the center position will be close to zero but often not be exactly zero and return values will also vary slightly from call to call even when the user did not move the joystick. joystick_getbutton(joydev, b) returns the state of a button. It returns 1 for pressed button and 0 else. Note that no hardware checks for button clicks. The button press is only detected during a call to joystick_update(3) (at least in the 0.* protocol). NOTE: The functions simply return the data passed to the default joystick event handler! For your convenience, the following stortcuts have been established by use of the preprocessor: joystick_button1(i) for joystick_getbutton(i, 0). joystick_button2(i) for joystick_getbutton(i, 1). joystick_button3(i) for joystick_getbutton(i, 2). joystick_button4(i) for joystick_getbutton(i, 3). joystick_x(i) for joystick_getaxis(i, 0). joystick_y(i) for joystick_getaxis(i, 1). joystick_z(i) for joystick_getaxis(i, 2). joystick_getb1() for joystick_getbutton(0, 0). joystick_getb2() for joystick_getbutton(0, 1). joystick_getb3() for joystick_getbutton(0, 2). joystick_getb4() for joystick_getbutton(0, 3). joystick_getx() for joystick_getaxis(0, 0). joystick_gety() for joystick_getaxis(0, 1). joystick_getz() for joystick_getaxis(0, 2). CAVEATS
This function is only available in ELF versions of svgalib. Due to backwards compatibility issues it cannot be used with shared a.out libs. SEE ALSO
svgalib(7), vgagl(7), libvga.config(5), joytest(6), mjoytest(6), joystick_init(3), joystick_close(3), joystick_update(3), joy- stick_sethandler(3), joystick_setdefaulthandler(3), joystick_getnumaxes(3), joystick_getnumbuttons(3). AUTHOR
The svgalib joystick handler was mostly done by Daniel Engstr"om <>. Multiple joystick, VC switching support and code to glue it into svgalib by Michael Weller <>. Part of the code is based on code from C. Smith and Vojtech Pavlik. Svgalib 1.3.0 14 April 1998 joystick_getaxis(3)
Man Page