[PATCH 1/2] RFC: Implement XInputEnable based on MSDN

Christoph Brill egore911 at gmail.com
Sat Feb 11 16:52:55 CST 2017


---
 dlls/xinput1_3/xinput1_3_main.c | 45 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/dlls/xinput1_3/xinput1_3_main.c b/dlls/xinput1_3/xinput1_3_main.c
index 6c559de765..e91304f9ef 100644
--- a/dlls/xinput1_3/xinput1_3_main.c
+++ b/dlls/xinput1_3/xinput1_3_main.c
@@ -34,6 +34,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(xinput);
 
+static BOOL enabled = TRUE;
+
 struct
 {
     BOOL connected;
@@ -52,11 +54,35 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
 
 void WINAPI DECLSPEC_HOTPATCH XInputEnable(BOOL enable)
 {
+    int i;
+
     /* Setting to false will stop messages from XInputSetState being sent
     to the controllers. Setting to true will send the last vibration
     value (sent to XInputSetState) to the controller and allow messages to
     be sent */
-    FIXME("(enable %d) Stub!\n", enable);
+    TRACE("XInputEnable(%d)\n", enable);
+    enabled = enable;
+
+    if (enabled)
+    {
+        for (i = 0; i < XUSER_MAX_COUNT; i++)
+        {
+            if (controllers[i].connected)
+            {
+                FIXME("XInputEnable should reenable vibration and resend the last event\n");
+            }
+        }
+    }
+    else
+    {
+        for (i = 0; i < XUSER_MAX_COUNT; i++)
+        {
+            if (controllers[i].connected)
+            {
+                FIXME("XInputEnable should disable vibration and keep the last event\n");
+            }
+        }
+    }
 }
 
 DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration)
@@ -68,6 +94,11 @@ DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration)
     if (!controllers[index].connected)
         return ERROR_DEVICE_NOT_CONNECTED;
 
+    if (!enabled)
+    {
+        return ERROR_SUCCESS;
+    }
+
     return ERROR_NOT_SUPPORTED;
 }
 
@@ -134,6 +165,18 @@ DWORD WINAPI XInputGetCapabilities(DWORD index, DWORD flags, XINPUT_CAPABILITIES
     if (!controllers[index].connected)
         return ERROR_DEVICE_NOT_CONNECTED;
 
+    if (!enabled)
+    {
+        state_ex->Gamepad.wButtons = 0x00;
+        state_ex->Gamepad.bLeftTrigger = 0;
+        state_ex->Gamepad.bRightTrigger = 0;
+        state_ex->Gamepad.sThumbLX = 0;
+        state_ex->Gamepad.sThumbLY = 0;
+        state_ex->Gamepad.sThumbRX = 0;
+        state_ex->Gamepad.sThumbRY = 0;
+        return ERROR_SUCCESS;
+    }
+
     return ERROR_NOT_SUPPORTED;
 }
 
-- 
2.11.1




More information about the wine-patches mailing list