Home » Questions » Computers [ Ask a new question ]

Linux joystick seems mis-calibrated in an SDL game (Freespace 2 Open) [closed]

Linux joystick seems mis-calibrated in an SDL game (Freespace 2 Open) [closed]

I have a USB joystick (Saitek Cyborg 3D) which shows up on my recently installed Ubuntu 9.04 box as /dev/input/js0, and jstest is showing values in the range +-32767 as I would expect. I just dug up a copy of FreeSpace Open, a game which uses SDL and worked with no problems on a previous Ubuntu install about a year ago, and the joystick seems very mis-calibrated. All axes (X, Y, twist, throttle) seem at least 20% off-center. The X and Y axes at least definitely aren't reaching their end points.

Asked by: Guest | Views: 31
Total answers/comments: 1
Guest [Entry]

"I noticed the problem in d2x (a Descent port), which also uses SDL, so I went digging in SDL. testjoystick from the SDL source showed the problem as well. Looking at the SDL linux joystick driver, the problem is mentioned. Search for joydev_pattern in that file and you'll see what they're doing; search for calibrate and they do mention this problem. Basically they use /dev/input/event6 (or whichever) in preference to /dev/input/js0, unless compiled with --disable-input-events, even knowing the event device can't be calibrated (i.e. the calibration set on js0 will be ignored).

Having found all that, Google searches involving that configure option reveal that hidden away in the comments to a Linux howto for fs2_open, someone has actually had this problem already.

I have reported this bug to Ubuntu. To work around, pick any one of:

Set SDL_JOYSTICK_DEVICE=/dev/input/js0 (you could put this in /etc/environment and reboot to apply it everywhere). Edit: SDL will still have the evdev device as a second joystick, so in games like d2x that respond to the second joystick as well by default, visit the options screen and remove those extra bindings.
Recompile libSDL with --disable-input-events.
rmmod evdev (quite likely to lose any unusual input devices you have)."