Commit cc00075a authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

hid: Implement HidP_GetUsagesEx.

parent fbd3525e
......@@ -29,7 +29,7 @@
@ stdcall HidP_GetUsageValue(long long long long ptr ptr ptr long)
@ stub HidP_GetUsageValueArray
@ stdcall HidP_GetUsages(long long long ptr ptr ptr ptr long)
@ stub HidP_GetUsagesEx
@ stdcall HidP_GetUsagesEx(long long ptr ptr ptr ptr long)
@ stdcall HidP_GetValueCaps(long ptr ptr ptr)
@ stdcall HidP_InitializeReportForID(long long ptr ptr long)
@ stub HidP_MaxDataListLength
......
......@@ -676,3 +676,90 @@ NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType,
return HIDP_STATUS_SUCCESS;
}
NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollection, USAGE_AND_PAGE *ButtonList,
ULONG *UsageLength, PHIDP_PREPARSED_DATA PreparsedData, CHAR *Report, ULONG ReportLength)
{
WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData;
WINE_HID_REPORT *report = NULL;
USHORT b_count = 0, r_count = 0;
int i,uCount = 0;
NTSTATUS rc;
TRACE("(%i, %i, %p, %p(%i), %p, %p, %i)\n", ReportType, LinkCollection, ButtonList,
UsageLength, *UsageLength, PreparsedData, Report, ReportLength);
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)
return HIDP_STATUS_USAGE_NOT_FOUND;
for (i = 0; i < r_count; i++)
{
if (!report->reportID || report->reportID == Report[0])
break;
report = HID_NEXT_REPORT(data, report);
}
if (i == r_count)
return HIDP_STATUS_REPORT_DOES_NOT_EXIST;
for (i = 0; i < report->elementCount; i++)
{
if (report->Elements[i].ElementType == ButtonElement)
{
int k;
WINE_HID_ELEMENT *element = &report->Elements[i];
for (k=0; k < element->bitCount; k++)
{
UINT v = 0;
NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength,
element->valueStartBit + k, 1, &v);
if (rc != HIDP_STATUS_SUCCESS)
return rc;
if (v)
{
if (uCount < *UsageLength)
{
ButtonList[uCount].Usage = element->caps.button.u.Range.UsageMin + k;
ButtonList[uCount].UsagePage = element->caps.button.UsagePage;
}
uCount++;
}
}
}
}
TRACE("Returning %i usages\n", uCount);
if (*UsageLength < uCount)
rc = HIDP_STATUS_BUFFER_TOO_SMALL;
else
rc = HIDP_STATUS_SUCCESS;
*UsageLength = uCount;
return rc;
}
......@@ -161,6 +161,11 @@ typedef struct _HIDP_KEYBOARD_MODIFIER_STATE {
} DUMMYUNIONNAME;
} HIDP_KEYBOARD_MODIFIER_STATE, *PHIDP_KEYBOARD_MODIFIER_STATE;
typedef struct _USAGE_AND_PAGE {
USAGE Usage;
USAGE UsagePage;
} USAGE_AND_PAGE, *PUSAGE_AND_PAGE;
typedef BOOLEAN (NTAPI *PHIDP_INSERT_SCANCODES) (VOID *Context, CHAR *NewScanCodes, ULONG Length);
......@@ -175,6 +180,7 @@ NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE Usag
NTSTATUS WINAPI HidP_TranslateUsagesToI8042ScanCodes(USAGE *ChangedUsageList, ULONG UsageListLength, HIDP_KEYBOARD_DIRECTION KeyAction, HIDP_KEYBOARD_MODIFIER_STATE *ModifierState, PHIDP_INSERT_SCANCODES InsertCodesProcedure, VOID *InsertCodesContext);
NTSTATUS WINAPI HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, HIDP_BUTTON_CAPS *ButtonCaps, USHORT *ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, HIDP_VALUE_CAPS *ValueCaps, USHORT *ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollection, USAGE_AND_PAGE *ButtonList, ULONG *UsageLength, PHIDP_PREPARSED_DATA PreparsedData, CHAR *Report, ULONG ReportLength);
#ifndef FACILITY_HID_ERROR_CODE
#define FACILITY_HID_ERROR_CODE 0x11
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment