src/haptic/windows/SDL_syshaptic.c
changeset 7621 5caa5fb3deb6
parent 7481 5ff71e03d9eb
child 7622 d758150805de
     1.1 --- a/src/haptic/windows/SDL_syshaptic.c	Sat Aug 10 13:20:45 2013 -0400
     1.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Sat Aug 10 13:38:09 2013 -0400
     1.3 @@ -303,7 +303,8 @@
     1.4      EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT);
     1.5      EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM);
     1.6      EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE);
     1.7 -    EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);
     1.8 +    /* !!! FIXME: put this back when we have more bits in 2.1 */
     1.9 +    /*EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE);*/
    1.10      EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE);
    1.11      EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP);
    1.12      EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN);
    1.13 @@ -389,8 +390,7 @@
    1.14      XINPUT_VIBRATION vibration = { 0, 0 };  /* stop any current vibration */
    1.15      XINPUTSETSTATE(userid, &vibration);
    1.16  
    1.17 -    /* !!! FIXME: we can probably do more than SINE if we figure out how to set up the left and right motors properly. */
    1.18 -    haptic->supported = SDL_HAPTIC_SINE;
    1.19 +    haptic->supported = SDL_HAPTIC_LEFTRIGHT;
    1.20  
    1.21      haptic->neffects = 1;
    1.22      haptic->nplaying = 1;
    1.23 @@ -935,7 +935,8 @@
    1.24          break;
    1.25  
    1.26      case SDL_HAPTIC_SINE:
    1.27 -    case SDL_HAPTIC_SQUARE:
    1.28 +    /* !!! FIXME: put this back when we have more bits in 2.1 */
    1.29 +    /*case SDL_HAPTIC_SQUARE:*/
    1.30      case SDL_HAPTIC_TRIANGLE:
    1.31      case SDL_HAPTIC_SAWTOOTHUP:
    1.32      case SDL_HAPTIC_SAWTOOTHDOWN:
    1.33 @@ -1163,8 +1164,9 @@
    1.34      case SDL_HAPTIC_RAMP:
    1.35          return &GUID_RampForce;
    1.36  
    1.37 -    case SDL_HAPTIC_SQUARE:
    1.38 -        return &GUID_Square;
    1.39 +    /* !!! FIXME: put this back when we have more bits in 2.1 */
    1.40 +    /*case SDL_HAPTIC_SQUARE:
    1.41 +        return &GUID_Square;*/
    1.42  
    1.43      case SDL_HAPTIC_SINE:
    1.44          return &GUID_Sine;
    1.45 @@ -1210,7 +1212,7 @@
    1.46      HRESULT ret;
    1.47      REFGUID type = SDL_SYS_HapticEffectType(base);
    1.48  
    1.49 -    if (type == NULL) {
    1.50 +    if ((type == NULL) && (!haptic->hwdata->bXInputHaptic)) {
    1.51          goto err_hweffect;
    1.52      }
    1.53  
    1.54 @@ -1225,7 +1227,7 @@
    1.55      SDL_zerop(effect->hweffect);
    1.56  
    1.57      if (haptic->hwdata->bXInputHaptic) {
    1.58 -        SDL_assert(base->type == SDL_HAPTIC_SINE);  /* should catch this at higher level */
    1.59 +        SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT);  /* should catch this at higher level */
    1.60          return SDL_SYS_HapticUpdateEffect(haptic, effect, base);
    1.61      }
    1.62  
    1.63 @@ -1269,20 +1271,14 @@
    1.64      DIEFFECT temp;
    1.65  
    1.66      if (haptic->hwdata->bXInputHaptic) {
    1.67 -        /* !!! FIXME: this isn't close to right. We only support "sine" effects,
    1.68 -         * !!! FIXME:  we ignore most of the parameters, and we probably get
    1.69 -         * !!! FIXME:  the ones we don't ignore wrong, too.
    1.70 -         * !!! FIXME: if I had a better understanding of how the two motors
    1.71 -         * !!! FIXME:  could be used in unison, perhaps I could implement other
    1.72 -         * !!! FIXME:  effect types?
    1.73 -         */
    1.74          /* From MSDN:
    1.75              "Note that the right motor is the high-frequency motor, the left
    1.76               motor is the low-frequency motor. They do not always need to be
    1.77               set to the same amount, as they provide different effects." */
    1.78          XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
    1.79 -        SDL_assert(data->type == SDL_HAPTIC_SINE);
    1.80 -        vib->wLeftMotorSpeed = vib->wRightMotorSpeed = data->periodic.magnitude * 2;
    1.81 +        SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT);
    1.82 +        vib->wLeftMotorSpeed = data->leftright.large_magnitude;
    1.83 +        vib->wRightMotorSpeed = data->leftright.small_magnitude;
    1.84          return 0;
    1.85      }
    1.86  
    1.87 @@ -1333,9 +1329,9 @@
    1.88  
    1.89      if (haptic->hwdata->bXInputHaptic) {
    1.90          XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
    1.91 -        SDL_assert(effect->effect.type == SDL_HAPTIC_SINE);  /* should catch this at higher level */
    1.92 +        SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT);  /* should catch this at higher level */
    1.93          SDL_LockMutex(haptic->hwdata->mutex);
    1.94 -        haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.periodic.length * iterations);
    1.95 +        haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations);
    1.96          SDL_UnlockMutex(haptic->hwdata->mutex);
    1.97          return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1;
    1.98      }