Difference between revisions of "Linux Joysticks and Gamepads"
m (Created page with '== Setting up the XBox 360 Controller in Oolite ==') |
m |
||
| (39 intermediate revisions by 7 users not shown) | |||
| Line 1: | Line 1: | ||
| − | == | + | [[File:PS3 Controller.jpeg|right|320px]] |
| + | == Overview == | ||
| + | |||
| + | Generally speaking, Linux is quite good with joystick and gamepad 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. This article provides information on setting up game controllers so that they work well in Oolite Linux. | ||
| + | |||
| + | == Calibrating a Joystick or Gamepad == | ||
| + | |||
| + | Although Oolite provides options to set up dead zones, a full calibration within the game is not possible. The best way to calibrate game controllers on Linux is using a utility such as [https://github.com/Grumbel/jstest-gtk jstest-gtk] which will probably be present in your distribution's Software Manager. Launch the ''jstest-gtk'' gui (it will probably be located in the System Menu) and, underneath the name of your joystick, it will list the device details, such as "Device: /dev/input/js0". Keep a record of this device information. | ||
| + | |||
| + | After calibrating and before closing the gui, execute the following command in a shell to store the calibration information: | ||
| + | |||
| + | sudo jscal-store /dev/input/js0 | ||
| + | |||
| + | Ensure you use the device information you recorded earlier in place of ''/dev/input/js0''. | ||
| + | |||
| + | == Button Detection & Axis Range Problems == | ||
| + | |||
| + | If your calibration is ignored, then you need to do the following: add the appropriate environment variable to either the ''/etc/environment'' file, or the ''.bashrc'' startup script. | ||
| + | |||
| + | [https://help.ubuntu.com/community/EnvironmentVariables 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 text editor, add the following (on a new line) to the file, and save: | ||
| + | |||
| + | SDL_JOYSTICK_DEVICE="/dev/input/js0" | ||
| + | |||
| + | Again, use the device information you recorded earlier. | ||
| + | |||
| + | 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, 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. | ||
| + | |||
| + | Explanation: Oolite uses [https://www.libsdl.org/ Simple DirectMedia Layer (SDL)]. For unknown reasons, it appears that sometimes SDL takes raw input from the evdev device drivers, instead of using the correct joystick device. This fix forces SDL to use the "real" joystick driver for input. | ||
| + | |||
| + | == Using Saved Calibration == | ||
| + | |||
| + | The calibration will be forgotten after rebooting, so to ensure the saved calibration is used, make a file called for example ''run_oolite'' with the following contents: | ||
| + | |||
| + | #!/bin/bash | ||
| + | jscal-restore /dev/input/js0 | ||
| + | cd ${1%/*} | ||
| + | $1 | ||
| + | |||
| + | Again, use the device information you recorded earlier. Save the file (which is a bash script) in a folder which is in your system's ''PATH'' or you can save it in the same folder as the ''oolite'' executable. The ''oolite'' executable is located in a folder like this: ''/home/USERNAME/GNUstep/Applications/Oolite/'' which hereafter we'll call ''OOLITE_FOLDER''. Make that file executable (which can usually be done in your distro's file explorer by right clicking on the file and choosing to edit Permissions). Then you can run Oolite in a shell using: | ||
| + | |||
| + | OOLITE_FOLDER/run_oolite OOLITE_FOLDER/oolite | ||
| + | |||
| + | The first ''OOLITE_FOLDER'' in the command above should be removed if ''run_oolite'' is in your system's ''PATH''. | ||
| + | |||
| + | If you are using the [https://github.com/OoliteProject/OoliteStarter Oolite Starter] then replace ''OOLITE_FOLDER/oolite'' with the path to Oolite Starter which will look something like: ''/opt/oolitestarter-innocuous/bin/OoliteStarter_innocuous''. | ||
| + | |||
| + | == Mapping Axes and Buttons to Keyboard Key Presses == | ||
| + | |||
| + | Sometimes it is desirable to have an axis act more like a keyboard key press, for example to increase and decrease speed. This can be achieved with the utility [https://github.com/AntiMicroX/antimicrox AntiMicroX], a graphical program used to map joystick and gamepad controls to keyboard, mouse, scripts and macros. More information on Oolite's default keyboard controls can be found [https://wiki.alioth.net/index.php/Oolite_Keyboard_Controls here]. Once you have set up AntiMicroX the way you want, you can use your configuration by modifying the ''run_oolite'' script described earlier: | ||
| + | |||
| + | #!/bin/bash | ||
| + | jscal-restore /dev/input/js0 | ||
| + | antimicrox --tray & | ||
| + | cd ${1%/*} | ||
| + | $1 | ||
| + | |||
| + | Again, use the device information you recorded earlier. | ||
| + | |||
| + | == Other problems == | ||
| + | |||
| + | Should you require further guidance in creating or 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 [https://bb.oolite.space/viewforum.php?f=9 Oolite-Linux forum]. The forum has several Linux gurus available, who would be more than happy to assist. | ||
| + | |||
| + | == Links == | ||
| + | *[[Joysticks and Gamepads]] | ||
| + | *[[Joysticks: Guide to Setting Up]] | ||
| + | *[[Dizzy's guide to Setting up Joystick Axis Profiles]] | ||
| + | *[[Keyboard Issues]] | ||
| + | |||
| + | [[Category:Oolite]][[Category:Help pages]] | ||
Latest revision as of 22:12, 15 July 2025
Contents
Overview
Generally speaking, Linux is quite good with joystick and gamepad 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. This article provides information on setting up game controllers so that they work well in Oolite Linux.
Calibrating a Joystick or Gamepad
Although Oolite provides options to set up dead zones, a full calibration within the game is not possible. The best way to calibrate game controllers on Linux is using a utility such as jstest-gtk which will probably be present in your distribution's Software Manager. Launch the jstest-gtk gui (it will probably be located in the System Menu) and, underneath the name of your joystick, it will list the device details, such as "Device: /dev/input/js0". Keep a record of this device information.
After calibrating and before closing the gui, execute the following command in a shell to store the calibration information:
sudo jscal-store /dev/input/js0
Ensure you use the device information you recorded earlier in place of /dev/input/js0.
Button Detection & Axis Range Problems
If your calibration is ignored, then you need to do the following: add the appropriate environment variable to either the /etc/environment file, or the .bashrc startup script.
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 text editor, add the following (on a new line) to the file, and save:
SDL_JOYSTICK_DEVICE="/dev/input/js0"
Again, use the device information you recorded earlier.
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, 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.
Explanation: Oolite uses Simple DirectMedia Layer (SDL). For unknown reasons, it appears that sometimes SDL takes raw input from the evdev device drivers, instead of using the correct joystick device. This fix forces SDL to use the "real" joystick driver for input.
Using Saved Calibration
The calibration will be forgotten after rebooting, so to ensure the saved calibration is used, make a file called for example run_oolite with the following contents:
#!/bin/bash
jscal-restore /dev/input/js0
cd ${1%/*}
$1
Again, use the device information you recorded earlier. Save the file (which is a bash script) in a folder which is in your system's PATH or you can save it in the same folder as the oolite executable. The oolite executable is located in a folder like this: /home/USERNAME/GNUstep/Applications/Oolite/ which hereafter we'll call OOLITE_FOLDER. Make that file executable (which can usually be done in your distro's file explorer by right clicking on the file and choosing to edit Permissions). Then you can run Oolite in a shell using:
OOLITE_FOLDER/run_oolite OOLITE_FOLDER/oolite
The first OOLITE_FOLDER in the command above should be removed if run_oolite is in your system's PATH.
If you are using the Oolite Starter then replace OOLITE_FOLDER/oolite with the path to Oolite Starter which will look something like: /opt/oolitestarter-innocuous/bin/OoliteStarter_innocuous.
Mapping Axes and Buttons to Keyboard Key Presses
Sometimes it is desirable to have an axis act more like a keyboard key press, for example to increase and decrease speed. This can be achieved with the utility AntiMicroX, a graphical program used to map joystick and gamepad controls to keyboard, mouse, scripts and macros. More information on Oolite's default keyboard controls can be found here. Once you have set up AntiMicroX the way you want, you can use your configuration by modifying the run_oolite script described earlier:
#!/bin/bash
jscal-restore /dev/input/js0
antimicrox --tray &
cd ${1%/*}
$1
Again, use the device information you recorded earlier.
Other problems
Should you require further guidance in creating or 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.