We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2353

Summary: Joystick calibration impossible on Linux
Product: SDL Reporter: Manuel Reimer <manuel.reimer>
Component: joystickAssignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: ahartmetz, gabomdq, icculus, tjwhaynes
Version: HG 2.1   
Hardware: All   
OS: Linux   

Description Manuel Reimer 2014-01-19 13:39:24 UTC
There are two common ways on Linux to access a joystick.

SDL supported both up to this commit:

http://hg.libsdl.org/SDL/rev/fdaeea9e7567

It is true, that the "newer" evdev system exists for a very long time, but it is also true, that you get *raw* values from there! There is no userspace method to calibrate a joystick with this devices.

Prior to this commit it was possible to revert to the old API and use calibration this way. This is impossible, now.

How can this be resolved? Do you plan to implement something (like SDL built-in calibration) that maps raw values to calibrated values?

evdev definitively doesn't work well for joysticks. I tried this with "Frozen Bubble". The result was, that my try to map keys resulted in all keys to be mapped to "joystick down" which is detected even if I don't touch the stick, as no dead zone has been calibrated. With this setting Frozen Bubble toggled quickly between "full screen" and "window mode" until my GPU finally crashed.
Comment 1 Andreas Hartmetz 2014-02-12 04:53:03 UTC
There are a few things that joystick API does better than evdev, at least with SDL1.2.

I am using a Logitech Attack 3 joystick and a Logitech Rumblepad 2 wireless gamepad with analog sticks.
Main applications used are dxx-rebirth for the joystick and "Sir, you are being hunted" for the gamepad.

My main problem is far too large, non-configurable deadzone.
My joystick, uses USB and does not really need calibration because its raw data is already "well-formed", with a range of 0-255 and center readings of 127 or 128 (using the Joystick API).
When games use it via evdev, the deadzone is far too large. For Descent 1 and 2 (dxx-rebirth), which use SDL1.2, no deadzone is optimal because very fine control is required for long-range shots. I have so far disabled the deadzone by calibrating the joystick using the joystick API and then setting SDL_JOYSTICK_DEVICE=dev/input/js0, which is not going to work anymore.

A default deadzone of zero would work for me. But I don't know if other joysticks deliver equally good raw values, and it would be nice to support even gameport joysticks which *will* need calibration.

Also, for some reason, button numbers as displayed in control setup in various games better match numbers printed on the physical buttons with the joystick API. With joystick API, worst case there is an offset of 1 (physically printed numbers are one-based, displayed numbers are zero-based). With evdev, there is some permutation as well.

Overall, it seems to be a good idea to even prefer the joystick API by default for joystick-like devices (joysticks and gamepads).
Comment 2 Ryan C. Gordon 2014-03-22 19:14:07 UTC
*** Bug 2303 has been marked as a duplicate of this bug. ***
Comment 3 Ryan C. Gordon 2014-03-22 19:18:05 UTC
We removed the old interface thinking it was an obsolete interface, and that the generic /dev/input devices were meant to replace them. We didn't realize this important feature was exclusively part of /dev/js*

I'm planning to rollback the commit that removed this support, and fix it up for 2.0.4.

Sorry about that!

--ryan.
Comment 4 Gabriel Jacobo 2014-03-24 14:33:30 UTC
FWIW, I just checked and the /dev/input/js* devices do appear on the UDEV stream, so the autodetection stuff should work, it's a matter of telling them apart from the event devices.
Comment 5 Andreas Hartmetz 2014-03-25 13:15:25 UTC
Glad to hear that this is going to be fixed. Thanks!
This would have been a bit of a problem once most games use SDL2.
Comment 6 Sam Lantinga 2014-04-18 05:58:38 UTC
Let's go ahead and fix this for 2.0.4.
Comment 7 Toby Haynes 2014-08-11 17:05:33 UTC
(In reply to Sam Lantinga from comment #6)
> Let's go ahead and fix this for 2.0.4.

Any update on this one? The lack of the calibrated joysticks makes half my controllers effectively useless for SDL2 games.
Comment 8 Andreas Hartmetz 2014-10-14 21:42:24 UTC
Come on guys, please?
Comment 9 Ryan C. Gordon 2015-02-19 05:22:15 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!