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 1460 - Axis 0 (left stick x) always returns 0. testjoystick patch
Summary: Axis 0 (left stick x) always returns 0. testjoystick patch
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.0
Hardware: x86_64 Linux
: P1 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
: 2165 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-30 09:58 UTC by jordirovira
Modified: 2013-10-20 19:26 UTC (History)
3 users (show)

See Also:


Attachments
Fix to update the joystick test to 2.0 (1.80 KB, patch)
2012-03-30 09:58 UTC, jordirovira
Details | Diff
fix_joystick_misc_axes.diff (464 bytes, patch)
2012-06-11 07:45 UTC, manuel.montezelo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jordirovira 2012-03-30 09:58:01 UTC
Created attachment 840 [details]
Fix to update the joystick test to 2.0

Using linux and PS3 controller. In SDL 1.2 it used to work fine. 
The axis 0 corresponding to X in the left stick always returns 0. The rest of the axis seem to work fine.

To reproduce, i have updated the testjoystick.c program in SDL/test to work with 2.0 (See patch). You can see that the right stick works, and the left stick works for the vertical axis only.
Comment 1 jordirovira 2012-04-20 03:33:56 UTC
I think i have located the problem: The joystick system is constantly receiving events of the type ABS_MT_WIDTH_MAJOR (related to multitouch?) for the PS3 pad. This events get incorrectly mapped to axis 0 events in a switch at SDL_sysjoystick.c.

The problem is in the default branch of the switch at line 1133, which is executed for all events but ABS_HATxx. 

Not beeing a joystick expert, i have solved it for now, by adding some extra case filtering like this:


//jordi
//                default:
                case ABS_X:
                case ABS_Y:
                case ABS_Z:
                case ABS_RX:
                case ABS_RY:
                case ABS_RZ:
                case ABS_THROTTLE:
                case ABS_RUDDER:
                case ABS_WHEEL:
                case ABS_GAS:
                case ABS_BRAKE:
                    events[i].value =
                        EV_AxisCorrect(joystick, code, events[i].value);
#ifndef NO_LOGICAL_JOYSTICKS
                    if (!LogicalJoystickAxis(joystick,
                                             joystick->hwdata->abs_map[code],
                                             events[i].value))
#endif
                        SDL_PrivateJoystickAxis(joystick,
                                                joystick->
                                                hwdata->abs_map[code],
                                                events[i].value);
                    break;

                default:
                    break;

I am not really sure if the gas, rudder, wheel, etc should be axis though.
Comment 2 manuel.montezelo 2012-06-11 07:45:01 UTC
We are going to apply this patch in Debian, created by one of the maintainers of the package, to try to fix it:

http://anonscm.debian.org/gitweb/?p=pkg-sdl/packages/libsdl1.2.git;a=blob;f=debian/patches/fix_joystick_misc_axes.diff;h=75e3755c93c83965a76c9f0541205855b3b8a27b;hb=856a810b8cd61fb371163a480a96c7f6c3e461a4

Cheers.
Comment 3 manuel.montezelo 2012-06-11 07:45:49 UTC
Created attachment 875 [details]
fix_joystick_misc_axes.diff
Comment 4 Ryan C. Gordon 2013-07-12 11:43:11 UTC
I think we fixed this awhile ago, separate from this patch. I'll confirm.

--ryan.
Comment 5 Ryan C. Gordon 2013-07-12 18:52:54 UTC
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.)

Tagging a bunch of bugs as target-2.0.0, Priority 1.

This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible.

That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship.

Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment.

Thanks!
--ryan.
Comment 6 Ryan C. Gordon 2013-07-15 01:37:00 UTC
I think this is the change we made to deal with axis zero being overwritten incorrectly...

    http://hg.libsdl.org/SDL/rev/57001e845b72

...I'm trying to understand how the Debian patch fixes this...is this mapping some extra, bogus axes to the controller? (or maybe the PS3 controller's tilt sensors are showing up as an axis now?).

--ryan.
Comment 7 Ryan C. Gordon 2013-07-30 00:26:00 UTC
(In reply to comment #6)
> ...I'm trying to understand how the Debian patch fixes this...is this
> mapping some extra, bogus axes to the controller? (or maybe the PS3
> controller's tilt sensors are showing up as an axis now?).

I'm closing this as FIXED for now, because the existing code fixed this specific bug report at some point.

We'll probably be revamping the joystick code a little bit going forward, since we want to deal with non-standard things better (Wiimote things, Guitar Hero things, etc), and will look at the PS3 controller tilt sensors then.

--ryan.
Comment 8 Ryan C. Gordon 2013-10-20 19:26:43 UTC
*** Bug 2165 has been marked as a duplicate of this bug. ***