joystick (4)
Leading comments
shorthand for double quote that works everywhere.
NAME
joystick - Joystick input driverSYNOPSIS
Snipped for xorg.conf.d(5):Section N'34'InputClassN'34' Identifier N'34'joystick-allN'34' Driver N'34'joystickN'34' Option N'34'MatchIsJoystickN'34' N'34'onN'34' Option N'34'MatchDevicePath N'34'/dev/input/event*N'34' ... EndSection
DESCRIPTION
joystick is an Xorg input driver for controlling the pointer with a joystick device.- Use this driver, if you want to
-
- generate
cursor movement,
perform button or key events to control desktop and applications
- generate cursor key events for playing legacy games, that have no native joystick support
- Do not use, if you want to
-
- play games, that have native joystick support
- use XI2 applications. The evdev(4) driver will suffice for those in most cases.
You may mix above scenarios by setting the device
floating.
The driver reports relative cursor movement, button and key events,
as well as raw axis values through valuators.
SUPPORTED HARDWARE
The joystick input module can be used on top of the following kernel devices:- Linux's evdev device - Linux's joystick device - BSD's usbhid device
Every joystick supported by the kernel should be supported by the joystick input driver. The joystick is assumed to be calibrated and reporting axis values between -32768 and 32768. See the Linux kernel documentation for a complete list of supported devices.
There is no support for force feedback at the moment.
CONFIGURATION DETAILS
Please refer to xorg.conf(5) for general configuration details. This section only covers configuration details specific to this driver.The following Driver Options are supported:
- Option N'34'DeviceN'34' N'34'stringN'34'
- Option N'34'PathN'34' N'34'stringN'34'
-
Specifies the device through which the joystick can be accessed. This option is mandatory and there is no default setting.
In Linux, joysticks are usually accessible through /dev/input/jsX or /dev/input/eventX.
In *BSD, joysticks are usually recognized as /dev/uhidX. - Option N'34'AutoRepeatN'34' N'34'delay rateN'34'
- Sets the auto repeat behaviour for key events. delay is the time in milliseconds before a key starts repeating. rate is the number of times a key repeats per second. Default: Xorg default
- Option N'34'DebugLevelN'34' N'34'integerN'34'
- Controls the verbosity of the driver for debugging purposes. The higher the DebugLevel, the more output is produced. Default: 0
- Option N'34'MapButton<number>N'34' N'34'stringN'34'
-
Sets the mapping of a joystick button to the desired action. Button counting starts with
1,
Possible options are:
-
- none
- Don't do anything
- N'34'button=<number>N'34'
- Generate a pointer button event with button number (starting with 1).
- N'34'axis=[<factor>]<axis>N'34'
-
Where
<axis>
is one of:
x, y, zx, zy
and <factor> is an optional amplifier of the axis, like -, +, -5, 0.4, 1.3, ... Negative values invert the direction. Default: 1.0 - N'34'amplify=<factor>N'34'
- Amplifies the movement of all axes by the given factor when this button is held down. Different factors can be combined.
- N'34'key=<scancode>[,<scancode>[,<scancode>[,<scancode>]]]
-
When button is pressed, a series of keydown events with the specified scancodes is
generated. When the button is released, matching keyup events in the opposite
order are generated. You can specify up to 4 scancodes per button.
See special section about key events below. - N'34'disable-mouseN'34'
- N'34'disable-keysN'34'
- N'34'disable-allN'34'
-
Disables either the generation of mouse events, key events or the generation of
all X events by the driver. Press button again to allow the driver to generate
events again.
You may also set the device floating from client space to prevent it from generating core events.
-
- Option N'34'MapAxis<number>N'34' N'34'stringN'34'
-
Sets the mapping of the axis to the desired action. Axis counting starts with
1,
the parameter may contain:
-
- N'34'mode=<string>N'34'
-
Where
<string>
can be one of:
none, relative, accelerated, absolute
- N'34'valuatorN'34'
-
Send extra valuator events for this axis. The valuators will be numbered ascending, starting with 2 (valuator 0 and 1 are reserved for pointer movement). Please consider using the evdev(4) input driver if you are only interested in XI2 features.
The range of the valuators is always -32767 to 32768. Neither mode nor axis needs to be set to generate extra valuator events. The axis will be labelled according to its physical axis number, beginning with 1 , e.g. N'34'Axis 1N'34' for the first axis (being the 3rd valuator). Default: not set. - N'34'axis=[<factor>]<axis>N'34'
-
Where
<axis>
is one of:
x, y, zx, zy, key (see keylow/keyhigh)
and <factor> is an optional amplifier of the axis, like -, +, -5, 0.4, 1.3, ... Negative values will invert the movement. Default: 1.0 - N'34'keylow=<scancode>[,<scancode>[,<scancode>[,<scancode>]]]
- N'34'keyhigh=<scancode>[,<scancode>[,<scancode>[,<scancode>]]]
-
When the axis is moved out of the deadzone, a series of keydown events according
to the direction of the movement is generated. When the axis is released, matching keyup
events in opposite order will be generated. You can specify up to 4 scancodes for each direction.
keylow defines the keys to be generated when the axis is moved in negative direction (left or up), keyhigh defines the keys to be generated when the axis is moved in positive direction (right or down).
If mode is set to relative: The driver will emulate autorepeat according to the current value of the axis. A keydown and subsequent keyup event will be generated in short time intervals. To modify that interval and the autorepeat speed, supply the N'34'axis=[<factor>]KEYN'34' parameter.
If mode is set to accelerated: Keydown and keyup events will be generated repeatedly. The time between a keydown and a keyup event corresponds to the deflection of the axis. If the axis is deflected by 30%, the key will be considered to be down 300ms out of 1 second. The exact intervals may vary and can be adjusted with the amplify parameter. If the axis is deflected by 100%, there will only be one keydown event, so the key is considered down all the time. The keys will be autorepeated according to the Xorg keyboard settings.
See special section about key events below. - N'34'deadzone=<number>N'34'
- Sets the unresponsive range of the axis to <number>. This can be between 0 and 30000. Default: 5000
-
- Option N'34'StartKeysEnabledN'34' N'34'booleanN'34'
- Set to False to disable key event generation after startup. You can toggle key event generation with the disable-keys button mapping. Default: enabled
- Option N'34'StartMouseEnabledN'34' N'34'booleanN'34'
- Set to False to disable mouse event generation after startup. You can toggle mouse event generation with the disable-mouse button mapping. Default: enabled
DEFAULT CONFIGURATION
The default configuration is as follows:Option N'34'DebugLevelN'34' N'34'0N'34' Option N'34'StartKeysEnabledN'34' N'34'TrueN'34' Option N'34'StartMouseEnabledN'34' N'34'TrueN'34' Option N'34'MapButton1N'34' N'34'button=1N'34' Option N'34'MapButton2N'34' N'34'button=2N'34' Option N'34'MapButton3N'34' N'34'button=3N'34' Option N'34'MapButton4N'34' N'34'noneN'34' ... Option N'34'MapAxis1N'34' N'34'mode=relative axis=+1x deadzone=5000N'34' Option N'34'MapAxis2N'34' N'34'mode=relative axis=+1y deadzone=5000N'34' Option N'34'MapAxis3N'34' N'34'mode=relative axis=+1zx deadzone=5000N'34' Option N'34'MapAxis4N'34' N'34'mode=relative axis=+1zy deadzone=5000N'34' Option N'34'MapAxis5N'34' N'34'mode=accelerated axis=+1x deadzone=5000N'34' Option N'34'MapAxis6N'34' N'34'mode=accelerated axis=+1y deadzone=5000N'34' Option N'34'MapAxis7N'34' N'34'mode=noneN'34' ...
ACCELERATED AXIS CONFIGURATION
Accelerated mode should be selected, if the axis is a directional pad, which reports only three states: negative, center, positive. It will result in smoothly accelerated movement when the axis is deflected. An optional factor will affect the acceleration and final speed.This example will set up the axis as scrolling vertically inverted, with half the speed:
Option N'34'MapAxis1N'34' N'34'mode=accelerated axis=-0.5zyN'34'
This example maps four buttons to the four pointer directions, so you can use the buttons like a d-pad. The movement will be accelerated with half the normal speed:
Option N'34'MapButton1N'34' N'34'axis=+0.5xN'34' Option N'34'MapButton2N'34' N'34'axis=-0.5xN'34' Option N'34'MapButton3N'34' N'34'axis=+0.5yN'34' Option N'34'MapButton4N'34' N'34'axis=-0.5yN'34'
ABSOLUTE AXIS CONFIGURATION
In absolute axis mode, the position of the cursor will match the position of the configured axis, but relative to the previous position of the cursor. You can specify the range in which the cursor can move. The default range is the screen size.In this example the first axis gets a range from left to the right of the screen. The second axis gets a total range of 200 pixels, 100 to the top and 100 to the bottom:
Option N'34'MapAxis1N'34' N'34'mode=absolute axis=xN'34' Option N'34'MapAxis2N'34' N'34'mode=absolute axis=200yN'34'
GENERATING KEY EVENTS
Providing a N'34'key=<scancode>[,<scancode>[...]]N'34' option will generate X Events with specified scancodes. When the button/axis is released, the keys will be released in opposite order.If you want a certain KeySym, look up the matching scancode using xmodmap -pk. The scancodes depend on the configured keyboard layout. You can also use unused keycodes and map them to a KeySym of your choice using xmodmap(1).
You can specify up to 4 scancodes per joystick button/axis, which can be used for modificators to get the KeySym you want.
Examples:
Option N'34'MapButton1N'34' N'34'key=64,23N'34'will generate Alt_L+Tab when the button is pressed.
Option N'34'MapButton1N'34' N'34'key=50,40N'34'will generate a Shift_L+d which will result in an uppercase d.
Option N'34'MapButton1N'34' N'34'key=65N'34'will result in a space key.
Option N'34'MapAxis1N'34' N'34'mode=relative keylow=113 keyhigh=114 axis=0.5keyN'34' Option N'34'MapAxis2N'34' N'34'mode=relative keylow=111 keyhigh=116N'34' Option N'34'MapAxis3N'34' N'34'mode=accelerated keylow=113 keyhigh=114N'34' Option N'34'MapAxis4N'34' N'34'mode=accelerated keylow=111 keyhigh=116N'34'will map the first and third axis to the arrow keys left and right and the second and fourth axis to the arrow keys up and down.
The keys for the first two axes will be generated in an interval according to the value of the axis. The autorepeat speed of the first axis will be half the speed of that of the second axis. The keys for the third and fourth axis are generated once when the axis moves out of the deadzone and when it moves back into the deadzone. X.Org will autorepeat those keys according to current keyboard settings.
XI2 Events
If you only care about raw valuator events instead of using the joystick to control the cursor, consider using the evdev(4) input driver. If you still use the joystick driver for raw events, make sure to unmap all axes/buttons and add the valuator option to the axes:Option N'34'MapAxis1N'34' N'34'mode=none valuatorN'34' Option N'34'MapAxis2N'34' N'34'mode=none valuatorN'34' Option N'34'MapAxis3N'34' N'34'mode=none valuatorN'34' Option N'34'MapAxis4N'34' N'34'mode=none valuatorN'34' ... Option N'34'MapButton1N'34' N'34'button=1N'34' Option N'34'MapButton2N'34' N'34'button=2N'34' Option N'34'MapButton3N'34' N'34'button=3N'34' Option N'34'MapButton4N'34' N'34'button=4N'34' Option N'34'MapButton5N'34' N'34'button=5N'34' ...
Remember, that valuators 0 and 1 are reserved for pointer movement, additional axes will start with valuator 2.
You might also want to set the device "floating" to stop it from reporting core events:
Option N'34'FloatingN'34' N'34'trueN'34'
NOTES
It is not recommended to enable the joystick input driver by default unless explicitely requested by the user.Configuration through InputClass sections is recommended in X servers 1.8 and later. See xorg.conf.d(5) for more details. An example xorg.conf.d(5) snipped is provided in ${sourcecode}/config/50-joystick-all.conf
Configuration through hal fdi files is recommended in X servers 1.5, 1.6 and 1.7. An example hal policy file is still provided in ${sourcecode}/config/50-x11-input-joystick.fdi to be placed in /etc/hal/fdi/policy.