Updated button trigger stuff. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 30 Jul 2008 15:00:45 +0000
branchgsoc2008_force_feedback
changeset 2556fe346eddd3fb
parent 2555 f5bcc926bac4
child 2557 30778d9d8bff
Updated button trigger stuff.
src/haptic/darwin/SDL_syshaptic.c
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 14:50:00 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 15:00:45 2008 +0000
     1.3 @@ -524,7 +524,7 @@
     1.4     dwTriggerButton = FFEB_NOTRIGGER;
     1.5  
     1.6     if (button != 0) {
     1.7 -      dwTriggerButton = FFJOFS_BUTTON(button);
     1.8 +      dwTriggerButton = FFJOFS_BUTTON(button - 1);
     1.9     }
    1.10  
    1.11     return dwTriggerButton;
     2.1 --- a/src/haptic/linux/SDL_syshaptic.c	Wed Jul 30 14:50:00 2008 +0000
     2.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Wed Jul 30 15:00:45 2008 +0000
     2.3 @@ -453,6 +453,25 @@
     2.4     SDL_hapticlist[0].fname = NULL;
     2.5  }
     2.6  
     2.7 +
     2.8 +/*
     2.9 + * Converts an SDL button to a ff_trigger button.
    2.10 + */
    2.11 +static Uint16
    2.12 +SDL_SYS_ToButton( Uint16 button )
    2.13 +{
    2.14 +   Uint16 ff_button;
    2.15 +
    2.16 +   ff_button = 0;
    2.17 +
    2.18 +   if (button != 0) {
    2.19 +      ff_button = BTN_GAMEPAD + button - 1;
    2.20 +   }
    2.21 +
    2.22 +   return ff_button;
    2.23 +}
    2.24 +
    2.25 +
    2.26  /*
    2.27   * Returns the ff_effect usable direction from a SDL_HapticDirection.
    2.28   */
    2.29 @@ -488,6 +507,7 @@
    2.30     return 0;
    2.31  }
    2.32  
    2.33 +
    2.34  #define  CLAMP(x)    (((x) > 32767) ? 32767 : x)
    2.35  /*
    2.36   * Initializes the linux effect struct from a haptic_effect.
    2.37 @@ -520,7 +540,7 @@
    2.38           dest->replay.delay = CLAMP(constant->delay);
    2.39  
    2.40           /* Trigger */
    2.41 -         dest->trigger.button = CLAMP(constant->button);
    2.42 +         dest->trigger.button = SDL_SYS_ToButton(constant->button);
    2.43           dest->trigger.interval = CLAMP(constant->interval);
    2.44  
    2.45           /* Constant */
    2.46 @@ -552,7 +572,7 @@
    2.47           dest->replay.delay = CLAMP(periodic->delay);
    2.48           
    2.49           /* Trigger */
    2.50 -         dest->trigger.button = CLAMP(periodic->button);
    2.51 +         dest->trigger.button = SDL_SYS_ToButton(periodic->button);
    2.52           dest->trigger.interval = CLAMP(periodic->interval);
    2.53           
    2.54           /* Periodic */
    2.55 @@ -604,7 +624,7 @@
    2.56           dest->replay.delay = CLAMP(condition->delay);
    2.57  
    2.58           /* Trigger */
    2.59 -         dest->trigger.button = CLAMP(condition->button);
    2.60 +         dest->trigger.button = SDL_SYS_ToButton(condition->button);
    2.61           dest->trigger.interval = CLAMP(condition->interval);
    2.62  
    2.63           /* Condition */
    2.64 @@ -639,7 +659,7 @@
    2.65           dest->replay.delay = CLAMP(ramp->delay);
    2.66  
    2.67           /* Trigger */
    2.68 -         dest->trigger.button = CLAMP(ramp->button);
    2.69 +         dest->trigger.button = SDL_SYS_ToButton(ramp->button);
    2.70           dest->trigger.interval = CLAMP(ramp->interval);
    2.71  
    2.72           /* Ramp */