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 1486

Summary: 1.2.15 regression: some joystick axises stopped working
Product: SDL Reporter: Alon Bar-Lev <alon.barlev>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: VERIFIED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus, renesd, sezeroz
Version: 1.2.15   
Hardware: All   
OS: Linux   
Attachments: libsdl-1.2.15-joystick.patch

Description Alon Bar-Lev 2012-04-28 02:00:50 UTC
Created attachment 850 [details]
libsdl-1.2.15-joystick.patch

Hello,
In 1.2.15 there was a changed:
---
-               for ( i=0; i<ABS_MAX; ++i ) {
+               for ( i=0; i<ABS_MISC; ++i ) {
---

This caused some axis to not be detected.

I use sixaxis, it looks like the following aixs are important, all above ABS_MISC.
---
index: 3b
Joystick has absolute axis: 3b
Values = { 0, 0, 1023, 3, 63 }
index: 3c
Joystick has absolute axis: 3c
Values = { 485, 0, 1023, 3, 63 }
index: 3d
Joystick has absolute axis: 3d
Values = { 388, 0, 1023, 3, 63 }
index 3e
Joystick has absolute axis: 3e
Values = { 481, 0, 1023, 3, 63 }
---

Attached is a patch reverting this, all works now.
Comment 1 Alon Bar-Lev 2012-04-28 14:06:09 UTC
Hello,

Found commit...

The explanation is strange, as I use "standard PlayStation 3 controller plugged in via USB" and after change SDL totally ignoring the left stick X axes.

Using linux-3.3.3 and SDL-1.2.15 with attachment#850 [details] works correctly.

So the problem [if exists] is in different place.

---

# HG changeset patch
# User Ryan C. Gordon <icculus@icculus.org>
# Date 1310603889 25200
# Node ID aa0e501baca0eec3568481e9f61359b3118daf96
# Parent  dd0f52bf2bfaa14de95268ed9e0dfaef81f2ed72
Linux: Search a smaller set of potential joystick axes.

Newer kernels seem to report bogus axes in the higher ranges, for example
 with a standard PlayStation 3 controller plugged in via USB.

diff -r dd0f52bf2bfa -r aa0e501baca0 src/joystick/linux/SDL_sysjoystick.c
--- a/src/joystick/linux/SDL_sysjoystick.c	Tue Jul 05 22:05:56 2011 -0400
+++ b/src/joystick/linux/SDL_sysjoystick.c	Wed Jul 13 17:38:09 2011 -0700
@@ -703,7 +703,7 @@
                 ++joystick->nbuttons;
             }
         }
-        for (i = 0; i < ABS_MAX; ++i) {
+        for (i = 0; i < ABS_MISC; ++i) {
             /* Skip hats */
             if (i == ABS_HAT0X) {
                 i = ABS_HAT3Y;
Comment 2 Ryan C. Gordon 2012-06-03 02:10:31 UTC
(In reply to comment #0)
> Attached is a patch reverting this, all works now.

It works, but SDL thinks the SixAxis has 27 axes, which is probably not correct.

I just committed a patch that corrects the lost left-stick X axis...my original patch didn't take into account that the extra axes would still send data, and overwrite the first axis's state.

--ryan.
Comment 3 Alon Bar-Lev 2012-06-06 08:18:47 UTC
Confirmed!
Thanks.
Comment 5 Ozkan Sezer 2018-08-13 11:45:59 UTC
(In reply to Rene Dudfield from comment #4)
> Arch Linux has a patch for this here:
> https://git.archlinux.org/svntogit/packages.git/tree/trunk/SDL-1.2.15-
> ignore_insane_joystick_axis.patch?h=packages/sdl

That patch is already in the SDL-1.2 branch.