3.\" 4.Dd January 23, 1995 5.Dt JOY 4 6.Os 7.Sh NAME 8.Nm joy 9.Nd joystick device driver 10.Sh SYNOPSIS 11To link into the kernel: 12.Cd device joy 13.Pp 14To load as a kernel loadable module: 15.Dl kldload joy 16.Pp
| 3.\" 4.Dd January 23, 1995 5.Dt JOY 4 6.Os 7.Sh NAME 8.Nm joy 9.Nd joystick device driver 10.Sh SYNOPSIS 11To link into the kernel: 12.Cd device joy 13.Pp 14To load as a kernel loadable module: 15.Dl kldload joy 16.Pp
|
17.In machine/joystick.h 18.Sh DESCRIPTION 19The joystick device driver allows applications to read the status of 20the PC joystick. 21.Pp 22This device may be opened by only one process at a time. 23.Pp 24The joystick status is read from a structure via a read() 25call. 26The structure is defined in the header file as follows: 27.Pp 28.Bd -literal -offset indent 29 struct joystick { 30 int x; /* x position */ 31 int y; /* y position */ 32 int b1; /* button 1 status */ 33 int b2; /* button 2 status */ 34 }; 35.Ed 36.Pp 37Positions are typically in the range 0-2000. 38.Ss One line perl example: 39.Bd -literal -compact 40perl -e 'open(JOY,"/dev/joy0")||die;while(1) 41{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}' 42.Ed 43.Ss ioctl calls 44Several ioctl() calls are also available. 45They take an argument of 46type int * 47.Bl -tag -width JOY_SET_X_OFFSET 48.It Dv JOY_SETTIMEOUT Fa int *limit 49Set the time limit (in microseconds) for reading the joystick 50status. 51Setting a value 52too small may prevent to get correct values for the positions (which 53are then set to -2147483648), however this can be useful if one is 54only interested by the buttons status. 55.It Dv JOY_GETTIMEOUT Fa int *limit 56Get the time limit (in microseconds) used for reading the joystick 57status. 58.It Dv JOY_SET_X_OFFSET Fa int *offset 59Set the value to be added to the X position when reading the joystick 60status. 61.It Dv JOY_SET_Y_OFFSET Fa int *offset 62Set the value to be added to the Y position when reading the joystick 63status. 64.It Dv JOY_GET_X_OFFSET Fa int *offset 65Get the value which is added to the X position when reading the joystick 66status. 67.It Dv JOY_GET_Y_OFFSET Fa int *offset 68Get the value which is added to the Y position when reading the joystick 69status. 70.El 71.Sh TECHNICAL SPECIFICATIONS 72The pinout of the DB-15 connector is as follow: 73.Bd -literal 74 1 XY1 (+5v) 75 2 Switch 1 76 3 X1 (potentiometer #1) 77 4 Switch 1 (GND) 78 5 Switch 2 (GND) 79 6 Y1 (potentiometer #2) 80 7 Switch 2 81 8 N.C. 82 9 XY2 (+5v) 83 10 Switch 4 84 11 X2 (potentiometer #3) 85 12 Switch 3&4 (GND) 86 13 Y2 (potentiometer #4) 87 14 Switch 3 88 15 N.C. 89.Ed 90.Pp 91Pots are normally 0-150k variable resistors (0-100k sometimes), and 92according to the IBM techref, the time is given by 93Time = 24.2e-6s + 0.011e-6s * R/Ohms 94.Sh FILES 95.Bl -tag -width /dev/joy? 96.It Pa /dev/joy? 97joystick device files 98.El 99.Sh AUTHORS 100.An Jean-Marc Zucconi Aq jmz@cabri.obs-besancon.fr 101.Sh HISTORY 102The joystick driver appeared in 103.Fx 2.0.5 .
| 22.In machine/joystick.h 23.Sh DESCRIPTION 24The joystick device driver allows applications to read the status of 25the PC joystick. 26.Pp 27This device may be opened by only one process at a time. 28.Pp 29The joystick status is read from a structure via a read() 30call. 31The structure is defined in the header file as follows: 32.Pp 33.Bd -literal -offset indent 34 struct joystick { 35 int x; /* x position */ 36 int y; /* y position */ 37 int b1; /* button 1 status */ 38 int b2; /* button 2 status */ 39 }; 40.Ed 41.Pp 42Positions are typically in the range 0-2000. 43.Ss One line perl example: 44.Bd -literal -compact 45perl -e 'open(JOY,"/dev/joy0")||die;while(1) 46{sysread(JOY,$x,16);@j=unpack("iiii",$x);print "@j\\n";sleep(1);}' 47.Ed 48.Ss ioctl calls 49Several ioctl() calls are also available. 50They take an argument of 51type int * 52.Bl -tag -width JOY_SET_X_OFFSET 53.It Dv JOY_SETTIMEOUT Fa int *limit 54Set the time limit (in microseconds) for reading the joystick 55status. 56Setting a value 57too small may prevent to get correct values for the positions (which 58are then set to -2147483648), however this can be useful if one is 59only interested by the buttons status. 60.It Dv JOY_GETTIMEOUT Fa int *limit 61Get the time limit (in microseconds) used for reading the joystick 62status. 63.It Dv JOY_SET_X_OFFSET Fa int *offset 64Set the value to be added to the X position when reading the joystick 65status. 66.It Dv JOY_SET_Y_OFFSET Fa int *offset 67Set the value to be added to the Y position when reading the joystick 68status. 69.It Dv JOY_GET_X_OFFSET Fa int *offset 70Get the value which is added to the X position when reading the joystick 71status. 72.It Dv JOY_GET_Y_OFFSET Fa int *offset 73Get the value which is added to the Y position when reading the joystick 74status. 75.El 76.Sh TECHNICAL SPECIFICATIONS 77The pinout of the DB-15 connector is as follow: 78.Bd -literal 79 1 XY1 (+5v) 80 2 Switch 1 81 3 X1 (potentiometer #1) 82 4 Switch 1 (GND) 83 5 Switch 2 (GND) 84 6 Y1 (potentiometer #2) 85 7 Switch 2 86 8 N.C. 87 9 XY2 (+5v) 88 10 Switch 4 89 11 X2 (potentiometer #3) 90 12 Switch 3&4 (GND) 91 13 Y2 (potentiometer #4) 92 14 Switch 3 93 15 N.C. 94.Ed 95.Pp 96Pots are normally 0-150k variable resistors (0-100k sometimes), and 97according to the IBM techref, the time is given by 98Time = 24.2e-6s + 0.011e-6s * R/Ohms 99.Sh FILES 100.Bl -tag -width /dev/joy? 101.It Pa /dev/joy? 102joystick device files 103.El 104.Sh AUTHORS 105.An Jean-Marc Zucconi Aq jmz@cabri.obs-besancon.fr 106.Sh HISTORY 107The joystick driver appeared in 108.Fx 2.0.5 .
|