Controller configuration (driver level)

Northguy edited this page Mar 16, 2018 · 2 revisions

Controller configuration (driver level)


It can happen that a controller axis is inverted. In other words, When moving 'up' in Emulationstation or Attract mode it reports that is has mapped the 'Y-down' button of the controller. A situation where this can happen is with custom Arcade Controllers that are wired in a wrong way. This is not an issue for ES or AM, because they map the actual direction on the direction reported by the controller, but becomes an issue for applications that use the native driver output instead of the button configuration in RetroArch, Attract Mode or Emulationstation.

The driver button mapping, joystick axis and axis calibration can be changed with the commandline utilities jstest, jscal, jscal-store and jscal-restore,which are part of the joystick input driver package. When the Pixel desktop environment is installed, life can be made easy by installing jstest-gtk. The mapping requires some persistance, but with a little patience it not a major task. Please refer to the appropriate Man pages for more information on these utilities. This instruction assumes that you are using jstest-gtk.


First install the appropriate packages (if not available):

sudo apt-get install joystick

sudo apt-get install jstest-gtk

Calibration with jstest-gtk

Usage of jstest-gtk is straightforward. When running it, it will first show a page to select your joystick(s).


When selecting the appropriate device, a second screen is shown in which you can test the axes and button response. In the bottom of this screen there are two buttons, which will have you configure the button mapping and axes calibration.


Button and axis remapping

Button remapping can be done, by dragging and dropping the appropriate buttons in a new order.


Axis calibration

With axis calibration you can remove deadzones in your joystick. You can also invert the axis direction, if necessary, by ticking the box behind the axis number.


Calibration from the commandline

Calibration can also be done from commandline by using jscal. This is much less straightforward, so please study the manpages carefully on how to use these commands. Calibration and mapping is split in two separate commandline commands:

jscal -c <device> to calibrate axes

jscal - u <device> to change mappings

Persistent saving of the settings

When using jstest-gtk, the settings are not permanently saved. In order to save your settings, you need to use some commandline commands:

jscal-store <device> will store the settings for the specified device in a separate file: var/lib/joystick/joystick.state. The information for each unique device is appended to the contents of this file. An example of the contents can be found below:

NAME="ControlBlock Arcade Gamepad"
jscal -u 2,0,1,12,304,305,306,307,308,311,309,310,312,313,314,315
jscal -s 2,1,0,2,2,-268427264,-268427264,1,0,2,2,-268427264,-268427264

NAME="USB Gamepad "
jscal -u 2,0,1,10,288,289,290,291,292,293,294,295,296,297
jscal -s 2,1,0,112,142,5534751,5534751,1,0,112,142,5534751,5534751

When the appropriate device settings are stored in the joystick.state file, the changes can be made persistent by using jscal-restore <device> in a 'UDEV' rule. A 60-joystick.rules file should be available in /var/lib/udev/rules.d/. The file contains an UDEV rule which uses 'jscal-restore' to load the joystick.state file for joystick devices that are being attached. The contents of this file should be as follows:

# Restore any stored calibration for the device
ACTION=="add", KERNEL=="js*", RUN+="/lib/udev/jscal-restore %E{DEVNAME}"

# Avoid this specific gamepad disappearing (see
ACTION=="add", KERNEL=="js*", ATTRS{name}=="ACRUX USB GAMEPAD 8116", RUN+="/lib/
udev/js-acrux %E{DEVNAME}"

UDEV rules and device numbering /dev/input/js_x

Please note that the UDEV rule above maps the joystick to an arbitrary device number. The device number is mapped in order of connection. The first connected device is mapped as /dev/input/js0, the following /js1, etc.... It is not possible to use an UDEV rule to rename these mappings (although a lot of older websites say otherwise).


Wiki Home Page

Getting Started



Advanced Configuration




Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.