JS

Section: Devices and Network Interfaces (4)
Index Return to Main Contents
 

NAME

js - joystick device  

DESCRIPTION

These are character devices to access one or two analog joysticks.

They are typically created by:


    mknod -m 640 /dev/js0 c 15 0
    mknod -m 640 /dev/js1 c 15 1

The device is accessed via read() and ioctl() calls. These are described in the file <linux/joystick.h>.

Opening the device will return a file descriptor or -1 with errno ENODEV (if the device couldn't be opened) or EBUSY (if it is in use).

Reading the device will return a struct JS_DATA_TYPE. Several ioctl() calls are also provided to further control the joystick driver:

JS_SET_CAL - set joystick correction factor

JS_GET_CAL - get joystick correction factor

JS_SET_TIMEOUT - set timeout for reading joystick. Last arg is int*.

JS_GET_TIMEOUT - set timeout for reading joystick. Last arg is int*.

JS_SET_TIMELIMIT - set data retention time. Last arg is int*.

JS_GET_TIMELIMIT - get data retention time. Last arg is int*.

JS_GET_ALL - get all of the joystick data. Last arg is         JS_DATA_SAVE_TYPE*.

JS_SET_ALL - set all of the joystick data (except JS_BUSY). Last arg         is JS_DATA_SAVE_TYPE*.

An explanation of the timeout and timelimit values:

The timeout value represents a time delta. If the joystick cannot be read in this time, then an error is returned (ENODEV).

The timelimit value also represents a time delta. Once the joystick is successfully read, the state of the stick is stored away inside the device driver. It is considered valid for the length of the timelimit. Any reads of the joystick before the timelimit is up will receive the cached value. When the next read occurs after the timelimit, the driver actually looks at the joystick.

See also the "js" and "jscal" programs provided with the joystick driver package.

 

FILES

/dev/js0 - first joystick

/dev/js1 - second joystick

 

BUGS/LIMITATIONS

A maximum of 2 joysticks are supported.

The granularity of acquiring/releasing axes is two axes at a time (one joystick at a time).

 

AUTHOR

Art Smith (asmith@cbnewsd.att.com)

Version 0.6 changes by Jeff Tranter (tranter@software.mitel.com)

Version 0.7-8 changes by Matt Rhoten (mrhoten@oz.net) and many contributors (see joystick.c)


 

Index

NAME
DESCRIPTION
FILES
BUGS/LIMITATIONS
AUTHOR

This document was created by man2html, using the manual pages.
Time: 04:45:14 GMT, April 11, 2025