Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 26 +++++++++++--------------- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 5 +---- 2 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 24b11d519e2..948f0c7c4dc 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -347,25 +347,21 @@ static NTSTATUS get_usage_value( const struct hid_value_caps *caps, void *user ) return HIDP_STATUS_NULL; }
-NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, - USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, - PCHAR Report, ULONG ReportLength) +NTSTATUS WINAPI HidP_GetUsageValue( HIDP_REPORT_TYPE report_type, USAGE usage_page, USHORT collection, USAGE usage, + ULONG *value, PHIDP_PREPARSED_DATA preparsed_data, char *report_buf, ULONG report_len ) { - WINE_HID_ELEMENT element; - NTSTATUS rc; - - TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, - PreparsedData, Report, ReportLength); + struct usage_value_params params = {.value_buf = value, .value_len = sizeof(*value), .report_buf = report_buf}; + WINE_HIDP_PREPARSED_DATA *preparsed = (WINE_HIDP_PREPARSED_DATA *)preparsed_data; + struct caps_filter filter = {.values = TRUE, .usage_page = usage_page, .collection = collection, .usage = usage}; + USHORT count = 1;
- rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, 0, &element); + TRACE( "report_type %d, usage_page %x, collection %d, usage %x, value %p, preparsed_data %p, report_buf %p, report_len %u.\n", + report_type, usage_page, collection, usage, value, preparsed_data, report_buf, report_len );
- if (rc == HIDP_STATUS_SUCCESS) - { - return get_report_data((BYTE*)Report, ReportLength, - element.valueStartBit, element.bitCount, UsageValue); - } + if (!report_len) return HIDP_STATUS_INVALID_REPORT_LENGTH;
- return rc; + filter.report_id = report_buf[0]; + return enum_value_caps( preparsed, report_type, report_len, &filter, get_usage_value, ¶ms, &count ); }
NTSTATUS WINAPI HidP_GetUsageValueArray( HIDP_REPORT_TYPE report_type, USAGE usage_page, USHORT collection, diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index c0421c23fbc..b29660d4773 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2330,12 +2330,11 @@ static void test_hidp(HANDLE file, int report_id) ok(status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetUsageValue returned %#x\n", status); status = HidP_GetUsageValue(HidP_Feature, HID_USAGE_PAGE_ORDINAL, waveform_list, 3, &value, preparsed_data, report, caps.FeatureReportByteLength + 1); - todo_wine ok(status == HIDP_STATUS_INVALID_REPORT_LENGTH, "HidP_GetUsageValue returned %#x\n", status); report[0] = 1 - report_id; status = HidP_GetUsageValue(HidP_Feature, HID_USAGE_PAGE_ORDINAL, waveform_list, 3, &value, preparsed_data, report, caps.FeatureReportByteLength); - todo_wine + todo_wine_if(!report_id) ok(status == (report_id ? HIDP_STATUS_SUCCESS : HIDP_STATUS_INCOMPATIBLE_REPORT_ID), "HidP_GetUsageValue returned %#x\n", status); report[0] = 2; @@ -2346,14 +2345,12 @@ static void test_hidp(HANDLE file, int report_id) report[0] = report_id; status = HidP_GetUsageValue(HidP_Feature, HID_USAGE_PAGE_ORDINAL, 0xdead, 3, &value, preparsed_data, report, caps.FeatureReportByteLength); - todo_wine ok(status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetUsageValue returned %#x\n", status);
value = 0xdeadbeef; status = HidP_GetUsageValue(HidP_Feature, HID_USAGE_PAGE_ORDINAL, waveform_list, 3, &value, preparsed_data, report, caps.FeatureReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_GetUsageValue returned %#x\n", status); - todo_wine ok(value == HID_USAGE_HAPTICS_WAVEFORM_RUMBLE, "got value %x, expected %#x\n", value, HID_USAGE_HAPTICS_WAVEFORM_RUMBLE);