Joystick problems (Linux)

From Elite Wiki
Revision as of 02:48, 1 October 2015 by Diziet Sma (talk | contribs) (Overview)

Overview

Generally speaking, Linux is quite good with joystick detection and support, but sometimes things can go wrong. Failing to detect a joystick at all is fairly uncommon, and most reported problems revolve around button detection/assignment, and/or axis range. In the vast majority of cases, joystick problems in Oolite Linux have been traced back to the SDL_JOYSTICK_DEVICE being incorrectly assigned, so this article mostly focuses on that.


Joystick Detection Problems

Whilst not Oolite-specific, since xorg started using the evdev driver, default settings for evdev joystick sometimes caused it to be seen as a mouse and keyboard also. This can be solved by installing the xf86-input-joystick package, then creating a /etc/X11/xorg.conf-d/50-joystick.conf file, with the following content:

Section "InputClass"
       Identifier "joystick catchall"
       MatchIsJoystick "on"
       MatchDevicePath "/dev/input/event*"
       Driver "joystick"
       Option "StartKeysEnabled" "False"       #Disable mouse
       Option "StartMouseEnabled" "False"      #support
EndSection


The StartKeysEnabled and StartMouseEnabled options are the ones that change the default behaviour, the rest is X defaults for joystick driver.

Sensitivity Problems

Prior to Oolite v1.80, deadzone and responsiveness issues in Oolite Linux could only be solved by making use of the jscal, jstest and jstest-gtk utilities, but Oolite now has built-in joystick configuration and tuning software, which can solve these problems. A tutorial on how to set up and tune your joystick can be found here.


Button Detection & Range Problems

For unknown reasons, it appears that sometimes SDL (Simple DirectMedia Layer) takes raw input from the evdev device drivers, instead of using the correct joystick device. By adding the appropriate environment variable to either the /etc/environment file, or the .bashrc startup script, you can force SDL to use the "real" joystick driver for input.

Officially speaking, /etc/environment is the correct place for system-wide environment variables. To add the environment variable to the /etc/environment file, as root, open /etc/environment in your favourite text editor, add the following line to the file, and save:

SDL_JOYSTICK_DEVICE="/dev/input/js0"

For the change to 'take', you then need to log out and back in again. Rebooting is unnecessary.

If you prefer changing the .bashrc startup script instead (since it doesn't require root access to do so), you should add the above line to .bashrc in your Home folder. As the dot in front of the filename indicates, this is a hidden file, so you may need to set the view in your file browser to "Show Hidden Files" before it will become visible. Once done, save the file and log out, then back in.


Although rare, it sometimes happens that a joystick is assigned a device number other than 'js0'. If the above fails to work for you, this is the most likely reason.

Using your Software Manager, install the jstest-gtk package. Launch the jstest-gtk gui (it will probably be located in the System Menu under "Administration") and, underneath the name of your joystick, it will list the device details, such as "Device:/dev/input/js1". You can now edit /etc/environment or .bashrc to reflect the correct device number, save, log out and in again, after which Oolite should correctly identify your joystick, and allow you to configure it the way you want.


Other Problems

Should you require further guidance in editing the above files, or the methods given above fail to resolve, or don't address your particular problem, please don't hesitate to post a thread detailing the issue, and your attempts to fix it, to the Oolite-Linux forum. The forum has several Linux gurus available, who would be more than happy to assist.