Mercurial > sdl-ios-xcode
changeset 2601:4915cd01d0e7 gsoc2008_force_feedback
Get number of axes.
Should fix the autocenter issue.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 11:39:51 +0000 |
parents | d1140f0ebedf |
children | f578389c9ead |
files | src/haptic/win32/SDL_syshaptic.c |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 );