hid: Rewrite HidP_MaxDataListLength using enum_value_caps.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-06-28 09:21:58 +02:00 committed by Alexandre Julliard
parent 28bbaf6707
commit 1c4e7a00a3
2 changed files with 16 additions and 17 deletions

View file

@ -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,

View file

@ -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);