Made envelopes behave correctly with length of 0. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Wed, 30 Jul 2008 15:08:44 +0000
branchgsoc2008_force_feedback
changeset 2557 30778d9d8bff
parent 2556 fe346eddd3fb
child 2558 c38ac77ea28f
Made envelopes behave correctly with length of 0.
src/haptic/darwin/SDL_syshaptic.c
--- a/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 15:00:45 2008 +0000
+++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 15:08:44 2008 +0000
@@ -662,10 +662,20 @@
          }
          
          /* Envelope */
-         envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
-         envelope->dwAttackTime = hap_constant->attack_length * 1000;
-         envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
-         envelope->dwFadeTime = hap_constant->fade_length * 1000;
+         if (envelope->dwAttackTime == 0) {
+            envelope->dwAttackLevel = constant->dwMagnitude
+         }
+         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;
+         }
 
          break;
 
@@ -702,10 +712,20 @@
          }
          
          /* Envelope */
-         envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
-         envelope->dwAttackTime = hap_periodic->attack_length * 1000;
-         envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
-         envelope->dwFadeTime = hap_periodic->fade_length * 1000;
+         if (envelope->dwAttackTime == 0) {
+            envelope->dwAttackLevel = periodic->dwMagnitude
+         }
+         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;
+         }
 
          break;
 
@@ -745,6 +765,8 @@
          }                            
                                       
          /* Envelope */
+         SDL_free(dest->lpEnvelope);
+         dest->lpEnvelope = NULL;
 /* TODO Check is envelope actually used.
          envelope->dwAttackLevel = CONVERT(hap_condition->attack_level);
          envelope->dwAttackTime = hap_condition->attack_length * 1000;
@@ -781,10 +803,20 @@
          }
 
          /* Envelope */
-         envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
-         envelope->dwAttackTime = hap_ramp->attack_length * 1000;
-         envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
-         envelope->dwFadeTime = hap_ramp->fade_length * 1000;
+         if (envelope->dwAttackTime == 0) {
+            envelope->dwAttackLevel = ramp->dwMagnitude
+         }
+         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;
+         }
 
          break;
 
@@ -820,10 +852,20 @@
          }
          
          /* Envelope */
-         envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
-         envelope->dwAttackTime = hap_custom->attack_length * 1000;
-         envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
-         envelope->dwFadeTime = hap_custom->fade_length * 1000;
+         if (envelope->dwAttackTime == 0) {
+            envelope->dwAttackLevel = custom->dwMagnitude
+         }
+         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;
+         }
 
          break;