Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 32 +++++++++++++++--------------- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 1 - 2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 6261c3c2f68..afd69281f0d 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -679,24 +679,24 @@ NTSTATUS WINAPI HidP_GetUsagesEx( HIDP_REPORT_TYPE report_type, USHORT collectio return status; }
-ULONG WINAPI HidP_MaxDataListLength(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData) +static NTSTATUS count_data( const struct hid_value_caps *caps, void *user ) { - WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA *)PreparsedData; - TRACE("(%i, %p)\n", ReportType, PreparsedData); - if (data->magic != HID_MAGIC) - return 0; + if (caps->is_range || HID_VALUE_CAPS_IS_BUTTON( caps )) *(ULONG *)user += caps->report_count; + else *(ULONG *)user += 1; + return HIDP_STATUS_SUCCESS; +}
- switch(ReportType) - { - case HidP_Input: - return data->caps.NumberInputDataIndices; - case HidP_Output: - return data->caps.NumberOutputDataIndices; - case HidP_Feature: - return data->caps.NumberFeatureDataIndices; - default: - return 0; - } +ULONG WINAPI HidP_MaxDataListLength( HIDP_REPORT_TYPE report_type, PHIDP_PREPARSED_DATA preparsed_data ) +{ + WINE_HIDP_PREPARSED_DATA *preparsed = (WINE_HIDP_PREPARSED_DATA *)preparsed_data; + struct caps_filter filter = {}; + USHORT limit = -1; + ULONG count = 0; + + TRACE( "report_type %d, preparsed_data %p.\n", report_type, preparsed_data ); + + enum_value_caps( preparsed, report_type, 0, &filter, count_data, &count, &limit ); + return count; }
NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, ULONG *DataLength, diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 753957a8ac6..101366bf50b 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2229,7 +2229,6 @@ static void test_hidp(HANDLE file, int report_id) value = HidP_MaxDataListLength(HidP_Feature + 1, preparsed_data); ok(value == 0, "HidP_MaxDataListLength(HidP_Feature + 1) returned %d, expected %d\n", value, 0); value = HidP_MaxDataListLength(HidP_Input, preparsed_data); - todo_wine ok(value == 50, "HidP_MaxDataListLength(HidP_Input) returned %d, expected %d\n", value, 50); value = HidP_MaxDataListLength(HidP_Output, preparsed_data); ok(value == 0, "HidP_MaxDataListLength(HidP_Output) returned %d, expected %d\n", value, 0);