Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 58 +++++++----------------------- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 4 --- 2 files changed, 12 insertions(+), 50 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index c11a5d66985..76b9ff5ee2c 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -524,56 +524,22 @@ NTSTATUS WINAPI HidP_InitializeReportForID( HIDP_REPORT_TYPE report_type, UCHAR return HIDP_STATUS_SUCCESS; }
-ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, PHIDP_PREPARSED_DATA PreparsedData) +static NTSTATUS get_usage_list_length( const struct hid_value_caps *caps, void *data ) { - PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); - WINE_HID_REPORT *report = NULL; - int r_count; - int i; - int count = 0; - - TRACE("(%i, %x, %p)\n", ReportType, UsagePage, PreparsedData); - - if (data->magic != HID_MAGIC) - return 0; - - switch(ReportType) - { - case HidP_Input: - report = HID_INPUT_REPORTS(data); - break; - case HidP_Output: - report = HID_OUTPUT_REPORTS(data); - break; - case HidP_Feature: - report = HID_FEATURE_REPORTS(data); - break; - default: - return HIDP_STATUS_INVALID_REPORT_TYPE; - } - r_count = data->reportCount[ReportType]; + *(ULONG *)data += caps->report_count; + return HIDP_STATUS_SUCCESS; +}
+ULONG WINAPI HidP_MaxUsageListLength( HIDP_REPORT_TYPE report_type, USAGE usage_page, PHIDP_PREPARSED_DATA preparsed_data ) +{ + WINE_HIDP_PREPARSED_DATA *preparsed = (WINE_HIDP_PREPARSED_DATA *)preparsed_data; + struct caps_filter filter = {.buttons = TRUE, .usage_page = usage_page}; + USHORT limit = -1; + ULONG count = 0;
- if (!r_count) - return 0; + TRACE( "report_type %d, usage_page %x, preparsed_data %p.\n", report_type, usage_page, preparsed_data );
- for (i = 0; i < r_count; i++) - { - int j; - for (j = 0; j < report[i].elementCount; j++) - { - if (elems[report[i].elementIdx + j].caps.BitSize == 1 && - (UsagePage == 0 || elems[report[i].elementIdx + j].caps.UsagePage == UsagePage)) - { - if (elems[report[i].elementIdx + j].caps.IsRange) - count += (elems[report[i].elementIdx + j].caps.Range.UsageMax - - elems[report[i].elementIdx + j].caps.Range.UsageMin) + 1; - else - count++; - } - } - } + enum_value_caps( preparsed, report_type, &filter, get_usage_list_length, &count, &limit ); return count; }
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 3ce750728ec..8777880fd9d 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2140,18 +2140,14 @@ static void test_hidp(HANDLE file, int report_id) ok(value == 0, "got value %x, expected %#x\n", value, 0);
value = HidP_MaxUsageListLength(HidP_Feature + 1, 0, preparsed_data); - todo_wine ok(value == 0, "HidP_MaxUsageListLength(HidP_Feature + 1, 0) returned %d, expected %d\n", value, 0); value = HidP_MaxUsageListLength(HidP_Input, 0, preparsed_data); - todo_wine ok(value == 42, "HidP_MaxUsageListLength(HidP_Input, 0) returned %d, expected %d\n", value, 42); value = HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_BUTTON, preparsed_data); - todo_wine ok(value == 32, "HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_BUTTON) returned %d, expected %d\n", value, 32); value = HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_LED, preparsed_data); ok(value == 8, "HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_LED) returned %d, expected %d\n", value, 8); value = HidP_MaxUsageListLength(HidP_Feature, HID_USAGE_PAGE_BUTTON, preparsed_data); - todo_wine ok(value == 8, "HidP_MaxUsageListLength(HidP_Feature, HID_USAGE_PAGE_BUTTON) returned %d, expected %d\n", value, 8); value = HidP_MaxUsageListLength(HidP_Feature, HID_USAGE_PAGE_LED, preparsed_data); ok(value == 0, "HidP_MaxUsageListLength(HidP_Feature, HID_USAGE_PAGE_LED) returned %d, expected %d\n", value, 0);