[PATCH 1/4] dinput: Fix calculation of too small periods for periodic effect

Bruno Jesus 00cpxxx at gmail.com
Wed Aug 24 20:55:56 CDT 2016


Based on ideas by Elias Vanderstuyft.

This file indentation is hell, in every patch I'll try to change a bit of the surrounding code. All the patch is doing is:

From:
This->effect.u.periodic.period = tsp->dwPeriod / 1000;

To:
if (tsp->dwPeriod <= 1000)
    This->effect.u.periodic.period = 1;
else
    This->effect.u.periodic.period = tsp->dwPeriod / 1000;

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
 dlls/dinput/effect_linuxinput.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index bbcadf5..0d2fdf5 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -588,19 +588,29 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters(
     if (dwFlags & DIEP_TRIGGERREPEATINTERVAL)
 	This->effect.trigger.interval = peff->dwTriggerRepeatInterval / 1000;
 
-    if (dwFlags & DIEP_TYPESPECIFICPARAMS) {
-	if (!(peff->lpvTypeSpecificParams))
-	    return DIERR_INCOMPLETEEFFECT;
-	if (type == DIEFT_PERIODIC) {
-            LPCDIPERIODIC tsp;
+    if (dwFlags & DIEP_TYPESPECIFICPARAMS)
+    {
+        if (!(peff->lpvTypeSpecificParams))
+            return DIERR_INCOMPLETEEFFECT;
+
+        if (type == DIEFT_PERIODIC)
+        {
+            DIPERIODIC *tsp;
             if (peff->cbTypeSpecificParams != sizeof(DIPERIODIC))
                 return DIERR_INVALIDPARAM;
             tsp = peff->lpvTypeSpecificParams;
-	    This->effect.u.periodic.magnitude = (tsp->dwMagnitude / 10) * 32;
-	    This->effect.u.periodic.offset = (tsp->lOffset / 10) * 32;
-	    This->effect.u.periodic.phase = (tsp->dwPhase / 9) * 8; /* == (/ 36 * 32) */
-	    This->effect.u.periodic.period = tsp->dwPeriod / 1000;
-	} else if (type == DIEFT_CONSTANTFORCE) {
+
+            This->effect.u.periodic.magnitude = (tsp->dwMagnitude / 10) * 32;
+            This->effect.u.periodic.offset = (tsp->lOffset / 10) * 32;
+            This->effect.u.periodic.phase = (tsp->dwPhase / 9) * 8; /* == (/ 36 * 32) */
+            /* dinput uses microseconds, linux uses miliseconds */
+            if (tsp->dwPeriod <= 1000)
+                This->effect.u.periodic.period = 1;
+            else
+                This->effect.u.periodic.period = tsp->dwPeriod / 1000;
+        }
+        else if (type == DIEFT_CONSTANTFORCE)
+        {
             LPCDICONSTANTFORCE tsp;
             if (peff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE))
                 return DIERR_INVALIDPARAM;
-- 
2.9.3




More information about the wine-patches mailing list