Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Untested fix for bug 946 (SDL_HapticIndex returns 0 for all devices)
Browse files Browse the repository at this point in the history
 Edgar Simo      2011-02-20 09:02:31 PST

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.
  • Loading branch information
slouken committed Feb 20, 2011
1 parent 3f761fc commit 96cfb6a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/haptic/darwin/SDL_syshaptic.c
Expand Up @@ -534,6 +534,18 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
int i;
for (i=0; i<SDL_numhaptics; i++) {
if (IOObjectIsEqualTo((io_object_t) SDL_hapticlist[i].dev,
joystick->hwdata->ffservice)) {
haptic->index = i;
break;
}
}
if (i >= SDL_numhaptics) {
return -1;
}

return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice);
}

Expand Down
21 changes: 20 additions & 1 deletion src/haptic/windows/SDL_syshaptic.c
Expand Up @@ -576,7 +576,26 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
int ret;
int i, ret;
HRESULT idret;
DIDEVICEINSTANCE joy_instance;

/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (i=0; i<SDL_numhaptics; i++) {
idret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
&joy_instance);
if (FAILED(idret)) {
return -1;
}
if (DI_GUIDIsSame(&SDL_hapticlist[i].instance.guidInstance,
&joy_instance.guidInstance)) {
haptic->index = i;
break;
}
}
if (i >= SDL_numhaptics) {
return -1;
}

/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)
Expand Down

0 comments on commit 96cfb6a

Please sign in to comment.