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

Commit

Permalink
Get number of axes.
Browse files Browse the repository at this point in the history
Should fix the autocenter issue.
  • Loading branch information
bobbens committed Aug 5, 2008
1 parent 4e2d98a commit 3501a8a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/haptic/win32/SDL_syshaptic.c
Expand Up @@ -223,6 +223,28 @@ DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
}


/*
* Callback to get supported axes.
*/
static BOOL CALLBACK
DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
{
SDL_Haptic *haptic = (SDL_Hapti *) pvRef;

if (dev->dwType & DIDFT_AXIS) {

haptic->naxes++;

/* Currently using the artificial limit of 3 axes. */
if (haptic->naxes >= 3) {
return DIENUM_STOP;
}
}

return DIENUM_CONTINUE;
}


/*
* Opens the haptic device from the file descriptor.
*
Expand Down Expand Up @@ -299,6 +321,15 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
}
#endif

/* Get number of axes. */
ret = IDirectInputDevice2_EnumObjects( haptic->hwdata->device,
DI_DeviceObjectCallback,
haptic, DIDFT_AXIS );
if (FAILED(ret)) {
DI_SetError("Getting device axes",ret);
goto query_err;
}

/* Acquire the device. */
ret = IDirectInputDevice2_Acquire(haptic->hwdata->device);
if (FAILED(ret)) {
Expand Down Expand Up @@ -352,6 +383,8 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
else { /* Gain is supported. */
haptic->supported |= SDL_HAPTIC_GAIN;
}
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAUTOCENTER_OFF;
ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph );
Expand Down

0 comments on commit 3501a8a

Please sign in to comment.