From 81bef14324be69be190ef3fcfe301a7063e39351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 29 Sep 2021 10:24:57 +0200 Subject: [PATCH] dinput: Improve filtering of HID device state input report. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we only read input object from the device state input report and only look for generic and button usage pages to find the report. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick_hid.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 29cb8990689..a20925b6176 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -937,6 +937,8 @@ static BOOL check_device_state_button( struct hid_joystick *impl, struct hid_cap struct parse_device_state_params *params = data; BYTE old_value, value; + if (instance->wReportId != impl->device_state_report_id) return DIENUM_CONTINUE; + value = params->buttons[instance->wUsage - 1]; old_value = params->old_state[instance->dwOfs]; impl->device_state[instance->dwOfs] = value; @@ -1008,6 +1010,8 @@ static BOOL read_device_state_value( struct hid_joystick *impl, struct hid_caps LONG old_value, value; NTSTATUS status; + if (instance->wReportId != impl->device_state_report_id) return DIENUM_CONTINUE; + extra = impl->input_extra_caps + (value_caps - impl->input_value_caps); status = HidP_GetUsageValue( HidP_Input, instance->wUsagePage, 0, instance->wUsage, &logical_value, impl->preparsed, report_buf, report_len ); @@ -1360,10 +1364,15 @@ static BOOL init_objects( struct hid_joystick *impl, struct hid_caps *caps, if (instance->dwType & DIDFT_AXIS) impl->dev_caps.dwAxes++; if (instance->dwType & DIDFT_POV) impl->dev_caps.dwPOVs++; - if (!impl->device_state_report_id) - impl->device_state_report_id = instance->wReportId; - else if (impl->device_state_report_id != instance->wReportId) - FIXME( "multiple device state reports found!\n" ); + if (instance->dwType & (DIDFT_BUTTON|DIDFT_AXIS|DIDFT_POV) && + (instance->wUsagePage == HID_USAGE_PAGE_GENERIC || + instance->wUsagePage == HID_USAGE_PAGE_BUTTON)) + { + if (!impl->device_state_report_id) + impl->device_state_report_id = instance->wReportId; + else if (impl->device_state_report_id != instance->wReportId) + FIXME( "multiple device state reports found!\n" ); + } return DIENUM_CONTINUE; }