[HIDPARSE]

- Start support for multi top level hid collections
- Not yet full implemented
- Required for proper usb composite support

svn path=/branches/usb-bringup-trunk/; revision=55332
This commit is contained in:
Johannes Anderwald 2012-01-30 19:29:26 +00:00
parent c9a760c226
commit a7eba59665
5 changed files with 405 additions and 361 deletions

View file

@ -95,89 +95,73 @@ HidParser_GetCollection(
} }
PHID_REPORT PHID_REPORT
HidParser_GetReportByType( HidParser_GetReportInCollection(
IN PHID_PARSER Parser, PHID_COLLECTION Collection,
IN ULONG ReportType) IN UCHAR ReportType)
{ {
PHID_PARSER_CONTEXT ParserContext;
ULONG Index; ULONG Index;
PHID_REPORT Report;
// //
// get parser context // search in local array
// //
ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; for(Index = 0; Index < Collection->ReportCount; Index++)
//
// sanity checks
//
ASSERT(ParserContext);
//
// FIXME support multiple top collecions
//
ASSERT(ParserContext->RootCollection->NodeCount == 1);
for(Index = 0; Index < ParserContext->ReportCount; Index++)
{ {
// if (Collection->Reports[Index]->Type == ReportType)
// check if the report type match
//
if (ParserContext->Reports[Index]->Type == ReportType)
{ {
// //
// found report // found report
// //
return ParserContext->Reports[Index]; return Collection->Reports[Index];
} }
} }
// //
// report not found // search in local array
//
for(Index = 0; Index < Collection->NodeCount; Index++)
{
Report = HidParser_GetReportInCollection(Collection->Nodes[Index], ReportType);
if (Report)
{
//
// found report
//
return Report;
}
}
//
// not found
// //
return NULL; return NULL;
} }
PHID_REPORT
ULONG HidParser_GetReportByType(
HidParser_NumberOfReports(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG ReportType) IN ULONG CollectionIndex,
IN UCHAR ReportType)
{ {
PHID_PARSER_CONTEXT ParserContext; PHID_COLLECTION Collection;
ULONG Index;
ULONG ReportCount = 0;
// //
// get parser context // find collection
// //
ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; Collection = HidParser_GetCollection(Parser, CollectionIndex);
if (!Collection)
//
// sanity checks
//
ASSERT(ParserContext);
//
// FIXME support multiple top collecions
//
ASSERT(ParserContext->RootCollection->NodeCount == 1);
for(Index = 0; Index < ParserContext->ReportCount; Index++)
{ {
// //
// check if the report type match // no such collection
// //
if (ParserContext->Reports[Index]->Type == ReportType) ASSERT(FALSE);
{ return NULL;
//
// found report
//
ReportCount++;
}
} }
// //
// done // search report
// //
return ReportCount; return HidParser_GetReportInCollection(Collection, ReportType);
} }
HIDPARSER_STATUS HIDPARSER_STATUS
@ -212,6 +196,7 @@ HidParser_GetCollectionUsagePage(
ULONG ULONG
HidParser_GetReportLength( HidParser_GetReportLength(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType) IN ULONG ReportType)
{ {
PHID_PARSER_CONTEXT ParserContext; PHID_PARSER_CONTEXT ParserContext;
@ -236,7 +221,7 @@ HidParser_GetReportLength(
// //
// get first report // get first report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -289,6 +274,7 @@ HidParser_IsReportIDUsed(
ULONG ULONG
HidParser_GetReportItemCountFromReportType( HidParser_GetReportItemCountFromReportType(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType) IN ULONG ReportType)
{ {
PHID_PARSER_CONTEXT ParserContext; PHID_PARSER_CONTEXT ParserContext;
@ -312,7 +298,7 @@ HidParser_GetReportItemCountFromReportType(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -331,6 +317,7 @@ HidParser_GetReportItemCountFromReportType(
ULONG ULONG
HidParser_GetReportItemTypeCountFromReportType( HidParser_GetReportItemTypeCountFromReportType(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType, IN ULONG ReportType,
IN ULONG bData) IN ULONG bData)
{ {
@ -357,7 +344,7 @@ HidParser_GetReportItemTypeCountFromReportType(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -398,7 +385,8 @@ HidParser_GetReportItemTypeCountFromReportType(
ULONG ULONG
HidParser_GetContextSize( HidParser_GetContextSize(
IN PHID_PARSER Parser) IN PHID_PARSER Parser,
IN ULONG CollectionIndex)
{ {
// //
// FIXME the context must contain all parsed info // FIXME the context must contain all parsed info
@ -540,6 +528,7 @@ HidParser_GetTotalCollectionCount(
ULONG ULONG
HidParser_GetMaxUsageListLengthWithReportAndPage( HidParser_GetMaxUsageListLengthWithReportAndPage(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage OPTIONAL) IN USAGE UsagePage OPTIONAL)
{ {
@ -567,7 +556,7 @@ HidParser_GetMaxUsageListLengthWithReportAndPage(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -600,6 +589,7 @@ HidParser_GetMaxUsageListLengthWithReportAndPage(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetSpecificValueCapsWithReport( HidParser_GetSpecificValueCapsWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType, IN ULONG ReportType,
IN USHORT UsagePage, IN USHORT UsagePage,
IN USHORT Usage, IN USHORT Usage,
@ -631,7 +621,7 @@ HidParser_GetSpecificValueCapsWithReport(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -705,6 +695,7 @@ HidParser_GetSpecificValueCapsWithReport(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetUsagesWithReport( HidParser_GetUsagesWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage, IN USAGE UsagePage,
OUT USAGE *UsageList, OUT USAGE *UsageList,
@ -739,7 +730,7 @@ HidParser_GetUsagesWithReport(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -852,6 +843,7 @@ HidParser_GetUsagesWithReport(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetScaledUsageValueWithReport( HidParser_GetScaledUsageValueWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage, IN USAGE UsagePage,
IN USAGE Usage, IN USAGE Usage,
@ -884,7 +876,7 @@ HidParser_GetScaledUsageValueWithReport(
// //
// get report // get report
// //
Report = HidParser_GetReportByType(Parser, ReportType); Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType);
if (!Report) if (!Report)
{ {
// //
@ -1042,6 +1034,7 @@ HidParser_DispatchKey(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_TranslateUsage( HidParser_TranslateUsage(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN USAGE Usage, IN USAGE Usage,
IN HIDP_KEYBOARD_DIRECTION KeyAction, IN HIDP_KEYBOARD_DIRECTION KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
@ -1073,3 +1066,15 @@ HidParser_TranslateUsage(
// //
return HIDPARSER_STATUS_SUCCESS; return HIDPARSER_STATUS_SUCCESS;
} }
ULONG
HidParser_GetCollectionNumberFromParserContext(
IN PHID_PARSER Parser)
{
PHID_PARSER_CONTEXT Context = (PHID_PARSER_CONTEXT)Parser->ParserContext;
//
// get parser context
//
return Context->CollectionIndex;
}

View file

@ -69,16 +69,12 @@ HidParser_GetCollectionDescription(
// get collection count // get collection count
// //
CollectionCount = HidParser_NumberOfTopCollections(Parser); CollectionCount = HidParser_NumberOfTopCollections(Parser);
//
// FIXME: only one top level collection is supported
//
ASSERT(CollectionCount <= 1);
if (CollectionCount == 0) if (CollectionCount == 0)
{ {
// //
// no top level collections found // no top level collections found
// //
ASSERT(FALSE);
return STATUS_NO_DATA_DETECTED; return STATUS_NO_DATA_DETECTED;
} }
@ -119,9 +115,9 @@ HidParser_GetCollectionDescription(
// //
DeviceDescription->ReportIDs[Index].CollectionNumber = Index + 1; DeviceDescription->ReportIDs[Index].CollectionNumber = Index + 1;
DeviceDescription->ReportIDs[Index].ReportID = Index; //FIXME DeviceDescription->ReportIDs[Index].ReportID = Index; //FIXME
DeviceDescription->ReportIDs[Index].InputLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_INPUT); DeviceDescription->ReportIDs[Index].InputLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_INPUT);
DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_OUTPUT); DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_OUTPUT);
DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_FEATURE); DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_FEATURE);
// //
// init collection description // init collection description
@ -143,7 +139,7 @@ HidParser_GetCollectionDescription(
// //
// set preparsed data length // set preparsed data length
// //
DeviceDescription->CollectionDesc[Index].PreparsedDataLength = HidParser_GetContextSize(Parser); DeviceDescription->CollectionDesc[Index].PreparsedDataLength = HidParser_GetContextSize(Parser, Index);
DeviceDescription->CollectionDesc[Index].PreparsedData = Parser->Alloc(DeviceDescription->CollectionDesc[Index].PreparsedDataLength); DeviceDescription->CollectionDesc[Index].PreparsedData = Parser->Alloc(DeviceDescription->CollectionDesc[Index].PreparsedDataLength);
if (!DeviceDescription->CollectionDesc[Index].PreparsedData) if (!DeviceDescription->CollectionDesc[Index].PreparsedData)
{ {
@ -209,23 +205,24 @@ HidParser_GetCaps(
OUT PHIDP_CAPS Capabilities) OUT PHIDP_CAPS Capabilities)
{ {
ULONG CollectionNumber; ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
// //
// zero capabilities // zero capabilities
// //
Parser->Zero(Capabilities, sizeof(HIDP_CAPS)); Parser->Zero(Capabilities, sizeof(HIDP_CAPS));
//
// FIXME support multiple top level collections
//
CollectionNumber = 0;
// //
// init capabilities // init capabilities
// //
HidParser_GetCollectionUsagePage(Parser, CollectionNumber, &Capabilities->Usage, &Capabilities->UsagePage); HidParser_GetCollectionUsagePage(Parser, CollectionNumber, &Capabilities->Usage, &Capabilities->UsagePage);
Capabilities->InputReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_INPUT); Capabilities->InputReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT);
Capabilities->OutputReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_OUTPUT); Capabilities->OutputReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT);
Capabilities->FeatureReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_FEATURE); Capabilities->FeatureReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE);
// //
// always pre-prend report id // always pre-prend report id
@ -237,29 +234,29 @@ HidParser_GetCaps(
// //
// get number of link collection nodes // get number of link collection nodes
// //
Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(Parser); Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(Parser, CollectionNumber);
// //
// get data indices // get data indices
// //
Capabilities->NumberInputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_INPUT, TRUE); Capabilities->NumberInputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, TRUE);
Capabilities->NumberOutputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT, TRUE); Capabilities->NumberOutputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, TRUE);
Capabilities->NumberFeatureDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE, TRUE); Capabilities->NumberFeatureDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, TRUE);
// //
// get value caps // get value caps
// //
Capabilities->NumberInputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_INPUT, FALSE); Capabilities->NumberInputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, FALSE);
Capabilities->NumberOutputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT, FALSE); Capabilities->NumberOutputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, FALSE);
Capabilities->NumberFeatureValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE, FALSE); Capabilities->NumberFeatureValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, FALSE);
// //
// get button caps // get button caps
// //
Capabilities->NumberInputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_INPUT); Capabilities->NumberInputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT);
Capabilities->NumberOutputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT); Capabilities->NumberOutputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT);
Capabilities->NumberFeatureButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE); Capabilities->NumberFeatureButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE);
// //
// done // done
@ -275,6 +272,14 @@ HidParser_MaxUsageListLength(
IN HIDP_REPORT_TYPE ReportType, IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage OPTIONAL) IN USAGE UsagePage OPTIONAL)
{ {
ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
// //
// FIXME test what should be returned when usage page is not defined // FIXME test what should be returned when usage page is not defined
// //
@ -296,21 +301,21 @@ HidParser_MaxUsageListLength(
// //
// input report // input report
// //
return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_INPUT, UsagePage); return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, UsagePage);
} }
else if (ReportType == HidP_Output) else if (ReportType == HidP_Output)
{ {
// //
// input report // input report
// //
return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_OUTPUT, UsagePage); return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, UsagePage);
} }
else if (ReportType == HidP_Feature) else if (ReportType == HidP_Feature)
{ {
// //
// input report // input report
// //
return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_FEATURE, UsagePage); return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, UsagePage);
} }
else else
{ {
@ -348,6 +353,14 @@ HidParser_GetSpecificValueCaps(
IN OUT PULONG ValueCapsLength) IN OUT PULONG ValueCapsLength)
{ {
HIDPARSER_STATUS ParserStatus; HIDPARSER_STATUS ParserStatus;
ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
// //
// FIXME: implement searching in specific collection // FIXME: implement searching in specific collection
@ -359,21 +372,21 @@ HidParser_GetSpecificValueCaps(
// //
// input report // input report
// //
ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, Usage, ValueCaps, ValueCapsLength); ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, UsagePage, Usage, ValueCaps, ValueCapsLength);
} }
else if (ReportType == HidP_Output) else if (ReportType == HidP_Output)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, ValueCaps, ValueCapsLength); ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, ValueCaps, ValueCapsLength);
} }
else if (ReportType == HidP_Feature) else if (ReportType == HidP_Feature)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, ValueCaps, ValueCapsLength); ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, ValueCaps, ValueCapsLength);
} }
else else
{ {
@ -541,6 +554,12 @@ HidParser_GetUsages(
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
HIDPARSER_STATUS ParserStatus; HIDPARSER_STATUS ParserStatus;
ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
// //
// FIXME: implement searching in specific collection // FIXME: implement searching in specific collection
@ -552,21 +571,21 @@ HidParser_GetUsages(
// //
// input report // input report
// //
ParserStatus = HidParser_GetUsagesWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, UsageList, UsageLength, Report, ReportLength); ParserStatus = HidParser_GetUsagesWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, UsagePage, UsageList, UsageLength, Report, ReportLength);
} }
else if (ReportType == HidP_Output) else if (ReportType == HidP_Output)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetUsagesWithReport(Parser, HID_REPORT_TYPE_OUTPUT, UsagePage, UsageList, UsageLength, Report, ReportLength); ParserStatus = HidParser_GetUsagesWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, UsagePage, UsageList, UsageLength, Report, ReportLength);
} }
else if (ReportType == HidP_Feature) else if (ReportType == HidP_Feature)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetUsagesWithReport(Parser, HID_REPORT_TYPE_FEATURE, UsagePage, UsageList, UsageLength, Report, ReportLength); ParserStatus = HidParser_GetUsagesWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, UsagePage, UsageList, UsageLength, Report, ReportLength);
} }
else else
{ {
@ -604,6 +623,12 @@ HidParser_GetScaledUsageValue(
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
HIDPARSER_STATUS ParserStatus; HIDPARSER_STATUS ParserStatus;
ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
// //
// FIXME: implement searching in specific collection // FIXME: implement searching in specific collection
@ -615,21 +640,21 @@ HidParser_GetScaledUsageValue(
// //
// input report // input report
// //
ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, Usage, UsageValue, Report, ReportLength); ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
} }
else if (ReportType == HidP_Output) else if (ReportType == HidP_Output)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, UsageValue, Report, ReportLength); ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
} }
else if (ReportType == HidP_Feature) else if (ReportType == HidP_Feature)
{ {
// //
// input report // input report
// //
ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, UsageValue, Report, ReportLength); ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, UsageValue, Report, ReportLength);
} }
else else
{ {
@ -667,6 +692,12 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes(
{ {
ULONG Index; ULONG Index;
HIDPARSER_STATUS Status = HIDPARSER_STATUS_SUCCESS; HIDPARSER_STATUS Status = HIDPARSER_STATUS_SUCCESS;
ULONG CollectionNumber;
//
// get collection number from context
//
CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser);
for(Index = 0; Index < UsageListLength; Index++) for(Index = 0; Index < UsageListLength; Index++)
{ {
@ -678,7 +709,7 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes(
// //
// process usage // process usage
// //
Status = HidParser_TranslateUsage(Parser, ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext); Status = HidParser_TranslateUsage(Parser, CollectionNumber, ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
} }
else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER) else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER)
{ {
@ -890,12 +921,12 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetData( HidParser_GetData(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
OUT PHIDP_DATA DataList, IN HIDP_REPORT_TYPE ReportType,
IN OUT PULONG DataLength, OUT PHIDP_DATA DataList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG DataLength,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -906,11 +937,11 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetExtendedAttributes( HidParser_GetExtendedAttributes(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USHORT DataIndex, IN HIDP_REPORT_TYPE ReportType,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT DataIndex,
OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
IN OUT PULONG LengthAttributes) IN OUT PULONG LengthAttributes)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -921,9 +952,9 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetLinkCollectionNodes( HidParser_GetLinkCollectionNodes(
IN PHID_PARSER Parser,
OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
IN OUT PULONG LinkCollectionNodesLength, IN OUT PULONG LinkCollectionNodesLength)
IN PHIDP_PREPARSED_DATA PreparsedData)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -934,27 +965,26 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetUsageValue( HidParser_GetUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection,
OUT PULONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, OUT PULONG UsageValue,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
} }
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SysPowerEvent ( HidParser_SysPowerEvent(
IN PHID_PARSER Parser,
IN PCHAR HidPacket, IN PCHAR HidPacket,
IN USHORT HidPacketLength, IN USHORT HidPacketLength,
IN PHIDP_PREPARSED_DATA Ppd,
OUT PULONG OutputBuffer) OUT PULONG OutputBuffer)
{ {
UNIMPLEMENTED UNIMPLEMENTED
@ -965,7 +995,7 @@ HidParser_SysPowerEvent (
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SysPowerCaps ( HidParser_SysPowerCaps (
IN PHIDP_PREPARSED_DATA Ppd, IN PHID_PARSER Parser,
OUT PULONG OutputBuffer) OUT PULONG OutputBuffer)
{ {
UNIMPLEMENTED UNIMPLEMENTED
@ -977,15 +1007,15 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetUsageValueArray( HidParser_GetUsageValueArray(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
OUT PCHAR UsageValue, IN USAGE Usage,
IN USHORT UsageValueByteLength, OUT PCHAR UsageValue,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT UsageValueByteLength,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -996,14 +1026,14 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_UnsetUsages( HidParser_UnsetUsages(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN PUSAGE UsageList, IN USHORT LinkCollection,
IN OUT PULONG UsageLength, IN PUSAGE UsageList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG UsageLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1030,14 +1060,14 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsages( HidParser_SetUsages(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN PUSAGE UsageList, IN USHORT LinkCollection,
IN OUT PULONG UsageLength, IN PUSAGE UsageList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG UsageLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1048,15 +1078,15 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsageValueArray( HidParser_SetUsageValueArray(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
IN PCHAR UsageValue, IN USAGE Usage,
IN USHORT UsageValueByteLength, IN PCHAR UsageValue,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT UsageValueByteLength,
OUT PCHAR Report, OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1067,14 +1097,14 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsageValue( HidParser_SetUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection,
IN ULONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, IN ULONG UsageValue,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1085,14 +1115,14 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetScaledUsageValue( HidParser_SetScaledUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
IN LONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, IN LONG UsageValue,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1103,12 +1133,12 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetData( HidParser_SetData(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN PHIDP_DATA DataList, IN HIDP_REPORT_TYPE ReportType,
IN OUT PULONG DataLength, IN PHIDP_DATA DataList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG DataLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1119,8 +1149,8 @@ HIDAPI
ULONG ULONG
NTAPI NTAPI
HidParser_MaxDataListLength( HidParser_MaxDataListLength(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN PHIDP_PREPARSED_DATA PreparsedData) IN HIDP_REPORT_TYPE ReportType)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1131,11 +1161,11 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_InitializeReportForID( HidParser_InitializeReportForID(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN UCHAR ReportID, IN HIDP_REPORT_TYPE ReportType,
IN PHIDP_PREPARSED_DATA PreparsedData, IN UCHAR ReportID,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength) IN ULONG ReportLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);
@ -1148,10 +1178,10 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetValueCaps( HidParser_GetValueCaps(
HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
PHIDP_VALUE_CAPS ValueCaps, HIDP_REPORT_TYPE ReportType,
PULONG ValueCapsLength, PHIDP_VALUE_CAPS ValueCaps,
PHIDP_PREPARSED_DATA PreparsedData) PULONG ValueCapsLength)
{ {
UNIMPLEMENTED UNIMPLEMENTED
ASSERT(FALSE); ASSERT(FALSE);

View file

@ -119,7 +119,7 @@ VOID
NTAPI NTAPI
HidParser_FreeCollectionDescription( HidParser_FreeCollectionDescription(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN PHIDP_DEVICE_DESC DeviceDescription); IN PHIDP_DEVICE_DESC DeviceDescription);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
@ -180,53 +180,53 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetData( HidParser_GetData(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
OUT PHIDP_DATA DataList, IN HIDP_REPORT_TYPE ReportType,
IN OUT PULONG DataLength, OUT PHIDP_DATA DataList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG DataLength,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetExtendedAttributes( HidParser_GetExtendedAttributes(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USHORT DataIndex, IN HIDP_REPORT_TYPE ReportType,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT DataIndex,
OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
IN OUT PULONG LengthAttributes); IN OUT PULONG LengthAttributes);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetLinkCollectionNodes( HidParser_GetLinkCollectionNodes(
IN PHID_PARSER Parser,
OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
IN OUT PULONG LinkCollectionNodesLength, IN OUT PULONG LinkCollectionNodesLength);
IN PHIDP_PREPARSED_DATA PreparsedData);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetUsageValue( HidParser_GetUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection,
OUT PULONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, OUT PULONG UsageValue,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_UsageListDifference( HidParser_UsageListDifference(
IN PUSAGE PreviousUsageList, IN PUSAGE PreviousUsageList,
IN PUSAGE CurrentUsageList, IN PUSAGE CurrentUsageList,
OUT PUSAGE BreakUsageList, OUT PUSAGE BreakUsageList,
OUT PUSAGE MakeUsageList, OUT PUSAGE MakeUsageList,
IN ULONG UsageListLength); IN ULONG UsageListLength);
HIDAPI HIDAPI
@ -266,30 +266,30 @@ HidParser_GetUsagesEx(
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SysPowerEvent ( HidParser_SysPowerEvent (
IN PHID_PARSER Parser,
IN PCHAR HidPacket, IN PCHAR HidPacket,
IN USHORT HidPacketLength, IN USHORT HidPacketLength,
IN PHIDP_PREPARSED_DATA Ppd,
OUT PULONG OutputBuffer); OUT PULONG OutputBuffer);
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SysPowerCaps ( HidParser_SysPowerCaps (
IN PHIDP_PREPARSED_DATA Ppd, IN PHID_PARSER Parser,
OUT PULONG OutputBuffer); OUT PULONG OutputBuffer);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetUsageValueArray( HidParser_GetUsageValueArray(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
OUT PCHAR UsageValue, IN USAGE Usage,
IN USHORT UsageValueByteLength, OUT PCHAR UsageValue,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT UsageValueByteLength,
IN PCHAR Report, IN PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
@ -306,14 +306,14 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_UnsetUsages( HidParser_UnsetUsages(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN PUSAGE UsageList, IN USHORT LinkCollection,
IN OUT PULONG UsageLength, IN PUSAGE UsageList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG UsageLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
@ -342,87 +342,87 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsages( HidParser_SetUsages(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN PUSAGE UsageList, IN USHORT LinkCollection,
IN OUT PULONG UsageLength, IN PUSAGE UsageList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG UsageLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsageValueArray( HidParser_SetUsageValueArray(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
IN PCHAR UsageValue, IN USAGE Usage,
IN USHORT UsageValueByteLength, IN PCHAR UsageValue,
IN PHIDP_PREPARSED_DATA PreparsedData, IN USHORT UsageValueByteLength,
OUT PCHAR Report, OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetUsageValue( HidParser_SetUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection,
IN ULONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, IN ULONG UsageValue,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetScaledUsageValue( HidParser_SetScaledUsageValue(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN USAGE UsagePage, IN HIDP_REPORT_TYPE ReportType,
IN USHORT LinkCollection OPTIONAL, IN USAGE UsagePage,
IN USAGE Usage, IN USHORT LinkCollection OPTIONAL,
IN LONG UsageValue, IN USAGE Usage,
IN PHIDP_PREPARSED_DATA PreparsedData, IN LONG UsageValue,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_SetData( HidParser_SetData(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN PHIDP_DATA DataList, IN HIDP_REPORT_TYPE ReportType,
IN OUT PULONG DataLength, IN PHIDP_DATA DataList,
IN PHIDP_PREPARSED_DATA PreparsedData, IN OUT PULONG DataLength,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDAPI HIDAPI
ULONG ULONG
NTAPI NTAPI
HidParser_MaxDataListLength( HidParser_MaxDataListLength(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN PHIDP_PREPARSED_DATA PreparsedData); IN HIDP_REPORT_TYPE ReportType);
HIDAPI HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_InitializeReportForID( HidParser_InitializeReportForID(
IN HIDP_REPORT_TYPE ReportType, IN PHID_PARSER Parser,
IN UCHAR ReportID, IN HIDP_REPORT_TYPE ReportType,
IN PHIDP_PREPARSED_DATA PreparsedData, IN UCHAR ReportID,
IN OUT PCHAR Report, IN OUT PCHAR Report,
IN ULONG ReportLength); IN ULONG ReportLength);
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_TranslateUsage( HidParser_TranslateUsage(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN USAGE Usage, IN USAGE Usage,
IN HIDP_KEYBOARD_DIRECTION KeyAction, IN HIDP_KEYBOARD_DIRECTION KeyAction,
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
@ -433,7 +433,7 @@ HIDAPI
NTSTATUS NTSTATUS
NTAPI NTAPI
HidParser_GetValueCaps( HidParser_GetValueCaps(
HIDP_REPORT_TYPE ReportType, PHID_PARSER Parser,
PHIDP_VALUE_CAPS ValueCaps, HIDP_REPORT_TYPE ReportType,
PULONG ValueCapsLength, PHIDP_VALUE_CAPS ValueCaps,
PHIDP_PREPARSED_DATA PreparsedData); PULONG ValueCapsLength);

View file

@ -136,26 +136,6 @@ HidParser_ResetParser(
// //
ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext;
//
// delete all reports
//
for(Index = 0; Index < ParserContext->ReportCount; Index++)
{
//
// delete report
//
HidParser_DeleteReport(Parser, ParserContext->Reports[Index]);
}
if (ParserContext->ReportCount && ParserContext->Reports)
{
//
// free report array
//
Parser->Free(ParserContext->Reports);
}
if (ParserContext->RootCollection) if (ParserContext->RootCollection)
{ {
// //
@ -167,8 +147,6 @@ HidParser_ResetParser(
// //
// reinit parser // reinit parser
// //
ParserContext->ReportCount = 0;
ParserContext->Reports = NULL;
ParserContext->RootCollection = NULL; ParserContext->RootCollection = NULL;
ParserContext->UseReportIDs = FALSE; ParserContext->UseReportIDs = FALSE;
@ -237,33 +215,40 @@ HidParser_AddCollection(
} }
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_FindReport( HidParser_FindReportInCollection(
IN PHID_PARSER Parser, IN PHID_COLLECTION Collection,
IN UCHAR ReportType, IN UCHAR ReportType,
IN UCHAR ReportID, IN UCHAR ReportID,
OUT PHID_REPORT *OutReport) OUT PHID_REPORT *OutReport)
{ {
PHID_PARSER_CONTEXT ParserContext;
ULONG Index; ULONG Index;
HIDPARSER_STATUS Status;
// //
// get parser context // search in local list
// //
ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; for(Index = 0; Index < Collection->ReportCount; Index++)
ASSERT(ParserContext);
for(Index = 0; Index < ParserContext->ReportCount; Index++)
{ {
if (ParserContext->Reports[Index]->Type == ReportType && ParserContext->Reports[Index]->ReportID == ReportID) if (Collection->Reports[Index]->Type == ReportType && Collection->Reports[Index]->ReportID == ReportID)
{ {
// //
// found report // found report
// //
*OutReport = ParserContext->Reports[Index]; *OutReport = Collection->Reports[Index];
return HIDPARSER_STATUS_SUCCESS; return HIDPARSER_STATUS_SUCCESS;
} }
} }
//
// search in sub collections
//
for(Index = 0; Index < Collection->NodeCount; Index++)
{
Status = HidParser_FindReportInCollection(Collection->Nodes[Index], ReportType, ReportID, OutReport);
if (Status == HIDPARSER_STATUS_SUCCESS)
return Status;
}
// //
// no such report found // no such report found
// //
@ -271,6 +256,28 @@ HidParser_FindReport(
return HIDPARSER_STATUS_REPORT_NOT_FOUND; return HIDPARSER_STATUS_REPORT_NOT_FOUND;
} }
HIDPARSER_STATUS
HidParser_FindReport(
IN PHID_PARSER Parser,
IN UCHAR ReportType,
IN UCHAR ReportID,
OUT PHID_REPORT *OutReport)
{
PHID_PARSER_CONTEXT ParserContext;
//
// get parser context
//
ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext;
ASSERT(ParserContext);
//
// search in current top level collection
//
return HidParser_FindReportInCollection(ParserContext->RootCollection->Nodes[ParserContext->RootCollection->NodeCount-1], ReportType, ReportID, OutReport);
}
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_AllocateReport( HidParser_AllocateReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
@ -306,8 +313,9 @@ HidParser_AllocateReport(
} }
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_AddReport( HidParser_AddReportToCollection(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN PHID_COLLECTION CurrentCollection,
IN PHID_REPORT NewReport) IN PHID_REPORT NewReport)
{ {
PHID_REPORT * NewReportArray; PHID_REPORT * NewReportArray;
@ -322,7 +330,7 @@ HidParser_AddReport(
// //
// allocate new report array // allocate new report array
// //
NewReportArray = (PHID_REPORT*)Parser->Alloc(sizeof(PHID_REPORT) * (ParserContext->ReportCount + 1)); NewReportArray = (PHID_REPORT*)Parser->Alloc(sizeof(PHID_REPORT) * (CurrentCollection->ReportCount + 1));
if (!NewReportArray) if (!NewReportArray)
{ {
// //
@ -331,25 +339,25 @@ HidParser_AddReport(
return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES; return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES;
} }
if (ParserContext->ReportCount) if (CurrentCollection->ReportCount)
{ {
// //
// copy old array contents // copy old array contents
// //
Parser->Copy(NewReportArray, ParserContext->Reports, sizeof(PHID_REPORT) * ParserContext->ReportCount); Parser->Copy(NewReportArray, CurrentCollection->Reports, sizeof(PHID_REPORT) * CurrentCollection->ReportCount);
// //
// free old array // free old array
// //
Parser->Free(ParserContext->Reports); Parser->Free(CurrentCollection->Reports);
} }
// //
// store result // store result
// //
NewReportArray[ParserContext->ReportCount] = NewReport; NewReportArray[CurrentCollection->ReportCount] = NewReport;
ParserContext->Reports = NewReportArray; CurrentCollection->Reports = NewReportArray;
ParserContext->ReportCount++; CurrentCollection->ReportCount++;
// //
// completed successfully // completed successfully
@ -360,6 +368,7 @@ HidParser_AddReport(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetReport( HidParser_GetReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN PHID_COLLECTION Collection,
IN UCHAR ReportType, IN UCHAR ReportType,
IN UCHAR ReportID, IN UCHAR ReportID,
IN UCHAR CreateIfNotExists, IN UCHAR CreateIfNotExists,
@ -394,7 +403,7 @@ HidParser_GetReport(
// //
// add report // add report
// //
Status = HidParser_AddReport(Parser, *OutReport); Status = HidParser_AddReportToCollection(Parser, Collection, *OutReport);
if (Status != HIDPARSER_STATUS_SUCCESS) if (Status != HIDPARSER_STATUS_SUCCESS)
{ {
// //
@ -925,7 +934,7 @@ HidParser_ParseReportDescriptor(
} }
} }
Parser->Debug("Tag %x Type %x Size %x Offset %lu Length %lu\n", CurrentItem->Tag, CurrentItem->Type, CurrentItem->Size, ((ULONG_PTR)CurrentItem - (ULONG_PTR)ReportDescriptor), ReportLength);
// //
// handle items // handle items
// //
@ -1019,7 +1028,7 @@ HidParser_ParseReportDescriptor(
break; break;
default: default:
Parser->Debug("[HIDPARSE] Unknown ReportType %x\n", CurrentItem->Tag); Parser->Debug("[HIDPARSE] Unknown ReportType Tag %x Type %x Size %x CurrentItemSize %x\n", CurrentItem->Tag, CurrentItem->Type, CurrentItem->Size, CurrentItemSize);
ASSERT(FALSE); ASSERT(FALSE);
break; break;
} }
@ -1030,7 +1039,7 @@ HidParser_ParseReportDescriptor(
// //
// get report // get report
// //
Status = HidParser_GetReport(Parser, ReportType, ParserContext->GlobalItemState.ReportId, TRUE, &Report); Status = HidParser_GetReport(Parser, CurrentCollection, ReportType, ParserContext->GlobalItemState.ReportId, TRUE, &Report);
ASSERT(Status == HIDPARSER_STATUS_SUCCESS); ASSERT(Status == HIDPARSER_STATUS_SUCCESS);
// fill in a sensible default if the index isn't set // fill in a sensible default if the index isn't set
@ -1246,7 +1255,7 @@ HidParser_ParseReportDescriptor(
break; break;
case ITEM_TAG_LOCAL_USAGE_MAXIMUM: case ITEM_TAG_LOCAL_USAGE_MAXIMUM:
Parser->Debug("[HIDPARSE] ITEM_TAG_LOCAL_USAGE_MAXIMUM Data %x\n", Data); Parser->Debug("[HIDPARSE] ITEM_TAG_LOCAL_USAGE_MAXIMUM Data %x ItemSize %x %x\n", Data, CurrentItemSize, CurrentItem->Size);
ParserContext->LocalItemState.UsageMaximum.u.Extended = Data; ParserContext->LocalItemState.UsageMaximum.u.Extended = Data;
ParserContext->LocalItemState.UsageMaximum.IsExtended ParserContext->LocalItemState.UsageMaximum.IsExtended
= CurrentItemSize == sizeof(ULONG); = CurrentItemSize == sizeof(ULONG);
@ -1344,4 +1353,3 @@ HidParser_ParseReportDescriptor(
// //
return HIDPARSER_STATUS_SUCCESS; return HIDPARSER_STATUS_SUCCESS;
} }

View file

@ -195,7 +195,7 @@ typedef struct
UCHAR Valid; UCHAR Valid;
}HID_REPORT_ITEM, *PHID_REPORT_ITEM; }HID_REPORT_ITEM, *PHID_REPORT_ITEM;
struct HID_REPORT; struct _HID_REPORT;
typedef struct __HID_COLLECTION__ typedef struct __HID_COLLECTION__
{ {
@ -210,14 +210,15 @@ typedef struct __HID_COLLECTION__
ULONG ItemCount; ULONG ItemCount;
ULONG ItemCountAllocated; ULONG ItemCountAllocated;
PHID_REPORT_ITEM * Items; PHID_REPORT_ITEM * Items;
//ULONG ReportCount; ULONG ReportCount;
//struct HID_REPORT ** Reports; struct _HID_REPORT ** Reports;
}HID_COLLECTION, *PHID_COLLECTION; }HID_COLLECTION, *PHID_COLLECTION;
typedef struct typedef struct _HID_REPORT
{ {
UCHAR Type; UCHAR Type;
UCHAR ReportID; UCHAR ReportID;
@ -225,11 +226,8 @@ typedef struct
ULONG ItemCount; ULONG ItemCount;
ULONG ItemAllocated; ULONG ItemAllocated;
PHID_REPORT_ITEM *Items; PHID_REPORT_ITEM* Items;
ULONG ReportStatus;
UCHAR * CurrentReport;
ULONG BusyCount;
}HID_REPORT, *PHID_REPORT; }HID_REPORT, *PHID_REPORT;
typedef struct typedef struct
@ -249,21 +247,16 @@ typedef struct
// //
PHID_COLLECTION RootCollection; PHID_COLLECTION RootCollection;
//
// report count
//
ULONG ReportCount;
//
// reports
//
PHID_REPORT * Reports;
// //
// uses report ids // uses report ids
// //
UCHAR UseReportIDs; UCHAR UseReportIDs;
//
// collection index
//
ULONG CollectionIndex;
}HID_PARSER_CONTEXT, *PHID_PARSER_CONTEXT; }HID_PARSER_CONTEXT, *PHID_PARSER_CONTEXT;
HIDPARSER_STATUS HIDPARSER_STATUS
@ -280,11 +273,6 @@ HidParser_NumberOfTopCollections(
#define HID_REPORT_TYPE_OUTPUT 0x02 #define HID_REPORT_TYPE_OUTPUT 0x02
#define HID_REPORT_TYPE_FEATURE 0x04 #define HID_REPORT_TYPE_FEATURE 0x04
ULONG
HidParser_NumberOfReports(
IN PHID_PARSER Parser,
IN ULONG ReportType);
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetCollectionUsagePage( HidParser_GetCollectionUsagePage(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
@ -295,6 +283,7 @@ HidParser_GetCollectionUsagePage(
ULONG ULONG
HidParser_GetReportLength( HidParser_GetReportLength(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionIndex,
IN ULONG ReportType); IN ULONG ReportType);
UCHAR UCHAR
@ -304,17 +293,20 @@ HidParser_IsReportIDUsed(
ULONG ULONG
HidParser_GetReportItemCountFromReportType( HidParser_GetReportItemCountFromReportType(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType); IN ULONG ReportType);
ULONG ULONG
HidParser_GetReportItemTypeCountFromReportType( HidParser_GetReportItemTypeCountFromReportType(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType, IN ULONG ReportType,
IN ULONG bData); IN ULONG bData);
ULONG ULONG
HidParser_GetContextSize( HidParser_GetContextSize(
IN PHID_PARSER Parser); IN PHID_PARSER Parser,
IN ULONG CollectionNumber);
VOID VOID
HidParser_FreeContext( HidParser_FreeContext(
@ -329,12 +321,14 @@ HidParser_GetTotalCollectionCount(
ULONG ULONG
HidParser_GetMaxUsageListLengthWithReportAndPage( HidParser_GetMaxUsageListLengthWithReportAndPage(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage OPTIONAL); IN USAGE UsagePage OPTIONAL);
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetSpecificValueCapsWithReport( HidParser_GetSpecificValueCapsWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType, IN ULONG ReportType,
IN USHORT UsagePage, IN USHORT UsagePage,
IN USHORT Usage, IN USHORT Usage,
@ -345,6 +339,7 @@ HidParser_GetSpecificValueCapsWithReport(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetUsagesWithReport( HidParser_GetUsagesWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage, IN USAGE UsagePage,
OUT USAGE *UsageList, OUT USAGE *UsageList,
@ -355,9 +350,15 @@ HidParser_GetUsagesWithReport(
HIDPARSER_STATUS HIDPARSER_STATUS
HidParser_GetScaledUsageValueWithReport( HidParser_GetScaledUsageValueWithReport(
IN PHID_PARSER Parser, IN PHID_PARSER Parser,
IN ULONG CollectionNumber,
IN ULONG ReportType, IN ULONG ReportType,
IN USAGE UsagePage, IN USAGE UsagePage,
IN USAGE Usage, IN USAGE Usage,
OUT PLONG UsageValue, OUT PLONG UsageValue,
IN PCHAR ReportDescriptor, IN PCHAR ReportDescriptor,
IN ULONG ReportDescriptorLength); IN ULONG ReportDescriptorLength);
ULONG
HidParser_GetCollectionNumberFromParserContext(
IN PHID_PARSER Parser);