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 920

Summary: Haptic directions messed up on Linux
Product: SDL Reporter: elboato
Component: joystickAssignee: elboato
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: Linux   
Attachments: linux specific file for haptic
SDL_syshaptic.c for Linux

Description elboato 2009-12-30 13:55:08 UTC
Hey everybody!

I made further tests for my Java Joystick driver (http://sourceforge.net/projects/ffjoystick4java/) and I found out that the directions seem to be totally messed up on Linux.

note: directions mean the direction where the force comes from (e.g. force from south means that the stick moves away from the user).

I tested 5 directions with polar directions. "should be" is what I actually set as values, "is" is how the joystick behaved on Linux. On Windows it all worked fine.

should be  #         is
--------------------------------
northwest  # southeast --- WRONG
north      # south --- WRONG
south      # south --- CORRECT
east       # east --- CORRECT
west       # southeast --- WRONG

Then I changed the directions from polar to spherical. Again, on Windows everything worked as it should. On Linux the result is again weird, but also a little different compared to the previous one: west and east seem to be switched.

should be  #         is
--------------------------------
northwest  # southeast --- WRONG
north      # south --- WRONG
south      # south --- CORRECT
east       # southeast --- WRONG
west       # east --- WRONG

I looked at SDL_SYS_ToDirection in SDL_syshaptic.c in the linux directory of haptic, but I could not identify the problem yet. There's a comment: /* Linux directions are inverted. */

Maybe there's something wrong with that inversion " * 0xFFFF "?
Or maybe the values should be in another range, not from 0 to 36000?

All the best,

elboato
Comment 1 elboato 2010-01-07 05:53:30 UTC
Created attachment 478 [details]
linux specific file for haptic
Comment 2 elboato 2010-01-07 06:03:51 UTC
Alright... I corrected SDL_SYS_ToDirection in SDL_syshaptic.c in the linux directory of haptic. Now in all 3 cases the same value is returned, at least. Therefore now it should behave the same way as on Windows.

I added some comments and corrected the cases SDL_HAPTIC_CARTESIAN and SDL_HAPTIC_SPHERICAL.

Could you upload the file I attached to the SVN, please? see http://bugzilla.libsdl.org/attachment.cgi?id=478


So now I still have another problem: my Joystick (Logitech Force 3D Pro) does only work correctly for the directions south, east and south-east. (values for directions on driver/system level: 0, 49151 (0xC000) and 57343 (0xE000). Well so far I only tried the 8 default directions. I'll take a closer look. I have no clue what might be the problem. Maybe it's the driver itself... Any ideas?

All the best

elboato
Comment 3 elboato 2010-01-07 08:17:49 UTC
(In reply to comment #2)
> So now I still have another problem: my joystick (Logitech Force 3D Pro) does
> only work correctly for the directions south, east and south-east. (values for
> directions on driver/system level: 0, 49151 (0xC000) and 57343 (0xE000). Well
> so far I only tried the 8 default directions. I'll take a closer look. I have
> no clue what might be the problem. Maybe it's the driver itself...

As I supposed: in SDL_SYS_HapticUpdateEffect the effect is uploaded with ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) and there the values in the struct linux_effect are okay. So the problem seems to be the driver for my joystick Logitech Force 3D Pro.

Can anybody confirm that? If I'm right, I guess this bug is resolved with the file I attached before....

And can anybody suggest a joystick that works on linux? Which joysticks/gamepads were used/tested during the implementation of haptic for SDL?

Thx in advance!

elboato
Comment 4 elboato 2010-01-18 01:37:49 UTC
Created attachment 481 [details]
SDL_syshaptic.c for Linux

I added even more comments on the corrected conversion to Linux directions. This was tested on my Logitech Force 3D Pro Joystick and it should definitely work.
Comment 5 Sam Lantinga 2010-01-18 06:57:16 UTC
Your changes are in subversion, thanks!