Aric Stewart : hid: Implement HidP_GetScaledUsageValue.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 1 09:06:24 CDT 2015
Module: wine
Branch: master
Commit: 098efa1edc254916b7bda0fcd9a38162e5a7ad0e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=098efa1edc254916b7bda0fcd9a38162e5a7ad0e
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jun 30 07:40:41 2015 -0500
hid: Implement HidP_GetScaledUsageValue.
---
dlls/hid/hid.spec | 2 +-
dlls/hid/hidp.c | 65 ++++++++++++++++++++++++++++++++++++++++++++---------
include/ddk/hidpi.h | 1 +
3 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/dlls/hid/hid.spec b/dlls/hid/hid.spec
index 8772a35..c7b056d 100644
--- a/dlls/hid/hid.spec
+++ b/dlls/hid/hid.spec
@@ -23,7 +23,7 @@
@ stub HidP_GetData
@ stub HidP_GetExtendedAttributes
@ stub HidP_GetLinkCollectionNodes
-@ stub HidP_GetScaledUsageValue
+@ stdcall HidP_GetScaledUsageValue(long long long long ptr ptr ptr long)
@ stub HidP_GetSpecificButtonCaps
@ stub HidP_GetSpecificValueCaps
@ stdcall HidP_GetUsageValue(long long long long ptr ptr ptr long)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c
index d263880..3d7a12e 100644
--- a/dlls/hid/hidp.c
+++ b/dlls/hid/hidp.c
@@ -150,22 +150,20 @@ NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData,
return HIDP_STATUS_SUCCESS;
}
-
-NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection,
- USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData,
- PCHAR Report, ULONG ReportLength)
+static NTSTATUS find_value(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection,
+ USAGE Usage, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report,
+ WINE_HID_ELEMENT **element)
{
PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData;
WINE_HID_REPORT *report = NULL;
USHORT v_count = 0, r_count = 0;
int i;
- TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue,
- PreparsedData, Report, ReportLength);
+ TRACE("(%i, %x, %i, %i, %p, %p)\n", ReportType, UsagePage, LinkCollection, Usage,
+ PreparsedData, Report);
if (data->magic != HID_MAGIC)
return HIDP_STATUS_INVALID_PREPARSED_DATA;
-
switch(ReportType)
{
case HidP_Input:
@@ -206,15 +204,62 @@ NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage,
report->Elements[i].caps.value.UsagePage == UsagePage &&
report->Elements[i].caps.value.u.NotRange.Usage == Usage)
{
- return get_report_data((BYTE*)Report, ReportLength,
- report->Elements[i].valueStartBit,
- report->Elements[i].bitCount, UsageValue);
+ *element = &report->Elements[i];
+ return HIDP_STATUS_SUCCESS;
}
}
return HIDP_STATUS_USAGE_NOT_FOUND;
}
+NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage,
+ USHORT LinkCollection, USAGE Usage, PLONG UsageValue,
+ PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength)
+{
+ NTSTATUS rc;
+ WINE_HID_ELEMENT *element;
+ TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue,
+ PreparsedData, Report, ReportLength);
+
+ rc = find_value(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, &element);
+
+ if (rc == HIDP_STATUS_SUCCESS)
+ {
+ ULONG rawValue;
+ rc = get_report_data((BYTE*)Report, ReportLength,
+ element->valueStartBit, element->bitCount, &rawValue);
+ if (rc != HIDP_STATUS_SUCCESS)
+ return rc;
+ if (element->caps.value.BitSize == 16)
+ rawValue = (short)rawValue;
+ *UsageValue = rawValue;
+ }
+
+ return rc;
+}
+
+
+NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection,
+ USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData,
+ PCHAR Report, ULONG ReportLength)
+{
+ WINE_HID_ELEMENT *element;
+ NTSTATUS rc;
+
+ TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue,
+ PreparsedData, Report, ReportLength);
+
+ rc = find_value(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, &element);
+
+ if (rc == HIDP_STATUS_SUCCESS)
+ {
+ return get_report_data((BYTE*)Report, ReportLength,
+ element->valueStartBit, element->bitCount, UsageValue);
+ }
+
+ return rc;
+}
+
NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection,
PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData,
diff --git a/include/ddk/hidpi.h b/include/ddk/hidpi.h
index 40821de..527a966 100644
--- a/include/ddk/hidpi.h
+++ b/include/ddk/hidpi.h
@@ -143,6 +143,7 @@ NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage,
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);
ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, PHIDP_PREPARSED_DATA PreparsedData);
+NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PLONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
#ifndef FACILITY_HID_ERROR_CODE
#define FACILITY_HID_ERROR_CODE 0x11
More information about the wine-cvs
mailing list