From: Aric Stewart Subject: [2/11]hid: Implement HidP_GetButtonCaps Message-Id: <55928E16.9090307@codeweavers.com> Date: Tue, 30 Jun 2015 07:39:50 -0500 --- dlls/hid/hid.spec | 2 +- dlls/hid/hidp.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/ddk/hidpi.h | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/dlls/hid/hid.spec b/dlls/hid/hid.spec index 9d7899f..4bd9f4e 100644 --- a/dlls/hid/hid.spec +++ b/dlls/hid/hid.spec @@ -18,7 +18,7 @@ @ stdcall HidD_SetFeature(long ptr long) @ stub HidD_SetNumInputBuffers @ stub HidD_SetOutputReport -@ stub HidP_GetButtonCaps +@ stdcall HidP_GetButtonCaps(long ptr ptr ptr) @ stdcall HidP_GetCaps(ptr ptr) @ stub HidP_GetData @ stub HidP_GetExtendedAttributes diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index a6f462c..ce92d3a 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -37,6 +37,63 @@ WINE_DEFAULT_DEBUG_CHANNEL(hidp); +NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData) +{ + PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; + WINE_HID_REPORT *report = NULL; + USHORT b_count = 0, r_count = 0; + int i,j,u; + + TRACE("(%i, %p, %p, %p)\n",ReportType, ButtonCaps, ButtonCapsLength, PreparsedData); + + if (data->magic != HID_MAGIC) + return HIDP_STATUS_INVALID_PREPARSED_DATA; + + switch(ReportType) + { + case HidP_Input: + b_count = data->caps.NumberInputButtonCaps; + r_count = data->dwInputReportCount; + report = HID_INPUT_REPORTS(data); + break; + case HidP_Output: + b_count = data->caps.NumberOutputButtonCaps; + r_count = data->dwOutputReportCount; + report = HID_OUTPUT_REPORTS(data); + break; + case HidP_Feature: + b_count = data->caps.NumberFeatureButtonCaps; + r_count = data->dwFeatureReportCount; + report = HID_FEATURE_REPORTS(data); + break; + default: + return HIDP_STATUS_INVALID_REPORT_TYPE; + } + + if (!r_count || !b_count || !report) + { + *ButtonCapsLength = 0; + return HIDP_STATUS_SUCCESS; + } + + b_count = min(b_count, *ButtonCapsLength); + + u = 0; + for (j = 0; j < r_count && u < b_count; j++) + { + for (i = 0; i < report->elementCount && u < b_count; i++) + { + if (report->Elements[i].ElementType == ButtonElement) + ButtonCaps[u++] = report->Elements[i].caps.button; + } + report = HID_NEXT_REPORT(data, report); + } + + *ButtonCapsLength = b_count; + return HIDP_STATUS_SUCCESS; +} + + NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities) { diff --git a/include/ddk/hidpi.h b/include/ddk/hidpi.h index 32f6625..729f2d9 100644 --- a/include/ddk/hidpi.h +++ b/include/ddk/hidpi.h @@ -136,6 +136,7 @@ typedef struct _HIDP_CAPS USHORT NumberFeatureDataIndices; } HIDP_CAPS, *PHIDP_CAPS; +NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData); NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities); #ifndef FACILITY_HID_ERROR_CODE