src/haptic/linux/SDL_syshaptic.c
branchgsoc2008_force_feedback
changeset 2539 b4c41a7eea04
parent 2530 22ce87690b41
child 2556 fe346eddd3fb
--- a/src/haptic/linux/SDL_syshaptic.c	Sun Jul 20 14:12:52 2008 +0000
+++ b/src/haptic/linux/SDL_syshaptic.c	Sun Jul 20 16:21:15 2008 +0000
@@ -515,7 +515,8 @@
          if (dest->direction < 0) return -1;
 
          /* Replay */
-         dest->replay.length = CLAMP(constant->length);
+         dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ?
+               0 : CLAMP(constant->length);
          dest->replay.delay = CLAMP(constant->delay);
 
          /* Trigger */
@@ -546,7 +547,8 @@
          if (dest->direction < 0) return -1;
          
          /* Replay */
-         dest->replay.length = CLAMP(periodic->length);
+         dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? 
+               0 : CLAMP(periodic->length);
          dest->replay.delay = CLAMP(periodic->delay);
          
          /* Trigger */
@@ -597,7 +599,8 @@
          dest->direction = 0; /* Handled by the condition-specifics. */
 
          /* Replay */
-         dest->replay.length = CLAMP(condition->length);
+         dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? 
+               0 : CLAMP(condition->length);
          dest->replay.delay = CLAMP(condition->delay);
 
          /* Trigger */
@@ -631,7 +634,8 @@
          if (dest->direction < 0) return -1;
 
          /* Replay */
-         dest->replay.length = CLAMP(ramp->length);
+         dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? 
+               0 : CLAMP(ramp->length);
          dest->replay.delay = CLAMP(ramp->delay);
 
          /* Trigger */
@@ -741,6 +745,7 @@
    /* Prepare to run the effect */
    run.type = EV_FF;
    run.code = effect->hweffect->effect.id;
+   /* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */
    run.value = (iterations > INT_MAX) ? INT_MAX : iterations;
 
    if (write(haptic->hwdata->fd, (const void*) &run, sizeof(run)) < 0) {