[PATCH] xinput: Fix vibration capabilities

Alexey Prokhin alexey at prokhin.ru
Wed Aug 7 11:51:35 CDT 2019


wLeftMotorSpeed and wRightMotorSpeed returned by XInputGetCapabilities
are supposed to be resolutions rather than current motor speeds.

This fixes rumble in Far Cry 5.

Signed-off-by: Alexey Prokhin <alexey at prokhin.ru>
---
I have two concernes about the patch:
1. I have no idea how to write a test for it. The only thing I can
think of is to dump Vibration the same way Gamepad is dumped in
test_get_capabilities(). I can do it in the next revision, if you wish.
2. The patch is a bit incorrect for xinput9_1_0. XInputGetCapabilities
from the library returns wLeftMotorSpeed=wRightMotorSpeed=1. It is
possible to define XINPUT_VER in Makefile.in. But should I bother with
this? Far Cry 5, my testing target, does not seem to care if the
returned values are 1 or 255. The rumble starts working either way.
---
 dlls/xinput1_3/hid.c            | 10 +++++++---
 dlls/xinput1_3/xinput_private.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/xinput1_3/hid.c b/dlls/xinput1_3/hid.c
index aa46f35239..38c93beb80 100644
--- a/dlls/xinput1_3/hid.c
+++ b/dlls/xinput1_3/hid.c
@@ -173,7 +173,11 @@ static BOOL VerifyGamepad(PHIDP_PREPARSED_DATA ppd, XINPUT_CAPABILITIES *xinput_
 
     value_caps_count = caps->NumberOutputValueCaps;
     if (value_caps_count > 0)
+    {
         xinput_caps->Flags |= XINPUT_CAPS_FFB_SUPPORTED;
+        xinput_caps->Vibration.wLeftMotorSpeed = 255;
+        xinput_caps->Vibration.wRightMotorSpeed = 255;
+    }
 
     return TRUE;
 }
@@ -456,8 +460,8 @@ DWORD HID_set_state(xinput_controller* device, XINPUT_VIBRATION* state)
 
     if (device->caps.Flags & XINPUT_CAPS_FFB_SUPPORTED)
     {
-        device->caps.Vibration.wLeftMotorSpeed = state->wLeftMotorSpeed;
-        device->caps.Vibration.wRightMotorSpeed = state->wRightMotorSpeed;
+        device->vibration.wLeftMotorSpeed = state->wLeftMotorSpeed;
+        device->vibration.wRightMotorSpeed = state->wRightMotorSpeed;
 
         if (private->enabled)
         {
@@ -498,7 +502,7 @@ void HID_enable(xinput_controller* device, BOOL enable)
         }
         else if (!private->enabled && enable)
         {
-            HID_set_state(device, &device->caps.Vibration);
+            HID_set_state(device, &device->vibration);
         }
         LeaveCriticalSection(&private->crit);
     }
diff --git a/dlls/xinput1_3/xinput_private.h b/dlls/xinput1_3/xinput_private.h
index 00888f4518..d6e0e9614e 100644
--- a/dlls/xinput1_3/xinput_private.h
+++ b/dlls/xinput1_3/xinput_private.h
@@ -23,6 +23,7 @@ typedef struct _xinput_controller
     XINPUT_CAPABILITIES caps;
     void *platform_private;
     XINPUT_STATE state;
+    XINPUT_VIBRATION vibration;
 } xinput_controller;
 
 
-- 
2.20.1 (Apple Git-117)




More information about the wine-devel mailing list