From a7eba59665e14da26201d8e5c272ca87dc91ffe7 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 30 Jan 2012 19:29:26 +0000 Subject: [PATCH] [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 --- lib/drivers/hidparser/api.c | 129 ++++++------- lib/drivers/hidparser/hidparser.c | 294 ++++++++++++++++-------------- lib/drivers/hidparser/hidparser.h | 194 ++++++++++---------- lib/drivers/hidparser/parser.c | 100 +++++----- lib/drivers/hidparser/parser.h | 49 ++--- 5 files changed, 405 insertions(+), 361 deletions(-) diff --git a/lib/drivers/hidparser/api.c b/lib/drivers/hidparser/api.c index b75dd15ac99..c2d781edfdc 100644 --- a/lib/drivers/hidparser/api.c +++ b/lib/drivers/hidparser/api.c @@ -95,89 +95,73 @@ HidParser_GetCollection( } PHID_REPORT -HidParser_GetReportByType( - IN PHID_PARSER Parser, - IN ULONG ReportType) +HidParser_GetReportInCollection( + PHID_COLLECTION Collection, + IN UCHAR ReportType) { - PHID_PARSER_CONTEXT ParserContext; ULONG Index; + PHID_REPORT Report; // - // get parser context + // search in local array // - ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; - - // - // sanity checks - // - ASSERT(ParserContext); - - // - // FIXME support multiple top collecions - // - ASSERT(ParserContext->RootCollection->NodeCount == 1); - for(Index = 0; Index < ParserContext->ReportCount; Index++) + for(Index = 0; Index < Collection->ReportCount; Index++) { - // - // check if the report type match - // - if (ParserContext->Reports[Index]->Type == ReportType) + if (Collection->Reports[Index]->Type == ReportType) { // // 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; } - -ULONG -HidParser_NumberOfReports( +PHID_REPORT +HidParser_GetReportByType( IN PHID_PARSER Parser, - IN ULONG ReportType) + IN ULONG CollectionIndex, + IN UCHAR ReportType) { - PHID_PARSER_CONTEXT ParserContext; - ULONG Index; - ULONG ReportCount = 0; + PHID_COLLECTION Collection; // - // get parser context + // find collection // - ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; - - // - // sanity checks - // - ASSERT(ParserContext); - - // - // FIXME support multiple top collecions - // - ASSERT(ParserContext->RootCollection->NodeCount == 1); - for(Index = 0; Index < ParserContext->ReportCount; Index++) + Collection = HidParser_GetCollection(Parser, CollectionIndex); + if (!Collection) { // - // check if the report type match + // no such collection // - if (ParserContext->Reports[Index]->Type == ReportType) - { - // - // found report - // - ReportCount++; - } + ASSERT(FALSE); + return NULL; } // - // done + // search report // - return ReportCount; + return HidParser_GetReportInCollection(Collection, ReportType); } HIDPARSER_STATUS @@ -212,6 +196,7 @@ HidParser_GetCollectionUsagePage( ULONG HidParser_GetReportLength( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType) { PHID_PARSER_CONTEXT ParserContext; @@ -236,7 +221,7 @@ HidParser_GetReportLength( // // get first report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -289,6 +274,7 @@ HidParser_IsReportIDUsed( ULONG HidParser_GetReportItemCountFromReportType( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType) { PHID_PARSER_CONTEXT ParserContext; @@ -312,7 +298,7 @@ HidParser_GetReportItemCountFromReportType( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -331,6 +317,7 @@ HidParser_GetReportItemCountFromReportType( ULONG HidParser_GetReportItemTypeCountFromReportType( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType, IN ULONG bData) { @@ -357,7 +344,7 @@ HidParser_GetReportItemTypeCountFromReportType( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -398,7 +385,8 @@ HidParser_GetReportItemTypeCountFromReportType( ULONG HidParser_GetContextSize( - IN PHID_PARSER Parser) + IN PHID_PARSER Parser, + IN ULONG CollectionIndex) { // // FIXME the context must contain all parsed info @@ -540,6 +528,7 @@ HidParser_GetTotalCollectionCount( ULONG HidParser_GetMaxUsageListLengthWithReportAndPage( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType, IN USAGE UsagePage OPTIONAL) { @@ -567,7 +556,7 @@ HidParser_GetMaxUsageListLengthWithReportAndPage( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -600,6 +589,7 @@ HidParser_GetMaxUsageListLengthWithReportAndPage( HIDPARSER_STATUS HidParser_GetSpecificValueCapsWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType, IN USHORT UsagePage, IN USHORT Usage, @@ -631,7 +621,7 @@ HidParser_GetSpecificValueCapsWithReport( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -705,6 +695,7 @@ HidParser_GetSpecificValueCapsWithReport( HIDPARSER_STATUS HidParser_GetUsagesWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType, IN USAGE UsagePage, OUT USAGE *UsageList, @@ -739,7 +730,7 @@ HidParser_GetUsagesWithReport( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -852,6 +843,7 @@ HidParser_GetUsagesWithReport( HIDPARSER_STATUS HidParser_GetScaledUsageValueWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType, IN USAGE UsagePage, IN USAGE Usage, @@ -884,7 +876,7 @@ HidParser_GetScaledUsageValueWithReport( // // get report // - Report = HidParser_GetReportByType(Parser, ReportType); + Report = HidParser_GetReportByType(Parser, CollectionIndex, ReportType); if (!Report) { // @@ -1042,6 +1034,7 @@ HidParser_DispatchKey( HIDPARSER_STATUS HidParser_TranslateUsage( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, @@ -1072,4 +1065,16 @@ HidParser_TranslateUsage( // done // return HIDPARSER_STATUS_SUCCESS; -} \ No newline at end of file +} + +ULONG +HidParser_GetCollectionNumberFromParserContext( + IN PHID_PARSER Parser) +{ + PHID_PARSER_CONTEXT Context = (PHID_PARSER_CONTEXT)Parser->ParserContext; + + // + // get parser context + // + return Context->CollectionIndex; +} diff --git a/lib/drivers/hidparser/hidparser.c b/lib/drivers/hidparser/hidparser.c index c568cd81374..c84533ef56b 100644 --- a/lib/drivers/hidparser/hidparser.c +++ b/lib/drivers/hidparser/hidparser.c @@ -69,16 +69,12 @@ HidParser_GetCollectionDescription( // get collection count // CollectionCount = HidParser_NumberOfTopCollections(Parser); - - // - // FIXME: only one top level collection is supported - // - ASSERT(CollectionCount <= 1); if (CollectionCount == 0) { // // no top level collections found // + ASSERT(FALSE); return STATUS_NO_DATA_DETECTED; } @@ -119,9 +115,9 @@ HidParser_GetCollectionDescription( // DeviceDescription->ReportIDs[Index].CollectionNumber = Index + 1; DeviceDescription->ReportIDs[Index].ReportID = Index; //FIXME - DeviceDescription->ReportIDs[Index].InputLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_INPUT); - DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_OUTPUT); - DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_FEATURE); + DeviceDescription->ReportIDs[Index].InputLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_INPUT); + DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_OUTPUT); + DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength(Parser, Index, HID_REPORT_TYPE_FEATURE); // // init collection description @@ -143,7 +139,7 @@ HidParser_GetCollectionDescription( // // 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); if (!DeviceDescription->CollectionDesc[Index].PreparsedData) { @@ -209,23 +205,24 @@ HidParser_GetCaps( OUT PHIDP_CAPS Capabilities) { ULONG CollectionNumber; + + // + // get collection number from context + // + CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser); + // // zero capabilities // Parser->Zero(Capabilities, sizeof(HIDP_CAPS)); - // - // FIXME support multiple top level collections - // - CollectionNumber = 0; - // // init capabilities // HidParser_GetCollectionUsagePage(Parser, CollectionNumber, &Capabilities->Usage, &Capabilities->UsagePage); - Capabilities->InputReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_INPUT); - Capabilities->OutputReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_OUTPUT); - Capabilities->FeatureReportByteLength = HidParser_GetReportLength(Parser, HID_REPORT_TYPE_FEATURE); + Capabilities->InputReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT); + Capabilities->OutputReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT); + Capabilities->FeatureReportByteLength = HidParser_GetReportLength(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE); // // always pre-prend report id @@ -237,29 +234,29 @@ HidParser_GetCaps( // // get number of link collection nodes // - Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(Parser); + Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(Parser, CollectionNumber); // // get data indices // - Capabilities->NumberInputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_INPUT, TRUE); - Capabilities->NumberOutputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT, TRUE); - Capabilities->NumberFeatureDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE, TRUE); + Capabilities->NumberInputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, TRUE); + Capabilities->NumberOutputDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, TRUE); + Capabilities->NumberFeatureDataIndices = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, TRUE); // // get value caps // - Capabilities->NumberInputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_INPUT, FALSE); - Capabilities->NumberOutputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT, FALSE); - Capabilities->NumberFeatureValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE, FALSE); + Capabilities->NumberInputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT, FALSE); + Capabilities->NumberOutputValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT, FALSE); + Capabilities->NumberFeatureValueCaps = HidParser_GetReportItemTypeCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, FALSE); // // get button caps // - Capabilities->NumberInputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_INPUT); - Capabilities->NumberOutputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_OUTPUT); - Capabilities->NumberFeatureButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, HID_REPORT_TYPE_FEATURE); + Capabilities->NumberInputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_INPUT); + Capabilities->NumberOutputButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_OUTPUT); + Capabilities->NumberFeatureButtonCaps = HidParser_GetReportItemCountFromReportType(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE); // // done @@ -275,6 +272,14 @@ HidParser_MaxUsageListLength( IN HIDP_REPORT_TYPE ReportType, 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 // @@ -296,21 +301,21 @@ HidParser_MaxUsageListLength( // // 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) { // // 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) { // // input report // - return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_FEATURE, UsagePage); + return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, CollectionNumber, HID_REPORT_TYPE_FEATURE, UsagePage); } else { @@ -348,6 +353,14 @@ HidParser_GetSpecificValueCaps( IN OUT PULONG ValueCapsLength) { HIDPARSER_STATUS ParserStatus; + ULONG CollectionNumber; + + // + // get collection number from context + // + CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser); + + // // FIXME: implement searching in specific collection @@ -359,21 +372,21 @@ HidParser_GetSpecificValueCaps( // // 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) { // // 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) { // // 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 { @@ -541,6 +554,12 @@ HidParser_GetUsages( IN ULONG ReportLength) { HIDPARSER_STATUS ParserStatus; + ULONG CollectionNumber; + + // + // get collection number from context + // + CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser); // // FIXME: implement searching in specific collection @@ -552,21 +571,21 @@ HidParser_GetUsages( // // 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) { // // 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) { // // 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 { @@ -604,6 +623,12 @@ HidParser_GetScaledUsageValue( IN ULONG ReportLength) { HIDPARSER_STATUS ParserStatus; + ULONG CollectionNumber; + + // + // get collection number from context + // + CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser); // // FIXME: implement searching in specific collection @@ -615,21 +640,21 @@ HidParser_GetScaledUsageValue( // // 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) { // // 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) { // // 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 { @@ -667,6 +692,12 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes( { ULONG Index; HIDPARSER_STATUS Status = HIDPARSER_STATUS_SUCCESS; + ULONG CollectionNumber; + + // + // get collection number from context + // + CollectionNumber = HidParser_GetCollectionNumberFromParserContext(Parser); for(Index = 0; Index < UsageListLength; Index++) { @@ -678,7 +709,7 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes( // // 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) { @@ -890,12 +921,12 @@ HIDAPI NTSTATUS NTAPI HidParser_GetData( - IN HIDP_REPORT_TYPE ReportType, - OUT PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + OUT PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -906,11 +937,11 @@ HIDAPI NTSTATUS NTAPI HidParser_GetExtendedAttributes( - IN HIDP_REPORT_TYPE ReportType, - IN USHORT DataIndex, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, - IN OUT PULONG LengthAttributes) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USHORT DataIndex, + OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, + IN OUT PULONG LengthAttributes) { UNIMPLEMENTED ASSERT(FALSE); @@ -921,9 +952,9 @@ HIDAPI NTSTATUS NTAPI HidParser_GetLinkCollectionNodes( + IN PHID_PARSER Parser, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, - IN OUT PULONG LinkCollectionNodesLength, - IN PHIDP_PREPARSED_DATA PreparsedData) + IN OUT PULONG LinkCollectionNodesLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -934,27 +965,26 @@ HIDAPI NTSTATUS NTAPI HidParser_GetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - OUT PULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + OUT PULONG UsageValue, + IN PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); return STATUS_NOT_IMPLEMENTED; } - NTSTATUS NTAPI -HidParser_SysPowerEvent ( +HidParser_SysPowerEvent( + IN PHID_PARSER Parser, IN PCHAR HidPacket, IN USHORT HidPacketLength, - IN PHIDP_PREPARSED_DATA Ppd, OUT PULONG OutputBuffer) { UNIMPLEMENTED @@ -965,7 +995,7 @@ HidParser_SysPowerEvent ( NTSTATUS NTAPI HidParser_SysPowerCaps ( - IN PHIDP_PREPARSED_DATA Ppd, + IN PHID_PARSER Parser, OUT PULONG OutputBuffer) { UNIMPLEMENTED @@ -977,15 +1007,15 @@ HIDAPI NTSTATUS NTAPI HidParser_GetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - OUT PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + OUT PCHAR UsageValue, + IN USHORT UsageValueByteLength, + IN PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -996,14 +1026,14 @@ HIDAPI NTSTATUS NTAPI HidParser_UnsetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1030,14 +1060,14 @@ HIDAPI NTSTATUS NTAPI HidParser_SetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1048,15 +1078,15 @@ HIDAPI NTSTATUS NTAPI HidParser_SetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN PCHAR UsageValue, + IN USHORT UsageValueByteLength, + OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1067,14 +1097,14 @@ HIDAPI NTSTATUS NTAPI HidParser_SetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - IN ULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + IN ULONG UsageValue, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1085,14 +1115,14 @@ HIDAPI NTSTATUS NTAPI HidParser_SetScaledUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN LONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN LONG UsageValue, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1103,12 +1133,12 @@ HIDAPI NTSTATUS NTAPI HidParser_SetData( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1119,8 +1149,8 @@ HIDAPI ULONG NTAPI HidParser_MaxDataListLength( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_PREPARSED_DATA PreparsedData) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType) { UNIMPLEMENTED ASSERT(FALSE); @@ -1131,11 +1161,11 @@ HIDAPI NTSTATUS NTAPI HidParser_InitializeReportForID( - IN HIDP_REPORT_TYPE ReportType, - IN UCHAR ReportID, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN UCHAR ReportID, + IN OUT PCHAR Report, + IN ULONG ReportLength) { UNIMPLEMENTED ASSERT(FALSE); @@ -1148,10 +1178,10 @@ HIDAPI NTSTATUS NTAPI HidParser_GetValueCaps( - HIDP_REPORT_TYPE ReportType, - PHIDP_VALUE_CAPS ValueCaps, - PULONG ValueCapsLength, - PHIDP_PREPARSED_DATA PreparsedData) + IN PHID_PARSER Parser, + HIDP_REPORT_TYPE ReportType, + PHIDP_VALUE_CAPS ValueCaps, + PULONG ValueCapsLength) { UNIMPLEMENTED ASSERT(FALSE); diff --git a/lib/drivers/hidparser/hidparser.h b/lib/drivers/hidparser/hidparser.h index e5e917e2604..24d282a732c 100644 --- a/lib/drivers/hidparser/hidparser.h +++ b/lib/drivers/hidparser/hidparser.h @@ -119,7 +119,7 @@ VOID NTAPI HidParser_FreeCollectionDescription( IN PHID_PARSER Parser, - IN PHIDP_DEVICE_DESC DeviceDescription); + IN PHIDP_DEVICE_DESC DeviceDescription); HIDAPI NTSTATUS @@ -180,53 +180,53 @@ HIDAPI NTSTATUS NTAPI HidParser_GetData( - IN HIDP_REPORT_TYPE ReportType, - OUT PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + OUT PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_GetExtendedAttributes( - IN HIDP_REPORT_TYPE ReportType, - IN USHORT DataIndex, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, - IN OUT PULONG LengthAttributes); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USHORT DataIndex, + OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, + IN OUT PULONG LengthAttributes); HIDAPI NTSTATUS NTAPI HidParser_GetLinkCollectionNodes( + IN PHID_PARSER Parser, OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, - IN OUT PULONG LinkCollectionNodesLength, - IN PHIDP_PREPARSED_DATA PreparsedData); + IN OUT PULONG LinkCollectionNodesLength); HIDAPI NTSTATUS NTAPI HidParser_GetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - OUT PULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + OUT PULONG UsageValue, + IN PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_UsageListDifference( - IN PUSAGE PreviousUsageList, - IN PUSAGE CurrentUsageList, - OUT PUSAGE BreakUsageList, - OUT PUSAGE MakeUsageList, - IN ULONG UsageListLength); + IN PUSAGE PreviousUsageList, + IN PUSAGE CurrentUsageList, + OUT PUSAGE BreakUsageList, + OUT PUSAGE MakeUsageList, + IN ULONG UsageListLength); HIDAPI @@ -266,30 +266,30 @@ HidParser_GetUsagesEx( NTSTATUS NTAPI HidParser_SysPowerEvent ( + IN PHID_PARSER Parser, IN PCHAR HidPacket, IN USHORT HidPacketLength, - IN PHIDP_PREPARSED_DATA Ppd, OUT PULONG OutputBuffer); NTSTATUS NTAPI HidParser_SysPowerCaps ( - IN PHIDP_PREPARSED_DATA Ppd, + IN PHID_PARSER Parser, OUT PULONG OutputBuffer); HIDAPI NTSTATUS NTAPI HidParser_GetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - OUT PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + OUT PCHAR UsageValue, + IN USHORT UsageValueByteLength, + IN PCHAR Report, + IN ULONG ReportLength); HIDAPI @@ -306,14 +306,14 @@ HIDAPI NTSTATUS NTAPI HidParser_UnsetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS @@ -342,87 +342,87 @@ HIDAPI NTSTATUS NTAPI HidParser_SetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_SetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN PCHAR UsageValue, + IN USHORT UsageValueByteLength, + OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_SetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - IN ULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + IN ULONG UsageValue, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_SetScaledUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN LONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN LONG UsageValue, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI NTSTATUS NTAPI HidParser_SetData( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDAPI ULONG NTAPI HidParser_MaxDataListLength( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_PREPARSED_DATA PreparsedData); + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType); HIDAPI NTSTATUS NTAPI HidParser_InitializeReportForID( - IN HIDP_REPORT_TYPE ReportType, - IN UCHAR ReportID, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength); - + IN PHID_PARSER Parser, + IN HIDP_REPORT_TYPE ReportType, + IN UCHAR ReportID, + IN OUT PCHAR Report, + IN ULONG ReportLength); HIDPARSER_STATUS HidParser_TranslateUsage( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN USAGE Usage, IN HIDP_KEYBOARD_DIRECTION KeyAction, IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState, @@ -433,7 +433,7 @@ HIDAPI NTSTATUS NTAPI HidParser_GetValueCaps( - HIDP_REPORT_TYPE ReportType, - PHIDP_VALUE_CAPS ValueCaps, - PULONG ValueCapsLength, - PHIDP_PREPARSED_DATA PreparsedData); + PHID_PARSER Parser, + HIDP_REPORT_TYPE ReportType, + PHIDP_VALUE_CAPS ValueCaps, + PULONG ValueCapsLength); diff --git a/lib/drivers/hidparser/parser.c b/lib/drivers/hidparser/parser.c index d86b6df9bd0..4bb494bbc48 100644 --- a/lib/drivers/hidparser/parser.c +++ b/lib/drivers/hidparser/parser.c @@ -136,26 +136,6 @@ HidParser_ResetParser( // 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) { // @@ -167,8 +147,6 @@ HidParser_ResetParser( // // reinit parser // - ParserContext->ReportCount = 0; - ParserContext->Reports = NULL; ParserContext->RootCollection = NULL; ParserContext->UseReportIDs = FALSE; @@ -237,33 +215,40 @@ HidParser_AddCollection( } HIDPARSER_STATUS -HidParser_FindReport( - IN PHID_PARSER Parser, +HidParser_FindReportInCollection( + IN PHID_COLLECTION Collection, IN UCHAR ReportType, IN UCHAR ReportID, OUT PHID_REPORT *OutReport) { - PHID_PARSER_CONTEXT ParserContext; ULONG Index; + HIDPARSER_STATUS Status; // - // get parser context + // search in local list // - ParserContext = (PHID_PARSER_CONTEXT)Parser->ParserContext; - ASSERT(ParserContext); - - for(Index = 0; Index < ParserContext->ReportCount; Index++) + for(Index = 0; Index < Collection->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 // - *OutReport = ParserContext->Reports[Index]; + *OutReport = Collection->Reports[Index]; 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 // @@ -271,6 +256,28 @@ HidParser_FindReport( 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_AllocateReport( IN PHID_PARSER Parser, @@ -306,8 +313,9 @@ HidParser_AllocateReport( } HIDPARSER_STATUS -HidParser_AddReport( +HidParser_AddReportToCollection( IN PHID_PARSER Parser, + IN PHID_COLLECTION CurrentCollection, IN PHID_REPORT NewReport) { PHID_REPORT * NewReportArray; @@ -322,7 +330,7 @@ HidParser_AddReport( // // 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) { // @@ -331,25 +339,25 @@ HidParser_AddReport( return HIDPARSER_STATUS_INSUFFICIENT_RESOURCES; } - if (ParserContext->ReportCount) + if (CurrentCollection->ReportCount) { // // 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 // - Parser->Free(ParserContext->Reports); + Parser->Free(CurrentCollection->Reports); } // // store result // - NewReportArray[ParserContext->ReportCount] = NewReport; - ParserContext->Reports = NewReportArray; - ParserContext->ReportCount++; + NewReportArray[CurrentCollection->ReportCount] = NewReport; + CurrentCollection->Reports = NewReportArray; + CurrentCollection->ReportCount++; // // completed successfully @@ -360,6 +368,7 @@ HidParser_AddReport( HIDPARSER_STATUS HidParser_GetReport( IN PHID_PARSER Parser, + IN PHID_COLLECTION Collection, IN UCHAR ReportType, IN UCHAR ReportID, IN UCHAR CreateIfNotExists, @@ -394,7 +403,7 @@ HidParser_GetReport( // // add report // - Status = HidParser_AddReport(Parser, *OutReport); + Status = HidParser_AddReportToCollection(Parser, Collection, *OutReport); 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 // @@ -1019,7 +1028,7 @@ HidParser_ParseReportDescriptor( break; 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); break; } @@ -1030,7 +1039,7 @@ HidParser_ParseReportDescriptor( // // 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); // fill in a sensible default if the index isn't set @@ -1246,7 +1255,7 @@ HidParser_ParseReportDescriptor( break; 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.IsExtended = CurrentItemSize == sizeof(ULONG); @@ -1344,4 +1353,3 @@ HidParser_ParseReportDescriptor( // return HIDPARSER_STATUS_SUCCESS; } - diff --git a/lib/drivers/hidparser/parser.h b/lib/drivers/hidparser/parser.h index 489ad2356e7..1a633a9fba2 100644 --- a/lib/drivers/hidparser/parser.h +++ b/lib/drivers/hidparser/parser.h @@ -195,7 +195,7 @@ typedef struct UCHAR Valid; }HID_REPORT_ITEM, *PHID_REPORT_ITEM; -struct HID_REPORT; +struct _HID_REPORT; typedef struct __HID_COLLECTION__ { @@ -210,14 +210,15 @@ typedef struct __HID_COLLECTION__ ULONG ItemCount; ULONG ItemCountAllocated; + PHID_REPORT_ITEM * Items; - //ULONG ReportCount; - //struct HID_REPORT ** Reports; + ULONG ReportCount; + struct _HID_REPORT ** Reports; }HID_COLLECTION, *PHID_COLLECTION; -typedef struct +typedef struct _HID_REPORT { UCHAR Type; UCHAR ReportID; @@ -225,11 +226,8 @@ typedef struct ULONG ItemCount; ULONG ItemAllocated; - PHID_REPORT_ITEM *Items; + PHID_REPORT_ITEM* Items; - ULONG ReportStatus; - UCHAR * CurrentReport; - ULONG BusyCount; }HID_REPORT, *PHID_REPORT; typedef struct @@ -249,21 +247,16 @@ typedef struct // PHID_COLLECTION RootCollection; - // - // report count - // - ULONG ReportCount; - - // - // reports - // - PHID_REPORT * Reports; - // // uses report ids // UCHAR UseReportIDs; + // + // collection index + // + ULONG CollectionIndex; + }HID_PARSER_CONTEXT, *PHID_PARSER_CONTEXT; HIDPARSER_STATUS @@ -280,11 +273,6 @@ HidParser_NumberOfTopCollections( #define HID_REPORT_TYPE_OUTPUT 0x02 #define HID_REPORT_TYPE_FEATURE 0x04 -ULONG -HidParser_NumberOfReports( - IN PHID_PARSER Parser, - IN ULONG ReportType); - HIDPARSER_STATUS HidParser_GetCollectionUsagePage( IN PHID_PARSER Parser, @@ -295,6 +283,7 @@ HidParser_GetCollectionUsagePage( ULONG HidParser_GetReportLength( IN PHID_PARSER Parser, + IN ULONG CollectionIndex, IN ULONG ReportType); UCHAR @@ -304,17 +293,20 @@ HidParser_IsReportIDUsed( ULONG HidParser_GetReportItemCountFromReportType( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType); ULONG HidParser_GetReportItemTypeCountFromReportType( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType, IN ULONG bData); ULONG HidParser_GetContextSize( - IN PHID_PARSER Parser); + IN PHID_PARSER Parser, + IN ULONG CollectionNumber); VOID HidParser_FreeContext( @@ -329,12 +321,14 @@ HidParser_GetTotalCollectionCount( ULONG HidParser_GetMaxUsageListLengthWithReportAndPage( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType, IN USAGE UsagePage OPTIONAL); HIDPARSER_STATUS HidParser_GetSpecificValueCapsWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType, IN USHORT UsagePage, IN USHORT Usage, @@ -345,6 +339,7 @@ HidParser_GetSpecificValueCapsWithReport( HIDPARSER_STATUS HidParser_GetUsagesWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType, IN USAGE UsagePage, OUT USAGE *UsageList, @@ -355,9 +350,15 @@ HidParser_GetUsagesWithReport( HIDPARSER_STATUS HidParser_GetScaledUsageValueWithReport( IN PHID_PARSER Parser, + IN ULONG CollectionNumber, IN ULONG ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PLONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength); + +ULONG +HidParser_GetCollectionNumberFromParserContext( + IN PHID_PARSER Parser); +