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 4677

Summary: GameCube controller joystick axis doesn't use full axis range
Product: SDL Reporter: Zack Middleton (zturtleman) <zack>
Component: joystickAssignee: Zack Middleton (zturtleman) <zack>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   

Description Zack Middleton (zturtleman) 2019-06-19 09:38:41 UTC
The GameCube controller (via the Nintendo USB GameCube Adapter) joystick/trigger axis don't use the full axis range.

The joystick/trigger axis is a Uint8 in the approximate range of 32 to 224. This varies by axis and between controllers but for different controllers it's a similar distance from the axis initial position. SDL does ((axis * 257) - 32768) in HIDAPI_DriverGameCube_UpdateDriver() so it uses values approximately +/-24k but +/-32k is expected by applications.

Due to non-centered axis, simply increasing the 257 multiplier seems like a bad idea. Maybe have a default distance (per-axis) from initial position to use for scaling and increase min/max if axis goes past it. (I probably should test this / try to figure out what GameCube games do.)

axis_initial = first_value
axis_max = axis_initial + default_distance[axisnum]
axis_min = axis_initial - default_distance[axisnum]
...
if (axis > axis_max) axis_max = axis;
if (axis < axis_min) axis_min = axis;
SDL_PrivateJoystickAxis( js, axisnum, ((axis - axis_min) * 65536 / (axis_max - axis_min)) - 32768 );

I'm not entirely sure if this should be handled by SDL or if applications are expected to handle 'non-normalized axis'. Though I think ideally the default range of axis would be GameCube specific.
Comment 1 Sam Lantinga 2019-06-19 13:48:15 UTC
Okay, I'll leave this bug open for you to investigate and propose a patch.

Thanks!
Comment 2 Ryan C. Gordon 2019-07-30 17:49:38 UTC
(Sorry if you get several emails like this, we're marking a bunch of bugs.)

We're hoping to ship SDL 2.0.11 on a much shorter timeframe than we have historically done releases, so I'm starting to tag bugs we hope to have closed in this release cycle.

Note that this tag means we just intend to scrutinize this bug for the 2.0.11 release: we may fix it, reject it, or even push it back to a later release for now, but this helps give us both a goal and a wishlist for the next release.

If this bug has been quiet for a few months and you have new information (such as, "this is definitely still broken" or "this got fixed at some point"), please feel free to retest and/or add more notes to the bug.

--ryan.
Comment 3 Ryan C. Gordon 2019-09-20 20:47:36 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 4 Ryan C. Gordon 2019-09-20 20:48:44 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 5 Sam Lantinga 2019-12-12 00:59:46 UTC
To be clear, the idea is that calibrated values span the whole range of the axis.

Some autocalibration systems will use a clamped range and expand it out as they see larger values. That won't help with center offset though... ?