Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joystick calibration impossible on Linux #1314

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 2 comments
Closed

Joystick calibration impossible on Linux #1314

SDLBugzilla opened this issue Feb 10, 2021 · 2 comments
Assignees
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

@SDLBugzilla SDLBugzilla commented Feb 10, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2014-01-19 13:39:24 +0000, Manuel Reimer wrote:

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.

On 2014-02-12 04:53:03 +0000, Andreas Hartmetz wrote:

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).

On 2014-03-22 19:14:07 +0000, Ryan C. Gordon wrote:

*** Bug 2303 has been marked as a duplicate of this bug. ***

On 2014-03-22 19:18:05 +0000, Ryan C. Gordon wrote:

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.

On 2014-03-24 14:33:30 +0000, Gabriel Jacobo wrote:

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.

On 2014-03-25 13:15:25 +0000, Andreas Hartmetz wrote:

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.

On 2014-04-18 05:58:38 +0000, Sam Lantinga wrote:

Let's go ahead and fix this for 2.0.4.

On 2014-08-11 17:05:33 +0000, Toby Haynes wrote:

(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.

On 2014-10-14 21:42:24 +0000, Andreas Hartmetz wrote:

Come on guys, please?

On 2015-02-19 05:22:15 +0000, Ryan C. Gordon wrote:

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!

@icculus icculus added this to the 2.0.18 milestone Aug 11, 2021
@icculus
Copy link
Collaborator

@icculus icculus commented Aug 11, 2021

I have no idea if this is even feasible in modern times, with hotplug and udev, hidapi, etc. I also don't remember the last time I had to calibrate a game controller.

So this is in 2.0.18 but it's possible we just WONTFIX this one.

@slouken slouken self-assigned this Nov 8, 2021
@slouken
Copy link
Collaborator

@slouken slouken commented Nov 11, 2021

You can set the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to enable the classic /dev/input/js* joysticks as of 1c78b08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants