src/haptic/windows/SDL_syshaptic.c
changeset 5358 5b330ef7b8dd
parent 5090 327f181542f1
child 5535 96594ac5fd1a
     1.1 --- a/src/haptic/windows/SDL_syshaptic.c	Sun Feb 20 09:24:02 2011 -0800
     1.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Sun Feb 20 09:28:13 2011 -0800
     1.3 @@ -576,7 +576,26 @@
     1.4  int
     1.5  SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
     1.6  {
     1.7 -    int ret;
     1.8 +    int i, ret;
     1.9 +    HRESULT idret;
    1.10 +    DIDEVICEINSTANCE joy_instance;
    1.11 +
    1.12 +    /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
    1.13 +    for (i=0; i<SDL_numhaptics; i++) {
    1.14 +        idret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice,
    1.15 +              &joy_instance);
    1.16 +        if (FAILED(idret)) {
    1.17 +            return -1;
    1.18 +        }
    1.19 +        if (DI_GUIDIsSame(&SDL_hapticlist[i].instance.guidInstance,
    1.20 +                          &joy_instance.guidInstance)) {
    1.21 +            haptic->index = i;
    1.22 +            break;
    1.23 +        }
    1.24 +    }
    1.25 +    if (i >= SDL_numhaptics) {
    1.26 +        return -1;
    1.27 +    }
    1.28  
    1.29      /* Allocate the hwdata */
    1.30      haptic->hwdata = (struct haptic_hwdata *)