Mercurial > sdl-ios-xcode
changeset 2557:30778d9d8bff gsoc2008_force_feedback
Made envelopes behave correctly with length of 0.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Wed, 30 Jul 2008 15:08:44 +0000 |
parents | fe346eddd3fb |
children | c38ac77ea28f |
files | src/haptic/darwin/SDL_syshaptic.c |
diffstat | 1 files changed, 58 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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;