From: Christoph Brill Subject: [PATCH 1/2] RFC: Implement XInputEnable based on MSDN Message-Id: <20170211230538.5225-1-egore911@gmail.com> Date: Sun, 12 Feb 2017 00:05:37 +0100 In-Reply-To: <20170211225256.3347-2-egore911@gmail.com> References: <20170211225256.3347-2-egore911@gmail.com> --- 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..f3f0edfe1b 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; } @@ -107,6 +138,18 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetStateEx(DWORD index, XINPUT_STATE_EX* st 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