Mercurial > sdl-ios-xcode
changeset 2606:bb175d957174 gsoc2008_force_feedback
Some correctness, especially on axes.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 16:33:50 +0000 |
parents | 0ea3be6e81a7 |
children | e0ca521516f6 |
files | src/haptic/win32/SDL_syshaptic.c |
diffstat | 1 files changed, 7 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/haptic/win32/SDL_syshaptic.c Tue Aug 05 16:13:11 2008 +0000 +++ b/src/haptic/win32/SDL_syshaptic.c Tue Aug 05 16:33:50 2008 +0000 @@ -66,6 +66,7 @@ struct haptic_hwdata { LPDIRECTINPUTDEVICE2 device; + DWORD axes[3]; /* DIDEVCAPS capabilities; */ }; @@ -233,6 +234,7 @@ if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) { + haptic->hwdata->axes[haptic->naxes] = dev->dwOfs; haptic->naxes++; /* Currently using the artificial limit of 3 axes. */ @@ -345,7 +347,6 @@ goto acquire_err; } - /* Enabling actuators. */ ret = IDirectInputDevice2_SendForceFeedbackCommand( haptic->hwdata->device, DISFFC_SETACTUATORSON ); @@ -374,13 +375,7 @@ dipdw.dwData = 10000; ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, DIPROP_FFGAIN, &dipdw.diph ); - if (FAILED(ret)) { - if (ret != DIERR_UNSUPPORTED) { - DI_SetError("Checking gain",ret); - goto acquire_err; - } - } - else { /* Gain is supported. */ + if (!FAILED(ret)) { /* Gain is supported. */ haptic->supported |= SDL_HAPTIC_GAIN; } dipdw.diph.dwObj = 0; @@ -388,22 +383,14 @@ dipdw.dwData = DIPROPAUTOCENTER_OFF; ret = IDirectInputDevice2_SetProperty( haptic->hwdata->device, DIPROP_AUTOCENTER, &dipdw.diph ); - if (FAILED(ret)) { - if (ret != DIERR_UNSUPPORTED) { - DI_SetError("Checking autocenter",ret); - goto acquire_err; - } - } - else { /* Autocenter is supported. */ + if (!FAILED(ret)) { /* Autocenter is supported. */ haptic->supported |= SDL_HAPTIC_AUTOCENTER; } - /* Check maximum effects. */ haptic->neffects = 128; /* TODO actually figure this out. */ haptic->nplaying = 128; - /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); @@ -634,12 +621,12 @@ SDL_OutOfMemory(); return -1; } - axes[0] = DIJOFS_X; /* Always at least one axis. */ + axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ if (dest->cAxes > 1) { - axes[1] = DIJOFS_Y; + axes[1] = haptic->hwdata->axes[1]; } if (dest->cAxes > 2) { - axes[2] = DIJOFS_Z; + axes[2] = haptic->hwdata->axes[2]; } dest->rgdwAxes = axes; }