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 255730778d9d8bff
parent 2556 fe346eddd3fb
child 2558 c38ac77ea28f
Made envelopes behave correctly with length of 0.
src/haptic/darwin/SDL_syshaptic.c
     1.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 15:00:45 2008 +0000
     1.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Jul 30 15:08:44 2008 +0000
     1.3 @@ -662,10 +662,20 @@
     1.4           }
     1.5           
     1.6           /* Envelope */
     1.7 -         envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
     1.8 -         envelope->dwAttackTime = hap_constant->attack_length * 1000;
     1.9 -         envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
    1.10 -         envelope->dwFadeTime = hap_constant->fade_length * 1000;
    1.11 +         if (envelope->dwAttackTime == 0) {
    1.12 +            envelope->dwAttackLevel = constant->dwMagnitude
    1.13 +         }
    1.14 +         else {
    1.15 +            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
    1.16 +            envelope->dwAttackTime = hap_constant->attack_length * 1000;
    1.17 +         }
    1.18 +         if (envelope->dwFadeTime == 0) {
    1.19 +            envelope->dwFadeLevel = constant->dwMagnitude
    1.20 +         }
    1.21 +         else {
    1.22 +            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
    1.23 +            envelope->dwFadeTime = hap_constant->fade_length * 1000;
    1.24 +         }
    1.25  
    1.26           break;
    1.27  
    1.28 @@ -702,10 +712,20 @@
    1.29           }
    1.30           
    1.31           /* Envelope */
    1.32 -         envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
    1.33 -         envelope->dwAttackTime = hap_periodic->attack_length * 1000;
    1.34 -         envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
    1.35 -         envelope->dwFadeTime = hap_periodic->fade_length * 1000;
    1.36 +         if (envelope->dwAttackTime == 0) {
    1.37 +            envelope->dwAttackLevel = periodic->dwMagnitude
    1.38 +         }
    1.39 +         else {
    1.40 +            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
    1.41 +            envelope->dwAttackTime = hap_periodic->attack_length * 1000;
    1.42 +         }
    1.43 +         if (envelope->dwFadeTime == 0) {
    1.44 +            envelope->dwFadeLevel = periodic->dwMagnitude
    1.45 +         }
    1.46 +         else {
    1.47 +            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
    1.48 +            envelope->dwFadeTime = hap_periodic->fade_length * 1000;
    1.49 +         }
    1.50  
    1.51           break;
    1.52  
    1.53 @@ -745,6 +765,8 @@
    1.54           }                            
    1.55                                        
    1.56           /* Envelope */
    1.57 +         SDL_free(dest->lpEnvelope);
    1.58 +         dest->lpEnvelope = NULL;
    1.59  /* TODO Check is envelope actually used.
    1.60           envelope->dwAttackLevel = CONVERT(hap_condition->attack_level);
    1.61           envelope->dwAttackTime = hap_condition->attack_length * 1000;
    1.62 @@ -781,10 +803,20 @@
    1.63           }
    1.64  
    1.65           /* Envelope */
    1.66 -         envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
    1.67 -         envelope->dwAttackTime = hap_ramp->attack_length * 1000;
    1.68 -         envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
    1.69 -         envelope->dwFadeTime = hap_ramp->fade_length * 1000;
    1.70 +         if (envelope->dwAttackTime == 0) {
    1.71 +            envelope->dwAttackLevel = ramp->dwMagnitude
    1.72 +         }
    1.73 +         else {
    1.74 +            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
    1.75 +            envelope->dwAttackTime = hap_ramp->attack_length * 1000;
    1.76 +         }
    1.77 +         if (envelope->dwFadeTime == 0) {
    1.78 +            envelope->dwFadeLevel = ramp->dwMagnitude
    1.79 +         }
    1.80 +         else {
    1.81 +            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
    1.82 +            envelope->dwFadeTime = hap_ramp->fade_length * 1000;
    1.83 +         }
    1.84  
    1.85           break;
    1.86  
    1.87 @@ -820,10 +852,20 @@
    1.88           }
    1.89           
    1.90           /* Envelope */
    1.91 -         envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
    1.92 -         envelope->dwAttackTime = hap_custom->attack_length * 1000;
    1.93 -         envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
    1.94 -         envelope->dwFadeTime = hap_custom->fade_length * 1000;
    1.95 +         if (envelope->dwAttackTime == 0) {
    1.96 +            envelope->dwAttackLevel = custom->dwMagnitude
    1.97 +         }
    1.98 +         else {
    1.99 +            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
   1.100 +            envelope->dwAttackTime = hap_custom->attack_length * 1000;
   1.101 +         }
   1.102 +         if (envelope->dwFadeTime == 0) {
   1.103 +            envelope->dwFadeLevel = custom->dwMagnitude
   1.104 +         }
   1.105 +         else {
   1.106 +            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
   1.107 +            envelope->dwFadeTime = hap_custom->fade_length * 1000;
   1.108 +         }
   1.109  
   1.110           break;
   1.111