# HG changeset patch # User Edgar Simo # Date 1217954030 0 # Node ID bb175d957174df7e4c8f8a9030e44fb92d3f0148 # Parent 0ea3be6e81a7177363be50459a57a0b23cd265fa Some correctness, especially on axes. diff -r 0ea3be6e81a7 -r bb175d957174 src/haptic/win32/SDL_syshaptic.c --- 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; }