MCPcopy Create free account
hub / github.com/360Controller/360Controller / CalcEnvelope

Method CalcEnvelope

Feedback360/Feedback360Effect.cpp:134–163  ·  view source on GitHub ↗

---------------------------------------------------------------------------------------------- CalcEnvelope ----------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

132// CalcEnvelope
133//----------------------------------------------------------------------------------------------
134void Feedback360Effect::CalcEnvelope(ULONG Duration, ULONG CurrentPos, LONG *NormalRate, LONG *AttackLevel, LONG *FadeLevel)
135{
136 if( ( DiEffect.dwFlags & FFEP_ENVELOPE ) && DiEffect.lpEnvelope != NULL )
137 {
138 // Calculate attack factor
139 LONG AttackRate = 0;
140 ULONG AttackTime = max( (DWORD)1, DiEnvelope.dwAttackTime / 1000 );
141 if (CurrentPos < AttackTime)
142 {
143 AttackRate = ( AttackTime - CurrentPos ) * 100 / AttackTime;
144 }
145
146 // Calculate fade factor
147 LONG FadeRate = 0;
148 ULONG FadeTime = max( (DWORD)1, DiEnvelope.dwFadeTime / 1000 );
149 ULONG FadePos = Duration - FadeTime;
150 if (FadePos < CurrentPos)
151 {
152 FadeRate = ( CurrentPos - FadePos ) * 100 / FadeTime;
153 }
154
155 *NormalRate = 100 - AttackRate - FadeRate;
156 *AttackLevel = DiEnvelope.dwAttackLevel * AttackRate;
157 *FadeLevel = DiEnvelope.dwFadeLevel * FadeRate;
158 } else {
159 *NormalRate = 100;
160 *AttackLevel = 0;
161 *FadeLevel = 0;
162 }
163}
164
165void Feedback360Effect::CalcForce(ULONG Duration, ULONG CurrentPos, LONG NormalRate, LONG AttackLevel, LONG FadeLevel, LONG * NormalLevel)
166{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected