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 344

Summary: Gravis Gamepad Pro USB axes initially give incorrect values
Product: SDL Reporter: Michael Buckley <thebuckley>
Component: joystickAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: 1.2.11   
Hardware: PowerPC   
OS: Mac OS X (All)   
Attachments: The source code for the program used to test the Gamepad Pro
The results of the test on OS X
The results of the test on Windows XP

Description Michael Buckley 2006-10-13 01:32:02 UTC
This is kind of an odd bug which manifests itself only in OS X for SDL, as far as I can tell. However, since I only have a Gamepad Pro, I don't know if it affects other joysticks as well. I can only currently test it on 10.4 PPC, but I have confirmed it on multiple machines. If I recall, it also occurs in 10.3, but I can't confirm it. I first saw the behavior in the SDL port of VisualBoy Advance, and later in Super Mario War. It does not occur in non-SDL applications, like SNES9x.

Basically, if a direction is pressed on the pad for the first time since the application has started, when that direction is released, instead of centering the axis, it sets the value of that axis to the opposite direction. For example, if I press and then release joystick up, SDL will be left thinking the value of axis 0 is down, not center, even if I'm not pressing down. If I press up again, the same thing will happen. However, if I explicitly press down, the axis will behave normally until the program quits. However, the same problem still exists with the other axis until the same procedure is repeated for that axis.

If this is confusing, I hope that my attachments make sense. The file joytest.c is the source code I used to test this. The file stdout-osx.txt contains results from running the test on OS X, with comments edited in after each line. The file stdout-win.txt contains results from running the test on Windows, again with comments edited in. The joystick performs correctly on Windows, but not OS X.
Comment 1 Michael Buckley 2006-10-13 01:33:27 UTC
Created attachment 168 [details]
The source code for the program used to test the Gamepad Pro
Comment 2 Michael Buckley 2006-10-13 01:35:40 UTC
Created attachment 169 [details]
The results of the test on OS X
Comment 3 Michael Buckley 2006-10-13 01:36:08 UTC
Created attachment 170 [details]
The results of the test on Windows XP
Comment 4 Ryan C. Gordon 2007-05-28 22:32:56 UTC
*** Bug 430 has been marked as a duplicate of this bug. ***
Comment 5 Ryan C. Gordon 2007-05-29 05:14:31 UTC
Ok, I fixed this.

It looks like we had two variables set backwards (we assigned to "minReport" when we meant "maxReport" and vice versa), and this code worked until some recent Mac OS X revision changed a value we expected...I would guess it was always "0" until some OS X update, so it worked until recently.

Now we set the initial min/max bounds for device values to whatever the hardware/os tell us it is, and adjust if we find they are wrong later, which is probably what this code meant to do in the first place.

Fixed in svn revision #3030 for the 1.2 branch, and #3031 for the 1.3 branch.

--ryan.