Basic haptic support for windows should work. Needs testing (probably won't compile). gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Thu, 31 Jul 2008 11:06:16 +0000
branchgsoc2008_force_feedback
changeset 256694ff09afa478
parent 2565 698c776c642f
child 2567 d551e29f086b
Basic haptic support for windows should work. Needs testing (probably won't compile).
src/haptic/win32/SDL_syshaptic.c
     1.1 --- a/src/haptic/win32/SDL_syshaptic.c	Thu Jul 31 10:31:31 2008 +0000
     1.2 +++ b/src/haptic/win32/SDL_syshaptic.c	Thu Jul 31 11:06:16 2008 +0000
     1.3 @@ -462,10 +462,28 @@
     1.4  
     1.5  
     1.6  /*
     1.7 + * Converts an SDL trigger button to an DIEFFECT trigger button.
     1.8 + */
     1.9 +static DWORD
    1.10 +DIGetTriggerButton( Uint16 button )
    1.11 +{
    1.12 +   DWORD dwTriggerButton;
    1.13 +   
    1.14 +   dwTriggerButton = DIEB_NOTRIGGER;
    1.15 +   
    1.16 +   if (button != 0) {
    1.17 +      dwTriggerButton = DIJOFS_BUTTON(button - 1);
    1.18 +   }                                                                      
    1.19 +                                                                          
    1.20 +   return dwTriggerButton;
    1.21 +}
    1.22 +
    1.23 +
    1.24 +/*
    1.25   * Sets the direction.
    1.26   */
    1.27  static int
    1.28 -SDL_SYS_SetDirection( FFEFFECT * effect, SDL_HapticDirection *dir, int naxes )
    1.29 +SDL_SYS_SetDirection( DIEFFECT * effect, SDL_HapticDirection *dir, int naxes )
    1.30  {
    1.31     LONG *rglDir;
    1.32  
    1.33 @@ -486,17 +504,17 @@
    1.34  
    1.35     switch (dir->type) {
    1.36        case SDL_HAPTIC_POLAR:
    1.37 -         effect->dwFlags |= FFEFF_POLAR;
    1.38 +         effect->dwFlags |= DIEFF_POLAR;
    1.39           rglDir[0] = dir->dir[0];
    1.40           return 0;
    1.41        case SDL_HAPTIC_CARTESIAN:
    1.42 -         effect->dwFlags |= FFEFF_CARTESIAN;
    1.43 +         effect->dwFlags |= DIEFF_CARTESIAN;
    1.44           rglDir[0] = dir->dir[0];
    1.45           rglDir[1] = dir->dir[1];
    1.46           rglDir[2] = dir->dir[2];
    1.47           return 0;
    1.48        case SDL_HAPTIC_SPHERICAL:
    1.49 -         effect->dwFlags |= FFEFF_SPHERICAL;
    1.50 +         effect->dwFlags |= DIEFF_SPHERICAL;
    1.51           rglDir[0] = dir->dir[0];
    1.52           rglDir[1] = dir->dir[1];
    1.53           rglDir[2] = dir->dir[2];
    1.54 @@ -510,18 +528,18 @@
    1.55  
    1.56  #define CONVERT(x)   (((x)*10000) / 0xFFFF )
    1.57  /*
    1.58 - * Creates the FFEFFECT from a SDL_HapticEffect.
    1.59 + * Creates the DIEFFECT from a SDL_HapticEffect.
    1.60   */
    1.61  static int
    1.62 -SDL_SYS_ToFFEFFECT( SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src )
    1.63 +SDL_SYS_ToDIEFFECT( SDL_Haptic * haptic, DIEFFECT * dest, SDL_HapticEffect * src )
    1.64  {
    1.65     int i;
    1.66 -   FFCONSTANTFORCE *constant;
    1.67 -   FFPERIODIC *periodic;
    1.68 -   FFCONDITION *condition; /* Actually an array of conditions - one per axis. */
    1.69 -   FFRAMPFORCE *ramp;
    1.70 -   FFCUSTOMFORCE *custom;
    1.71 -   FFENVELOPE *envelope;
    1.72 +   DICONSTANTFORCE *constant;
    1.73 +   DIPERIODIC *periodic;
    1.74 +   DICONDITION *condition; /* Actually an array of conditions - one per axis. */
    1.75 +   DIRAMPFORCE *ramp;
    1.76 +   DICUSTOMFORCE *custom;
    1.77 +   DIENVELOPE *envelope;
    1.78     SDL_HapticConstant *hap_constant;
    1.79     SDL_HapticPeriodic *hap_periodic;
    1.80     SDL_HapticCondition *hap_condition;
    1.81 @@ -530,20 +548,20 @@
    1.82     DWORD *axes;
    1.83  
    1.84     /* Set global stuff. */
    1.85 -   SDL_memset(dest, 0, sizeof(FFEFFECT));
    1.86 -   dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */
    1.87 +   SDL_memset(dest, 0, sizeof(DIEFFECT));
    1.88 +   dest->dwSize = sizeof(DIEFFECT); /* Set the structure size. */
    1.89     dest->dwSamplePeriod = 0; /* Not used by us. */
    1.90     dest->dwGain = 10000; /* Gain is set globally, not locally. */
    1.91  
    1.92     /* Envelope. */
    1.93 -   envelope = SDL_malloc( sizeof(FFENVELOPE) );
    1.94 +   envelope = SDL_malloc( sizeof(DIENVELOPE) );
    1.95     if (envelope == NULL) {
    1.96        SDL_OutOfMemory();
    1.97        return -1;
    1.98     }
    1.99 -   SDL_memset(envelope, 0, sizeof(FFENVELOPE));
   1.100 +   SDL_memset(envelope, 0, sizeof(DIENVELOPE));
   1.101     dest->lpEnvelope = envelope;
   1.102 -   envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
   1.103 +   envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */
   1.104  
   1.105     /* Axes. */
   1.106     dest->cAxes = haptic->naxes;
   1.107 @@ -553,12 +571,12 @@
   1.108           SDL_OutOfMemory();
   1.109           return -1;
   1.110        }
   1.111 -      axes[0] = FFJOFS_X; /* Always at least one axis. */
   1.112 +      axes[0] = DIJOFS_X; /* Always at least one axis. */
   1.113        if (dest->cAxes > 1) {
   1.114 -         axes[1] = FFJOFS_Y;
   1.115 +         axes[1] = DIJOFS_Y;
   1.116        }
   1.117        if (dest->cAxes > 2) {
   1.118 -         axes[2] = FFJOFS_Z;
   1.119 +         axes[2] = DIJOFS_Z;
   1.120        }
   1.121        dest->rgdwAxes = axes;
   1.122     }
   1.123 @@ -568,21 +586,21 @@
   1.124     switch (src->type) {
   1.125        case SDL_HAPTIC_CONSTANT:
   1.126           hap_constant = &src->constant;
   1.127 -         constant = SDL_malloc( sizeof(FFCONSTANTFORCE) );
   1.128 +         constant = SDL_malloc( sizeof(DICONSTANTFORCE) );
   1.129           if (constant == NULL) {
   1.130              SDL_OutOfMemory();
   1.131              return -1;
   1.132           }
   1.133 -         SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
   1.134 +         SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
   1.135  
   1.136           /* Specifics */
   1.137           constant->lMagnitude = CONVERT(hap_constant->level);
   1.138 -         dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); 
   1.139 +         dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE); 
   1.140           dest->lpvTypeSpecificParams = constant;
   1.141  
   1.142           /* Generics */
   1.143           dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
   1.144 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
   1.145 +         dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button);
   1.146           dest->dwTriggerRepeatInterval = hap_constant->interval;
   1.147           dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
   1.148  
   1.149 @@ -592,10 +610,16 @@
   1.150           }
   1.151           
   1.152           /* Envelope */
   1.153 -         envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
   1.154 -         envelope->dwAttackTime = hap_constant->attack_length * 1000;
   1.155 -         envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
   1.156 -         envelope->dwFadeTime = hap_constant->fade_length * 1000;
   1.157 +         if ((hap_constant->attack_length==0) && (hap_constant->fade_length==0)) {
   1.158 +            SDL_free(dest->lpEnvelope);
   1.159 +            dest->lpEnvelope = NULL;
   1.160 +         }
   1.161 +         else {
   1.162 +            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
   1.163 +            envelope->dwAttackTime = hap_constant->attack_length * 1000;
   1.164 +            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
   1.165 +            envelope->dwFadeTime = hap_constant->fade_length * 1000;
   1.166 +         }
   1.167  
   1.168           break;
   1.169  
   1.170 @@ -605,24 +629,24 @@
   1.171        case SDL_HAPTIC_SAWTOOTHUP:
   1.172        case SDL_HAPTIC_SAWTOOTHDOWN:
   1.173           hap_periodic = &src->periodic;
   1.174 -         periodic = SDL_malloc(sizeof(FFPERIODIC));
   1.175 +         periodic = SDL_malloc(sizeof(DIPERIODIC));
   1.176           if (periodic == NULL) {
   1.177              SDL_OutOfMemory();
   1.178              return -1;
   1.179           }
   1.180 -         SDL_memset(periodic, 0, sizeof(FFPERIODIC));
   1.181 +         SDL_memset(periodic, 0, sizeof(DIPERIODIC));
   1.182  
   1.183           /* Specifics */
   1.184           periodic->dwMagnitude = CONVERT(hap_periodic->magnitude);
   1.185           periodic->lOffset = CONVERT(hap_periodic->offset);
   1.186           periodic->dwPhase = hap_periodic->phase;
   1.187           periodic->dwPeriod = hap_periodic->period * 1000;
   1.188 -         dest->cbTypeSpecificParams = sizeof(FFPERIODIC);
   1.189 +         dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
   1.190           dest->lpvTypeSpecificParams = periodic;
   1.191  
   1.192           /* Generics */
   1.193           dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
   1.194 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button);
   1.195 +         dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button);
   1.196           dest->dwTriggerRepeatInterval = hap_periodic->interval;
   1.197           dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
   1.198           
   1.199 @@ -632,10 +656,16 @@
   1.200           }
   1.201           
   1.202           /* Envelope */
   1.203 -         envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
   1.204 -         envelope->dwAttackTime = hap_periodic->attack_length * 1000;
   1.205 -         envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
   1.206 -         envelope->dwFadeTime = hap_periodic->fade_length * 1000;
   1.207 +         if ((hap_periodic->attack_length==0) && (hap_periodic->fade_length==0)) {
   1.208 +            SDL_free(dest->lpEnvelope);
   1.209 +            dest->lpEnvelope = NULL;
   1.210 +         }
   1.211 +         else {
   1.212 +            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
   1.213 +            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
   1.214 +            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
   1.215 +            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
   1.216 +         }
   1.217  
   1.218           break;
   1.219  
   1.220 @@ -644,12 +674,12 @@
   1.221        case SDL_HAPTIC_INERTIA:
   1.222        case SDL_HAPTIC_FRICTION:
   1.223           hap_condition = &src->condition;
   1.224 -         condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
   1.225 +         condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
   1.226           if (condition == NULL) {
   1.227              SDL_OutOfMemory();
   1.228              return -1;
   1.229           }
   1.230 -         SDL_memset(condition, 0, sizeof(FFCONDITION));
   1.231 +         SDL_memset(condition, 0, sizeof(DICONDITION));
   1.232  
   1.233           /* Specifics */
   1.234           for (i=0; i<dest->cAxes; i++) {
   1.235 @@ -660,12 +690,12 @@
   1.236              condition[i].dwNegativeSaturation = CONVERT(hap_condition->left_sat[i]);
   1.237              condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
   1.238           }
   1.239 -         dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
   1.240 +         dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
   1.241           dest->lpvTypeSpecificParams = condition;
   1.242  
   1.243           /* Generics */
   1.244           dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
   1.245 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button);
   1.246 +         dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button);
   1.247           dest->dwTriggerRepeatInterval = hap_condition->interval;
   1.248           dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
   1.249  
   1.250 @@ -686,22 +716,22 @@
   1.251  
   1.252        case SDL_HAPTIC_RAMP:
   1.253           hap_ramp = &src->ramp;
   1.254 -         ramp = SDL_malloc(sizeof(FFRAMPFORCE));
   1.255 +         ramp = SDL_malloc(sizeof(DIRAMPFORCE));
   1.256           if (ramp == NULL) {
   1.257              SDL_OutOfMemory();
   1.258              return -1;
   1.259           }
   1.260 -         SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
   1.261 +         SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
   1.262  
   1.263           /* Specifics */
   1.264           ramp->lStart = CONVERT(hap_ramp->start);
   1.265           ramp->lEnd = CONVERT(hap_ramp->end);
   1.266 -         dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE);
   1.267 +         dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE);
   1.268           dest->lpvTypeSpecificParams = ramp;
   1.269  
   1.270           /* Generics */
   1.271           dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
   1.272 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button);
   1.273 +         dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button);
   1.274           dest->dwTriggerRepeatInterval = hap_ramp->interval;
   1.275           dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
   1.276  
   1.277 @@ -711,21 +741,27 @@
   1.278           }
   1.279  
   1.280           /* Envelope */
   1.281 -         envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
   1.282 -         envelope->dwAttackTime = hap_ramp->attack_length * 1000;
   1.283 -         envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
   1.284 -         envelope->dwFadeTime = hap_ramp->fade_length * 1000;
   1.285 +         if ((hap_ramp->attack_length==0) && (hap_ramp->fade_length==0)) {
   1.286 +            SDL_free(dest->lpEnvelope);
   1.287 +            dest->lpEnvelope = NULL;
   1.288 +         }
   1.289 +         else {
   1.290 +            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
   1.291 +            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
   1.292 +            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
   1.293 +            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
   1.294 +         }
   1.295  
   1.296           break;
   1.297  
   1.298        case SDL_HAPTIC_CUSTOM:
   1.299           hap_custom = &src->custom;
   1.300 -         custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
   1.301 +         custom = SDL_malloc(sizeof(DICUSTOMFORCE));
   1.302           if (custom == NULL) {
   1.303              SDL_OutOfMemory();
   1.304              return -1;
   1.305           }
   1.306 -         SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
   1.307 +         SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
   1.308  
   1.309           /* Specifics */
   1.310           custom->cChannels = hap_custom->channels;
   1.311 @@ -735,12 +771,12 @@
   1.312           for (i=0; i<hap_custom->samples*hap_custom->channels; i++) { /* Copy data. */
   1.313              custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
   1.314           }
   1.315 -         dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE);
   1.316 +         dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
   1.317           dest->lpvTypeSpecificParams = custom;
   1.318  
   1.319           /* Generics */
   1.320           dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
   1.321 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button);
   1.322 +         dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button);
   1.323           dest->dwTriggerRepeatInterval = hap_custom->interval;
   1.324           dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
   1.325  
   1.326 @@ -750,10 +786,16 @@
   1.327           }
   1.328           
   1.329           /* Envelope */
   1.330 -         envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
   1.331 -         envelope->dwAttackTime = hap_custom->attack_length * 1000;
   1.332 -         envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
   1.333 -         envelope->dwFadeTime = hap_custom->fade_length * 1000;
   1.334 +         if ((hap_custom->attack_length==0) && (hap_custom->fade_length==0)) {
   1.335 +            SDL_free(dest->lpEnvelope);
   1.336 +            dest->lpEnvelope = NULL;
   1.337 +         }
   1.338 +         else {
   1.339 +            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
   1.340 +            envelope->dwAttackTime = hap_custom->attack_length * 1000;
   1.341 +            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
   1.342 +            envelope->dwFadeTime = hap_custom->fade_length * 1000;
   1.343 +         }
   1.344  
   1.345           break;
   1.346  
   1.347 @@ -768,12 +810,12 @@
   1.348  
   1.349  
   1.350  /*
   1.351 - * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT.
   1.352 + * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT.
   1.353   */
   1.354  static void
   1.355 -SDL_SYS_HapticFreeFFEFFECT( FFEFFECT * effect, int type )
   1.356 +SDL_SYS_HapticFreeDIEFFECT( DIEFFECT * effect, int type )
   1.357  {
   1.358 -   FFCUSTOMFORCE *custom;
   1.359 +   DICUSTOMFORCE *custom;
   1.360  
   1.361     if (effect->lpEnvelope != NULL) {
   1.362        SDL_free(effect->lpEnvelope);
   1.363 @@ -785,7 +827,7 @@
   1.364     }
   1.365     if (effect->lpvTypeSpecificParams != NULL) {
   1.366        if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
   1.367 -         custom = (FFCUSTOMFORCE*) effect->lpvTypeSpecificParams;
   1.368 +         custom = (DICUSTOMFORCE*) effect->lpvTypeSpecificParams;
   1.369           SDL_free(custom->rglForceData);
   1.370           custom->rglForceData = NULL;
   1.371        }
   1.372 @@ -874,22 +916,22 @@
   1.373     }
   1.374  
   1.375     /* Get the effect. */
   1.376 -   if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
   1.377 +   if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) {
   1.378        goto err_effectdone;
   1.379     }
   1.380  
   1.381     /* Create the actual effect. */
   1.382 -   ret = FFDeviceCreateEffect(haptic->hwdata->device, type,
   1.383 -         &effect->hweffect->effect, &effect->hweffect->ref);
   1.384 -   if (ret != FF_OK) {
   1.385 -      SDL_SetError("Haptic: Unable to create effect: %s.", FFStrError(ret));
   1.386 +   ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type,
   1.387 +         &effect->hweffect->effect, &effect->hweffect->ref, NULL);
   1.388 +   if (FAILED(ret)) {
   1.389 +      DI_SetError("Unable to create effect",ret);
   1.390        goto err_effectdone;
   1.391     }
   1.392  
   1.393     return 0;
   1.394  
   1.395  err_effectdone:
   1.396 -   SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type);
   1.397 +   SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
   1.398  err_hweffect:
   1.399     if (effect->hweffect != NULL) {
   1.400        SDL_free(effect->hweffect);
   1.401 @@ -907,34 +949,40 @@
   1.402        struct haptic_effect * effect, SDL_HapticEffect * data)
   1.403  {
   1.404     HRESULT ret;
   1.405 -   FFEffectParameterFlag flags;
   1.406 -   FFEFFECT temp;
   1.407 +   DWORD flags;
   1.408 +   DIEFFECT temp;
   1.409  
   1.410     /* Get the effect. */
   1.411 -   SDL_memset(&temp, 0, sizeof(FFEFFECT));
   1.412 -   if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) {
   1.413 +   SDL_memset(&temp, 0, sizeof(DIEFFECT));
   1.414 +   if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) {
   1.415        goto err_update;
   1.416     }
   1.417  
   1.418     /* Set the flags.  Might be worthwhile to diff temp with loaded effect and
   1.419      *  only change those parameters. */
   1.420 -   flags = FFEP_ALLPARAMS;
   1.421 +   flags = DIEP_DIRECTION | 
   1.422 +           DIEP_DURATION |
   1.423 +           DIEP_ENVELOPE |
   1.424 +           DIEP_STARTDELAY |
   1.425 +           DIEP_TRIGGERBUTTON |
   1.426 +           DIEP_TRIGGERREPEATINTERVAL |
   1.427 +           DIEP_TYPESPECIFICPARAMS;
   1.428  
   1.429     /* Create the actual effect. */
   1.430 -   ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags);
   1.431 +   ret = IDirectInputDevice2_SetParameters(effect->hweffect->ref, &temp, flags);
   1.432     if (ret != FF_OK) {
   1.433        SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret));
   1.434        goto err_update;
   1.435     }
   1.436  
   1.437     /* Copy it over. */
   1.438 -   SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type);
   1.439 -   SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT));
   1.440 +   SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type);
   1.441 +   SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT));
   1.442  
   1.443     return 0;
   1.444  
   1.445  err_update:
   1.446 -   SDL_SYS_HapticFreeFFEFFECT(&temp, data->type);
   1.447 +   SDL_SYS_HapticFreeDIEFFECT(&temp, data->type);
   1.448     return -1;
   1.449  }
   1.450  
   1.451 @@ -947,19 +995,19 @@
   1.452                          Uint32 iterations)
   1.453  {
   1.454     HRESULT ret;
   1.455 -   Uint32 iter;
   1.456 +   DWORD iter;
   1.457  
   1.458     /* Check if it's infinite. */
   1.459     if (iterations == SDL_HAPTIC_INFINITY) {
   1.460 -      iter = FF_INFINITE;
   1.461 +      iter = INFINITE;
   1.462     }
   1.463     else
   1.464        iter = iterations;
   1.465  
   1.466     /* Run the effect. */
   1.467 -   ret = FFEffectStart(effect->hweffect->ref, iter, 0);
   1.468 -   if (ret != FF_OK) {
   1.469 -      SDL_SetError("Haptic: Unable to run the effect: %s.", FFStrError(ret));
   1.470 +   ret = IDirectInputEffect_Start( effect->hweffect->ref, iter, 0 );
   1.471 +   if (FAILED(ret)) {
   1.472 +      DI_SetError("Running the effect",ret);
   1.473        return -1;
   1.474     }
   1.475  
   1.476 @@ -975,9 +1023,9 @@
   1.477  {
   1.478     HRESULT ret;
   1.479  
   1.480 -   ret = FFEffectStop(effect->hweffect->ref);
   1.481 -   if (ret != FF_OK) {
   1.482 -      SDL_SetError("Haptic: Unable to stop the effect: %s.", FFStrError(ret));
   1.483 +   ret = IDirectInputEffect_Stop(effect->hweffect->ref);
   1.484 +   if (FAILED(ret)) {
   1.485 +      DI_SetError("Unable to stop effect",ret);
   1.486        return -1;
   1.487     }
   1.488  
   1.489 @@ -993,13 +1041,11 @@
   1.490  {
   1.491     HRESULT ret;
   1.492  
   1.493 -   ret = FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref);
   1.494 -   if (ret != FF_OK) {
   1.495 -      SDL_SetError("Haptic: Error removing the effect from the device: %s.",
   1.496 -                   FFStrError(ret));
   1.497 +   ret = IDirectInputEffect_Unload(effect->hweffect->ref);
   1.498 +   if (FAILED(ret)) {
   1.499 +      DI_SetError("Removing effect from the device",ret);
   1.500     }
   1.501 -   SDL_free(effect->hweffect->effect.lpvTypeSpecificParams);
   1.502 -   effect->hweffect->effect.lpvTypeSpecificParams = NULL;
   1.503 +   SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, effect->effect.type);   
   1.504     SDL_free(effect->hweffect);
   1.505     effect->hweffect = NULL;
   1.506  }
   1.507 @@ -1011,6 +1057,8 @@
   1.508  int
   1.509  SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect * effect)
   1.510  {
   1.511 +   SDL_SetError("Haptic: Status not supported.");
   1.512 +   return -1;
   1.513  }
   1.514  
   1.515