Rémi Bernon : dinput: Reset button state for each report read.

Alexandre Julliard julliard at winehq.org
Thu Jan 13 16:26:40 CST 2022


Module: wine
Branch: master
Commit: 3ad4f9f356b9f59731bf7e5c8abbdcee145994ba
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3ad4f9f356b9f59731bf7e5c8abbdcee145994ba

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Jan 13 14:14:55 2022 +0100

dinput: Reset button state for each report read.

As we loop on ReadFile success we may read multiple reports at once, but
we never reset buttons in the enumeration params. The pressed buttons
are returned by HidP_GetUsagesEx and any other button must be cleared.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52387
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/joystick_hid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 2e3efd2ee8a..29d1de8b98e 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -1208,8 +1208,8 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface )
     struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
     ULONG i, index, count, report_len = impl->caps.InputReportByteLength;
     DIDATAFORMAT *format = impl->base.device_format;
-    struct parse_device_state_params params = {{0}};
     char *report_buf = impl->input_report_buf;
+    struct parse_device_state_params params;
     struct hid_joystick_effect *effect;
     DWORD device_state, effect_state;
     USAGE_AND_PAGE *usages;
@@ -1247,6 +1247,7 @@ static HRESULT hid_joystick_read( IDirectInputDevice8W *iface )
             params.time = GetCurrentTime();
             params.seq = impl->base.dinput->evsequence++;
             memcpy( params.old_state, impl->base.device_state, format->dwDataSize );
+            memset( params.buttons, 0, sizeof(params.buttons) );
             memset( impl->base.device_state, 0, format->dwDataSize );
 
             while (count--)




More information about the wine-cvs mailing list