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 946 - SDL_HapticIndex returns 0 for all devices on Windows
Summary: SDL_HapticIndex returns 0 for all devices on Windows
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All Windows (All)
: P2 normal
Assignee: Edgar Simo
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-12 04:44 UTC by elboato
Modified: 2011-02-20 10:53 UTC (History)
0 users

See Also:


Attachments
Untested patch to fix haptic index being 0 always when opening from joystick in windows. (1.04 KB, patch)
2011-02-20 09:18 UTC, Edgar Simo
Details | Diff
Untested patch to fix haptic index being 0 always when opening from joystick in mac os x. (697 bytes, patch)
2011-02-20 09:25 UTC, Edgar Simo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description elboato 2010-02-12 04:44:48 UTC
When there are more than 1 haptic devices connected SDL_HapticIndex should probably not return 0 for all devices.... I'm iterating over all haptics and outputting SDL_HapticIndex(). When I have 2 devices connected, SDL_HapticIndex always returns 0, where it should be 0 for the first, and 1 for the second. On Linux it works fine.

I worked around it by not using SDL_HapticIndex, but instead implementing it the way it is done in the linux specific file for haptic (using SDL_JoystickName and SDL_strcmp). This way it works on Windows and Linux.

BUT: (maybe this should be filed as a SEPARATE BUG)
I could not test this, but I think this might be a problem: If two times the same type of haptic controllers are connected, SDL_JoystickName() will return the same String for both of them - therefore SDL_HapticIndex will stop working on Linux as well as in my workaround. Can anybody test that?
Comment 1 Sam Lantinga 2011-02-16 04:04:14 UTC
Hey Edgar, do you have time to take a quick look at this?
Comment 2 Edgar Simo 2011-02-20 09:02:31 UTC
Linux uses fname, which is the name of the device path like for example /dev/input/event3 so it shouldn't have the issue. However I can confirm that it looks like haptic->index never gets properly set on windows. Have to look at mac os x also. I'll see if I can fix it real quick now.
Comment 3 Edgar Simo 2011-02-20 09:18:40 UTC
Created attachment 580 [details]
Untested patch to fix haptic index being 0 always when opening from joystick in windows.

Untested, should fix the issue.
Comment 4 Edgar Simo 2011-02-20 09:25:00 UTC
Created attachment 581 [details]
Untested patch to fix haptic index being 0 always when opening from joystick in mac os x.

Also untested, should fix the fact the same issue exists in mac os x.
Comment 5 Edgar Simo 2011-02-20 09:28:33 UTC
Sorry I can't fully test. I only have systems with linux at the moment and only a single haptic device. Anyway from my checking it seems like the issue is that both windows and mac os x (not linux however) do not set the haptic->index only when creating a SDL_Haptic* from a SDL_Joystick*. However creating an SDL_Haptic* by index should work. SDL_HapticIndex uses haptic->index so therefore they always return 0 on windows/darwin when created from a joystick. Both attached patches should fix it however as mentioned before I can't test them although it's seems straight forward enough to work.
Comment 6 Sam Lantinga 2011-02-20 09:30:06 UTC
Thanks Edgar, your patch is in:
http://hg.libsdl.org/SDL/rev/5b330ef7b8dd

elboato, can you try the latest SDL snapshot and see if this fixes your issue?
http://www.libsdl.org/tmp/SDL-1.3.zip

Thanks!
Comment 7 elboato 2011-02-20 10:49:57 UTC
(In reply to comment #6)
> elboato, can you try the latest SDL snapshot and see if this fixes your issue?
> http://www.libsdl.org/tmp/SDL-1.3.zip

Hi folks!

Thanks a lot for your work! Unfortunately I cannot test this, because I have only one haptic device left. (I had to give back the others to the university....) Sorry!

Best regards,
elboato
Comment 8 Sam Lantinga 2011-02-20 10:53:03 UTC
Okay, I'll mark this closed.  Please reopen it if you find any issues with it.

Thanks!