man.bsd.lv manual page server

Manual Page Search Parameters

JOY(4) Device Drivers Manual JOY(4)

joyjoystick device driver

To link into the kernel:
device joy

To load as a kernel loadable module:

kldload joy


#include <sys/joystick.h>

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 () 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.

perl -e 'open(JOY,"/dev/joy0")||die;while(1)
{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\n";sleep(1);}'

Several () calls are also available. They take an argument of type int *

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.
int *limit
Get the time limit (in microseconds) used for reading the joystick status.
int *offset
Set the value to be added to the X position when reading the joystick status.
int *offset
Set the value to be added to the Y position when reading the joystick status.
int *offset
Get the value which is added to the X position when reading the joystick status.
int *offset
Get the value which is added to the Y position when reading the joystick status.

The pinout of the DB-15 connector is as follows:

  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 techref, the time is given by Time = 24.2e-6s + 0.011e-6s * R/Ohms

/dev/joy?
joystick device files

The joystick driver appeared in FreeBSD 2.0.5.

Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr>

January 23, 1995 DragonFly-5.6.1