From: Aric Stewart Subject: [9/14]hid: Implement HidP_InitializeReportForID Message-Id: <558C1B32.7000608@codeweavers.com> Date: Thu, 25 Jun 2015 10:16:02 -0500 --- dlls/hid/hid.spec | 2 +- dlls/hid/hidp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/ddk/hidpi.h | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/dlls/hid/hid.spec b/dlls/hid/hid.spec index b8b4e7f..5659a88 100644 --- a/dlls/hid/hid.spec +++ b/dlls/hid/hid.spec @@ -31,7 +31,7 @@ @ stdcall HidP_GetUsages(long long long ptr ptr ptr ptr long) @ stub HidP_GetUsagesEx @ stdcall HidP_GetValueCaps(long ptr ptr ptr) -@ stub HidP_InitializeReportForID +@ stdcall HidP_InitializeReportForID(long long ptr ptr long) @ stub HidP_MaxDataListLength @ stub HidP_MaxUsageListLength @ stub HidP_SetData diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index b06625c..4bf63e7 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -350,3 +350,64 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS *ValueCapsLength = v_count; return HIDP_STATUS_SUCCESS; } + +NTSTATUS WINAPI HidP_InitializeReportForID(HIDP_REPORT_TYPE ReportType, UCHAR ReportID, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength) +{ + int size; + PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; + WINE_HID_REPORT *report = NULL; + BOOL found=FALSE; + int r_count; + int i; + + TRACE("(%i, %i, %p, %p, %i)\n",ReportType, ReportID, PreparsedData, Report, ReportLength); + + if (data->magic != HID_MAGIC) + return HIDP_STATUS_INVALID_PREPARSED_DATA; + + switch(ReportType) + { + case HidP_Input: + size = data->caps.InputReportByteLength; + report = HID_INPUT_REPORTS(data); + r_count = data->dwInputReportCount; + break; + case HidP_Output: + size = data->caps.OutputReportByteLength; + report = HID_OUTPUT_REPORTS(data); + r_count = data->dwOutputReportCount; + break; + case HidP_Feature: + size = data->caps.FeatureReportByteLength; + report = HID_FEATURE_REPORTS(data); + r_count = data->dwFeatureReportCount; + break; + default: + return HIDP_STATUS_INVALID_REPORT_TYPE; + } + + if (!r_count || !size || !report) + return HIDP_STATUS_REPORT_DOES_NOT_EXIST; + + if (size != ReportLength) + return HIDP_STATUS_INVALID_REPORT_LENGTH; + + ZeroMemory(Report, size); + + for (i = 0; i < r_count; i++) + { + if (report->reportID == ReportID) + { + found = TRUE; + if (report->reportID) + Report[0] = ReportID; + /* TODO: Handle null and default values */ + } + report = HID_NEXT_REPORT(data, report); + } + + if (!found) + return HIDP_STATUS_REPORT_DOES_NOT_EXIST; + + return HIDP_STATUS_SUCCESS; +} diff --git a/include/ddk/hidpi.h b/include/ddk/hidpi.h index aa730d5..e31aebb 100644 --- a/include/ddk/hidpi.h +++ b/include/ddk/hidpi.h @@ -141,6 +141,7 @@ NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capa NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); 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_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData); +NTSTATUS WINAPI HidP_InitializeReportForID(HIDP_REPORT_TYPE ReportType, UCHAR ReportID, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength); #ifndef FACILITY_HID_ERROR_CODE