1995-01-25 21:41:09 +00:00
|
|
|
.Dd January 23, 1995
|
|
|
|
.Dt JOY 4
|
|
|
|
.Sh NAME
|
|
|
|
.Nm joy
|
|
|
|
.Nd joystick device driver
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Cd device joy0 at isa? port "IO_GAME"
|
|
|
|
.Fd #include <machine/joystick.h>
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The joystick device driver allows applications to read the status of
|
|
|
|
the PC joystick.
|
|
|
|
.Pp
|
|
|
|
This device may be opened by only one process at a time.
|
|
|
|
.Pp
|
1995-02-22 23:34:58 +00:00
|
|
|
The joystick status is get in an structure joystick via a read()
|
|
|
|
call. The structure is defined in the header file as follows:
|
|
|
|
.Pp
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct joystick {
|
|
|
|
int x; /* x position */
|
|
|
|
int y; /* y position */
|
|
|
|
int b1; /* button 1 status */
|
|
|
|
int b2; /* button 2 status */
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Positions are typically in the range 0-2000.
|
1995-01-25 21:41:09 +00:00
|
|
|
.Ss One line perl example:
|
|
|
|
perl -e 'open(JOY,"/dev/joy0")||die;while(1)
|
|
|
|
.br
|
|
|
|
{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}'
|
|
|
|
.Ss ioctl calls
|
|
|
|
Several ioctl() calls are also available. They take an argument of
|
|
|
|
type int *
|
|
|
|
.Bl -tag -width JOY_SET_X_OFFSET
|
|
|
|
.It Dv JOY_SET_TIMEOUT Fa 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.
|
|
|
|
.It Dv JOY_GET_TIMEOUT Fa int *limit
|
|
|
|
Get the time limit (in microseconds) used for reading the joystick
|
|
|
|
status.
|
|
|
|
.It Dv JOY_SET_X_OFFSET Fa int *offset
|
|
|
|
Set the value to be added to the X position when reading the joystick
|
|
|
|
status.
|
|
|
|
.It Dv JOY_SET_Y_OFFSET Fa int *offset
|
|
|
|
Set the value to be added to the Y position when reading the joystick
|
|
|
|
status.
|
|
|
|
.It Dv JOY_GET_X_OFFSET Fa int *offset
|
|
|
|
Get the value which is added to the X position when reading the joystick
|
|
|
|
status.
|
|
|
|
.It Dv JOY_GET_Y_OFFSET Fa int *offset
|
|
|
|
Get the value which is added to the Y position when reading the joystick
|
|
|
|
status.
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /dev/joy?
|
|
|
|
.It Pa /dev/joy?
|
|
|
|
joystick device files
|
|
|
|
.Sh AUTHOR
|
|
|
|
Jean-Marc Zucconi <jmz@cabri.obs-besancon.fr>
|
|
|
|
.Sh HISTORY
|
1995-06-25 13:58:54 +00:00
|
|
|
The joystick driver appeared in FreeBSD 2.0.5.
|