More verbose about envelopes. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Thu, 31 Jul 2008 10:25:49 +0000
branchgsoc2008_force_feedback
changeset 2563 be2ea885d70b
parent 2562 c284ce0cd8e0
child 2564 c9348710a98a
More verbose about envelopes.
include/SDL_haptic.h
src/haptic/darwin/SDL_syshaptic.c
--- a/include/SDL_haptic.h	Thu Jul 31 10:21:11 2008 +0000
+++ b/include/SDL_haptic.h	Thu Jul 31 10:25:49 2008 +0000
@@ -649,6 +649,9 @@
  *  use them if possible.  Buttons start at index 1 instead of index 0 like
  *  they joystick.
  *
+ * If both attack_length and fade_level are 0, the envelope is not used,
+ *  otherwise both values are used.
+ *
  * Common parts:
  * \code
  * // Replay - All effects have this
--- 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;
          }