src/haptic/darwin/SDL_syshaptic.c
branchgsoc2008_force_feedback
changeset 2563 be2ea885d70b
parent 2562 c284ce0cd8e0
child 2564 c9348710a98a
--- a/src/haptic/darwin/SDL_syshaptic.c	Thu Jul 31 10:21:11 2008 +0000
+++ b/src/haptic/darwin/SDL_syshaptic.c	Thu Jul 31 10:25:49 2008 +0000
@@ -655,17 +655,13 @@
          }
          
          /* Envelope */
-         if (envelope->dwAttackTime == 0) {
-            envelope->dwAttackLevel = constant->dwMagnitude
+         if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
+            SDL_free(envelope);
+            dest->lpEnvelope = NULL;
          }
          else {
             envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
             envelope->dwAttackTime = hap_constant->attack_length * 1000;
-         }
-         if (envelope->dwFadeTime == 0) {
-            envelope->dwFadeLevel = constant->dwMagnitude
-         }
-         else {
             envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
             envelope->dwFadeTime = hap_constant->fade_length * 1000;
          }
@@ -705,17 +701,13 @@
          }
          
          /* Envelope */
-         if (envelope->dwAttackTime == 0) {
-            envelope->dwAttackLevel = periodic->dwMagnitude
+         if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
+            SDL_free(envelope);
+            dest->lpEnvelope = NULL;
          }
          else {
             envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
             envelope->dwAttackTime = hap_periodic->attack_length * 1000;
-         }
-         if (envelope->dwFadeTime == 0) {
-            envelope->dwFadeLevel = periodic->dwMagnitude
-         }
-         else {
             envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
             envelope->dwFadeTime = hap_periodic->fade_length * 1000;
          }
@@ -796,17 +788,12 @@
          }
 
          /* Envelope */
-         if (envelope->dwAttackTime == 0) {
-            envelope->dwAttackLevel = ramp->dwMagnitude
-         }
+         if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
+            SDL_free(envelope);
+            dest->lpEnvelope = NULL;
          else {
             envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
             envelope->dwAttackTime = hap_ramp->attack_length * 1000;
-         }
-         if (envelope->dwFadeTime == 0) {
-            envelope->dwFadeLevel = ramp->dwMagnitude
-         }
-         else {
             envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
             envelope->dwFadeTime = hap_ramp->fade_length * 1000;
          }
@@ -845,17 +832,13 @@
          }
          
          /* Envelope */
-         if (envelope->dwAttackTime == 0) {
-            envelope->dwAttackLevel = custom->dwMagnitude
+         if ((envelope->dwAttackTime == 0) && (envelope->dwFadeTime == 0)) {
+            SDL_free(envelope);
+            dest->lpEnvelope = NULL;
          }
          else {
             envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
             envelope->dwAttackTime = hap_custom->attack_length * 1000;
-         }
-         if (envelope->dwFadeTime == 0) {
-            envelope->dwFadeLevel = custom->dwMagnitude
-         }
-         else {
             envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
             envelope->dwFadeTime = hap_custom->fade_length * 1000;
          }