From b117f6548a3f3734b23f865f2e9aeceed27062ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 25 Aug 2021 18:08:31 +0200 Subject: [PATCH] hidclass.sys: Fix nary usage collections index ordering. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/hidparse.sys/main.c | 4 ++-- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dlls/hidparse.sys/main.c b/dlls/hidparse.sys/main.c index 185cefbb3e5..3a57c338165 100644 --- a/dlls/hidparse.sys/main.c +++ b/dlls/hidparse.sys/main.c @@ -354,14 +354,13 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY } value = state->values[type] + *value_idx; - state->items.start_index = 0; + state->items.start_index = usages_size; if (!(is_array = HID_VALUE_CAPS_IS_ARRAY( &state->items ))) state->items.report_count -= usages_size - 1; else state->items.start_bit -= state->items.report_count * state->items.bit_size; while (usages_size--) { if (!is_array) state->items.start_bit -= state->items.report_count * state->items.bit_size; - else state->items.start_index += 1; state->items.usage_page = state->usages_page[usages_size]; state->items.usage_min = state->usages_min[usages_size]; state->items.usage_max = state->usages_max[usages_size]; @@ -371,6 +370,7 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY *value++ = state->items; *value_idx += 1; if (!is_array) state->items.report_count = 1; + else state->items.start_index -= 1; } state->items.usage_page = usage_page; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 85380cd9df2..2f5c2cd81cc 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2340,10 +2340,8 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled status = HidP_SetUsages(HidP_Input, HID_USAGE_PAGE_KEYBOARD, 0, usages, &value, preparsed_data, report, caps.InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_SetUsages returned %#x\n", status); - todo_wine ok(report[caps.InputReportByteLength - 2] == 3, "unexpected usage index %d, expected 3\n", report[caps.InputReportByteLength - 2]); - todo_wine ok(report[caps.InputReportByteLength - 1] == 4, "unexpected usage index %d, expected 4\n", report[caps.InputReportByteLength - 1]); report[caps.InputReportByteLength - 2] = 0; @@ -2353,7 +2351,6 @@ static void test_hidp(HANDLE file, HANDLE async_file, int report_id, BOOL polled status = HidP_SetUsages(HidP_Input, HID_USAGE_PAGE_KEYBOARD, 0, usages, &value, preparsed_data, report, caps.InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_SetUsages returned %#x\n", status); - todo_wine ok(report[caps.InputReportByteLength - 2] == 1, "unexpected usage index %d, expected 1\n", report[caps.InputReportByteLength - 2]);