# HG changeset patch # User Edgar Simo # Date 1217936391 0 # Node ID 4915cd01d0e7f91cbfcaa2d5586cbb9b09620d4e # Parent d1140f0ebedfa4ae51eb72cd4a0acd1f2ed3c3f2 Get number of axes. Should fix the autocenter issue. diff -r d1140f0ebedf -r 4915cd01d0e7 src/haptic/win32/SDL_syshaptic.c --- a/src/haptic/win32/SDL_syshaptic.c Tue Aug 05 11:21:21 2008 +0000 +++ b/src/haptic/win32/SDL_syshaptic.c Tue Aug 05 11:39:51 2008 +0000 @@ -224,6 +224,28 @@ /* + * 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. * * Steps: @@ -299,6 +321,15 @@ } #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)) { @@ -352,6 +383,8 @@ 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 );