Linux/Ubuntu: Joystick calibration

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Linux/Ubuntu: Joystick calibration

Post by ^rooker »

[PROBLEM]
While researching practical usability of an "analogue-gameport to USB device" for retro-computing preservation, I ran into issues on Ubuntu (12.04) Linux:
  • Used jstest-gtk to calibrate
  • jstest-gtk values/behavior displayed made sense
However, whenever I tried to use the joystick in an application, it drifted - and only half of each axis was recognized.
Buttons worked fine.

So something was wrong with the calibration.

It seems that there's a conflict between the joystick as "/dev/input/jsX" and "/dev/input/eventX" (X being a numerical index).

Min/Max values for /dev/input/js0 (Axis 0 - left/right)
-32767 to +32767
While "evtest" shows completely different, asymmetrical values:
42 to 150

[SOLUTION]
Quoting README of "jstest-gtk" where the conflict issue of joystick-device vs. event-device is mentioned:

Depending on what version and what compilation flags where used, your version of SDL might not use the joystick interface at all, but instead use the /dev/input/event* device directly. That means that any calibration or button/axis mapping will be ignored, as those apply to the joystick interface, not evdev.
"To work around that you have to set an environment variable that forces SDL to use the joystick device:"

Code: Select all

$ SDL_JOYSTICK_DEVICE="/dev/input/js0"
$ export SDL_JOYSTICK_DEVICE
Joystick behaves correctly now! :D 8)

Might update this article once I've tried how joystick stuff behaves in more recent versions of Linux/Ubuntu...


Links:
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Issues with DosBox

Post by ^rooker »

Unfortunately, the Joystick only works properly now in some programs, but the behavior is still the same in DosBox.
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Issues with RetroPie

Post by ^rooker »

Same behavior issues on RetroPie:
  • X-axis (#0): Left works, right does NOT
  • Y-axis (#1): Up works, Down does NOT
Values shown by "jstest /dev/input/js0" (SSH on RetroPie):
X-axis (#0)
  • Left = -32767
  • Center = -14864
  • Right = 0
Y-axis (#1)
  • Down = 0
  • Center = -15878
  • Up = -32767
Tried to calibrate the joystick/gamepad using:

Code: Select all

$ jscal -c /dev/input/js0
Values during calibration are:
X/Y = min.0 / center.68 / max.133

Here's the output:
Joystick has 4 axes and 4 buttons.
Correction for axis 0 is broken line, precision is 0.
Coeficients are: 112, 142, 5534751, 5534751
Correction for axis 1 is broken line, precision is 0.
Coeficients are: 112, 142, 5534751, 5534751
Correction for axis 2 is broken line, precision is 0.
Coeficients are: 112, 142, 5534751, 5534751
Correction for axis 3 is broken line, precision is 0.
Coeficients are: 112, 142, 5534751, 5534751

Calibrating precision: wait and don't touch the joystick.
Done. Precision is: 255, 255
Axis: 0: 0
Axis: 1: 0
Axis: 2: 0
Axis: 3: 0

Move axis 0 to minimum position and push any button.
Hold ... OK.
Move axis 0 to center position and push any button.
Hold ... OK.
Move axis 0 to maximum position and push any button.
Hold ... OK.
Move axis 1 to minimum position and push any button.
Hold ... OK.
Move axis 1 to center position and push any button.
Hold ... OK.
Move axis 1 to maximum position and push any button.
Hold ... OK.
Move axis 2 to minimum position and push any button.
Hold ... OK.
Move axis 2 to center position and push any button.
Hold ... OK.
Move axis 2 to maximum position and push any button.
Hold ... OK.
Move axis 3 to minimum position and push any button.
Hold ... OK.
Move axis 3 to center position and push any button.
Hold ... OK.
Move axis 3 to maximum position and push any button.
Hold ... OK.

Setting correction to:
Correction for axis 0: broken line, precision: 0.
Coeficients: 68, 68, 8388352, 8134160
Correction for axis 1: broken line, precision: 0.
Coeficients: 64, 64, 9099229, 8947575
Correction for axis 2: broken line, precision: 0.
Coeficients: 255, 255, 2147483647, 2147483647
Correction for axis 3: broken line, precision: 0.
Coeficients: 255, 255, 2147483647, 2147483647
To be continued...
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply