Bruno Jesus : dinput: Don't give up if we can' t translate the effect envelope.

Alexandre Julliard julliard at winehq.org
Thu Aug 25 10:39:36 CDT 2016


Module: wine
Branch: master
Commit: 4cf2ad9899d68ab5416514a1e817b3be41834d48
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4cf2ad9899d68ab5416514a1e817b3be41834d48

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Wed Aug 24 22:55:59 2016 -0300

dinput: Don't give up if we can't translate the effect envelope.

Based on ideas by Elias Vanderstuyft.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/effect_linuxinput.c | 52 +++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index b4e7b06..e2e75c7 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -557,30 +557,36 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
             This->effect.replay.length = 1;
     }
 
-    if (dwFlags & DIEP_ENVELOPE) {
+    if (dwFlags & DIEP_ENVELOPE)
+    {
         struct ff_envelope* env;
-        if (This->effect.type == FF_CONSTANT) env = &This->effect.u.constant.envelope;
-        else if (This->effect.type == FF_PERIODIC) env = &This->effect.u.periodic.envelope;
-        else if (This->effect.type == FF_RAMP) env = &This->effect.u.ramp.envelope;
-        else env = NULL; 
-
-	if (peff->lpEnvelope == NULL) {
-	    /* if this type had an envelope, reset it */
-	    if (env) {
-		env->attack_length = 0;
-		env->attack_level = 0;
-		env->fade_length = 0;
-		env->fade_level = 0;
-	    }
-	} else {
-	    /* did we get passed an envelope for a type that doesn't even have one? */
-	    if (!env) return DIERR_INVALIDPARAM;
-	    /* copy the envelope */
-	    env->attack_length = peff->lpEnvelope->dwAttackTime / 1000;
-	    env->attack_level = (peff->lpEnvelope->dwAttackLevel / 10) * 32;
-	    env->fade_length = peff->lpEnvelope->dwFadeTime / 1000;
-	    env->fade_level = (peff->lpEnvelope->dwFadeLevel / 10) * 32;
-	}
+        if (This->effect.type == FF_CONSTANT)
+            env = &This->effect.u.constant.envelope;
+        else if (This->effect.type == FF_PERIODIC)
+            env = &This->effect.u.periodic.envelope;
+        else if (This->effect.type == FF_RAMP)
+            env = &This->effect.u.ramp.envelope;
+        else
+            env = NULL;
+
+        /* copy the envelope if it is present and the linux effect supports it */
+        if (peff->lpEnvelope && env)
+        {
+            env->attack_length = peff->lpEnvelope->dwAttackTime / 1000;
+            env->attack_level = (peff->lpEnvelope->dwAttackLevel / 10) * 32;
+            env->fade_length = peff->lpEnvelope->dwFadeTime / 1000;
+            env->fade_level = (peff->lpEnvelope->dwFadeLevel / 10) * 32;
+        }
+        /* if the dinput envelope is NULL we will clear the linux envelope */
+        else if (env)
+        {
+            env->attack_length = 0;
+            env->attack_level = 0;
+            env->fade_length = 0;
+            env->fade_level = 0;
+        }
+        else
+            WARN("Ignoring dinput envelope not supported in the linux effect\n");
     }
 
     /* Gain and Sample Period settings are not supported by the linux




More information about the wine-cvs mailing list