Warn about using button triggers. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 30 Jul 2008 14:48:34 +0000
branchgsoc2008_force_feedback
changeset 25542681a04c2d3d
parent 2553 3f853f075bc0
child 2555 f5bcc926bac4
Warn about using button triggers.
include/SDL_haptic.h
src/haptic/darwin/SDL_syshaptic.c
     1.1 --- a/include/SDL_haptic.h	Wed Jul 30 14:09:10 2008 +0000
     1.2 +++ b/include/SDL_haptic.h	Wed Jul 30 14:48:34 2008 +0000
     1.3 @@ -645,6 +645,10 @@
     1.4   * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
     1.5   *  SDL_HAPTIC_INFINITY.
     1.6   *
     1.7 + * Button triggers may not be supported on all devices, it is advised to not
     1.8 + *  use them if possible.  Buttons start at index 1 instead of index 0 like
     1.9 + *  they joystick.
    1.10 + *
    1.11   * Common parts:
    1.12   * \code
    1.13   * // Replay - All effects have this
     2.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 14:09:10 2008 +0000
     2.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 14:48:34 2008 +0000
     2.3 @@ -309,8 +309,8 @@
     2.4     FF_TEST(FFCAP_ET_CUSTOMFORCE,   SDL_HAPTIC_CUSTOM);
     2.5  
     2.6     /* Check if supports gain. */
     2.7 -   ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
     2.8 -                                          &val, sizeof(val));
     2.9 +   ret = FFDeviceGetForceFeedbackProperty( device, FFPROP_FFGAIN,
    2.10 +                                           &val, sizeof(val));
    2.11     if (ret == FF_OK) supported |= SDL_HAPTIC_GAIN;
    2.12     else if (ret != FFERR_UNSUPPORTED) {
    2.13        SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
    2.14 @@ -514,6 +514,23 @@
    2.15  
    2.16  
    2.17  /*
    2.18 + * Converts an SDL trigger button to an FFEFFECT trigger button.
    2.19 + */
    2.20 +static DWORD
    2.21 +FFGetTriggerButton( Uint16 button )
    2.22 +{
    2.23 +   DWORD dwTriggerButton;
    2.24 +
    2.25 +   dwTriggerButton = FFEB_NOTRIGGER;
    2.26 +
    2.27 +   if (hap_constant->button != 0)
    2.28 +      dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
    2.29 +
    2.30 +   return dwTriggerButton;
    2.31 +}
    2.32 +
    2.33 +
    2.34 +/*
    2.35   * Sets the direction.
    2.36   */
    2.37  static int
    2.38 @@ -634,7 +651,7 @@
    2.39  
    2.40           /* Generics */
    2.41           dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */
    2.42 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_constant->button);
    2.43 +         dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button);
    2.44           dest->dwTriggerRepeatInterval = hap_constant->interval;
    2.45           dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */
    2.46  
    2.47 @@ -674,7 +691,7 @@
    2.48  
    2.49           /* Generics */
    2.50           dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */
    2.51 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_periodic->button);
    2.52 +         dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button);
    2.53           dest->dwTriggerRepeatInterval = hap_periodic->interval;
    2.54           dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */
    2.55           
    2.56 @@ -717,7 +734,7 @@
    2.57  
    2.58           /* Generics */
    2.59           dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */
    2.60 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_condition->button);
    2.61 +         dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button);
    2.62           dest->dwTriggerRepeatInterval = hap_condition->interval;
    2.63           dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */
    2.64  
    2.65 @@ -753,7 +770,7 @@
    2.66  
    2.67           /* Generics */
    2.68           dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */
    2.69 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_ramp->button);
    2.70 +         dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button);
    2.71           dest->dwTriggerRepeatInterval = hap_ramp->interval;
    2.72           dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */
    2.73  
    2.74 @@ -792,7 +809,7 @@
    2.75  
    2.76           /* Generics */
    2.77           dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */
    2.78 -         dest->dwTriggerButton = FFJOFS_BUTTON(hap_custom->button);
    2.79 +         dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button);
    2.80           dest->dwTriggerRepeatInterval = hap_custom->interval;
    2.81           dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */
    2.82