Fixed: Windows always fails with SDL_HapticOpenFromJoystick
authorSam Lantinga <slouken@libsdl.org>
Tue, 19 Apr 2011 08:08:50 -0700
changeset 5539b305e3c2d2e7
parent 5538 b395a72329c3
child 5540 918efbff8259
Fixed: Windows always fails with SDL_HapticOpenFromJoystick

The windows function SDL_SYS_HapticOpenFromJoystick fails because DIDEVICEINSTANCE joy_instance does not have its dwSize field initialized. The attached patch includes the fix along with a fix for two similar problems.

Daniel Heath
src/haptic/windows/SDL_syshaptic.c
     1.1 --- a/src/haptic/windows/SDL_syshaptic.c	Mon Apr 18 12:20:30 2011 -0700
     1.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Tue Apr 19 08:08:50 2011 -0700
     1.3 @@ -549,6 +549,8 @@
     1.4  {
     1.5      HRESULT ret;
     1.6      DIDEVICEINSTANCE hap_instance, joy_instance;
     1.7 +    hap_instance.dwSize = sizeof(DIDEVICEINSTANCE);
     1.8 +    joy_instance.dwSize = sizeof(DIDEVICEINSTANCE);
     1.9  
    1.10      /* Get the device instances. */
    1.11      ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device,
    1.12 @@ -578,6 +580,7 @@
    1.13      int i, ret;
    1.14      HRESULT idret;
    1.15      DIDEVICEINSTANCE joy_instance;
    1.16 +    joy_instance.dwSize = sizeof(DIDEVICEINSTANCE);
    1.17  
    1.18      /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
    1.19      for (i=0; i<SDL_numhaptics; i++) {