# HG changeset patch # User Edgar Simo # Date 1217430524 0 # Node ID 30778d9d8bff4a1f15ae65bf3d2e63851392cdbc # Parent fe346eddd3fb97bfd2925b7ca5e09952f3a23741 Made envelopes behave correctly with length of 0. diff -r fe346eddd3fb -r 30778d9d8bff 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;