Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46142 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/xinput1_3/xinput_main.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/xinput1_3/xinput_main.c b/dlls/xinput1_3/xinput_main.c index 56bb36a05d..f6e3e15568 100644 --- a/dlls/xinput1_3/xinput_main.c +++ b/dlls/xinput1_3/xinput_main.c @@ -85,13 +85,31 @@ DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration) return HID_set_state(&controllers[index], vibration); }
+/* Some versions of SteamOverlayRenderer hot-patch XInputGetStateEx() and call + * XInputGetState() in the hook, so we need a wrapper. */ +static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state) +{ + HID_find_gamepads(controllers); + + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) + return ERROR_DEVICE_NOT_CONNECTED; + + HID_update_state(&controllers[index]); + memcpy(state, &controllers[index].state, sizeof(XINPUT_STATE)); + + return ERROR_SUCCESS; +} + + DWORD WINAPI DECLSPEC_HOTPATCH XInputGetState(DWORD index, XINPUT_STATE* state) { DWORD ret;
TRACE("(index %u, state %p)!\n", index, state);
- ret = XInputGetStateEx(index, state); + ret = xinput_get_state(index, state); if (ret != ERROR_SUCCESS) return ret;
@@ -105,17 +123,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetStateEx(DWORD index, XINPUT_STATE* state { TRACE("(index %u, state %p)!\n", index, state);
- HID_find_gamepads(controllers); - - if (index >= XUSER_MAX_COUNT) - return ERROR_BAD_ARGUMENTS; - if (!controllers[index].connected) - return ERROR_DEVICE_NOT_CONNECTED; - - HID_update_state(&controllers[index]); - memcpy(state, &controllers[index].state, sizeof(XINPUT_STATE)); - - return ERROR_SUCCESS; + return xinput_get_state(index, state); }
DWORD WINAPI XInputGetKeystroke(DWORD index, DWORD reserved, PXINPUT_KEYSTROKE keystroke)
Signed-off-by: Aric Stewart aric@codeweavers.com
On 11/18/18 1:15 PM, Zebediah Figura wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46142 Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/xinput1_3/xinput_main.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/xinput1_3/xinput_main.c b/dlls/xinput1_3/xinput_main.c index 56bb36a05d..f6e3e15568 100644 --- a/dlls/xinput1_3/xinput_main.c +++ b/dlls/xinput1_3/xinput_main.c @@ -85,13 +85,31 @@ DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration) return HID_set_state(&controllers[index], vibration); }
+/* Some versions of SteamOverlayRenderer hot-patch XInputGetStateEx() and call
- XInputGetState() in the hook, so we need a wrapper. */
+static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state) +{
- HID_find_gamepads(controllers);
- if (index >= XUSER_MAX_COUNT)
return ERROR_BAD_ARGUMENTS;
- if (!controllers[index].connected)
return ERROR_DEVICE_NOT_CONNECTED;
- HID_update_state(&controllers[index]);
- memcpy(state, &controllers[index].state, sizeof(XINPUT_STATE));
- return ERROR_SUCCESS;
+}
DWORD WINAPI DECLSPEC_HOTPATCH XInputGetState(DWORD index, XINPUT_STATE* state) { DWORD ret;
TRACE("(index %u, state %p)!\n", index, state);
- ret = XInputGetStateEx(index, state);
- ret = xinput_get_state(index, state); if (ret != ERROR_SUCCESS) return ret;
@@ -105,17 +123,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetStateEx(DWORD index, XINPUT_STATE* state { TRACE("(index %u, state %p)!\n", index, state);
- HID_find_gamepads(controllers);
- if (index >= XUSER_MAX_COUNT)
return ERROR_BAD_ARGUMENTS;
- if (!controllers[index].connected)
return ERROR_DEVICE_NOT_CONNECTED;
- HID_update_state(&controllers[index]);
- memcpy(state, &controllers[index].state, sizeof(XINPUT_STATE));
- return ERROR_SUCCESS;
return xinput_get_state(index, state); }
DWORD WINAPI XInputGetKeystroke(DWORD index, DWORD reserved, PXINPUT_KEYSTROKE keystroke)