Aric Stewart : hid: Implement HidP_GetButtonCaps.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 1 09:06:24 CDT 2015
Module: wine
Branch: master
Commit: b183dc3d6ed604f356a6fd468a356301455f6ff5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b183dc3d6ed604f356a6fd468a356301455f6ff5
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jun 30 07:39:50 2015 -0500
hid: Implement HidP_GetButtonCaps.
---
dlls/hid/hid.spec | 2 +-
dlls/hid/hidp.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
include/ddk/hidpi.h | 1 +
3 files changed, 60 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..47864fa 100644
--- a/dlls/hid/hidp.c
+++ b/dlls/hid/hidp.c
@@ -37,6 +37,64 @@
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
More information about the wine-cvs
mailing list