Properly support INFINITY length haptic effects on linux. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Sun, 20 Jul 2008 16:21:15 +0000
branchgsoc2008_force_feedback
changeset 2539b4c41a7eea04
parent 2538 1f9c20580ab4
child 2540 56cf872c723a
Properly support INFINITY length haptic effects on linux.
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sun Jul 20 14:12:52 2008 +0000
     1.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sun Jul 20 16:21:15 2008 +0000
     1.3 @@ -515,7 +515,8 @@
     1.4           if (dest->direction < 0) return -1;
     1.5  
     1.6           /* Replay */
     1.7 -         dest->replay.length = CLAMP(constant->length);
     1.8 +         dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ?
     1.9 +               0 : CLAMP(constant->length);
    1.10           dest->replay.delay = CLAMP(constant->delay);
    1.11  
    1.12           /* Trigger */
    1.13 @@ -546,7 +547,8 @@
    1.14           if (dest->direction < 0) return -1;
    1.15           
    1.16           /* Replay */
    1.17 -         dest->replay.length = CLAMP(periodic->length);
    1.18 +         dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? 
    1.19 +               0 : CLAMP(periodic->length);
    1.20           dest->replay.delay = CLAMP(periodic->delay);
    1.21           
    1.22           /* Trigger */
    1.23 @@ -597,7 +599,8 @@
    1.24           dest->direction = 0; /* Handled by the condition-specifics. */
    1.25  
    1.26           /* Replay */
    1.27 -         dest->replay.length = CLAMP(condition->length);
    1.28 +         dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? 
    1.29 +               0 : CLAMP(condition->length);
    1.30           dest->replay.delay = CLAMP(condition->delay);
    1.31  
    1.32           /* Trigger */
    1.33 @@ -631,7 +634,8 @@
    1.34           if (dest->direction < 0) return -1;
    1.35  
    1.36           /* Replay */
    1.37 -         dest->replay.length = CLAMP(ramp->length);
    1.38 +         dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? 
    1.39 +               0 : CLAMP(ramp->length);
    1.40           dest->replay.delay = CLAMP(ramp->delay);
    1.41  
    1.42           /* Trigger */
    1.43 @@ -741,6 +745,7 @@
    1.44     /* Prepare to run the effect */
    1.45     run.type = EV_FF;
    1.46     run.code = effect->hweffect->effect.id;
    1.47 +   /* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */
    1.48     run.value = (iterations > INT_MAX) ? INT_MAX : iterations;
    1.49  
    1.50     if (write(haptic->hwdata->fd, (const void*) &run, sizeof(run)) < 0) {