[HIDPARSE]
[reactos.git] / lib / drivers / hidparser / hidparser.c
index 21b357e..2e78d46 100644 (file)
@@ -51,11 +51,12 @@ HidParser_GetCollectionDescription(
     HIDPARSER_STATUS ParserStatus;
     ULONG CollectionCount;
     ULONG Index;
+    PVOID ParserContext;
 
     //
     // first parse the report descriptor
     //
-    ParserStatus = HidParser_ParseReportDescriptor(Parser, ReportDesc, DescLength);
+    ParserStatus = HidParser_ParseReportDescriptor(Parser, ReportDesc, DescLength, &ParserContext);
     if (ParserStatus != HIDPARSER_STATUS_SUCCESS)
     {
         //
@@ -68,17 +69,13 @@ HidParser_GetCollectionDescription(
     //
     // get collection count
     //
-    CollectionCount = HidParser_NumberOfTopCollections(Parser);
-
-    //
-    // FIXME: only one top level collection is supported
-    //
-    ASSERT(CollectionCount <= 1);
+    CollectionCount = HidParser_NumberOfTopCollections(ParserContext);
     if (CollectionCount == 0)
     {
         //
         // no top level collections found
         //
+        ASSERT(FALSE);
         return STATUS_NO_DATA_DETECTED;
     }
 
@@ -114,14 +111,27 @@ HidParser_GetCollectionDescription(
 
     for(Index = 0; Index < CollectionCount; Index++)
     {
+        //
+        // set preparsed data length
+        //
+        DeviceDescription->CollectionDesc[Index].PreparsedDataLength = HidParser_GetContextSize(Parser, ParserContext, Index);
+        ParserStatus = HidParser_BuildContext(Parser, ParserContext, Index, DeviceDescription->CollectionDesc[Index].PreparsedDataLength, (PVOID*)&DeviceDescription->CollectionDesc[Index].PreparsedData);
+        if (ParserStatus != HIDPARSER_STATUS_SUCCESS)
+        {
+            //
+            // no memory
+            //
+            return TranslateHidParserStatus(ParserStatus);
+        }
+
         //
         // init report description
         //
         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((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_INPUT);
+        DeviceDescription->ReportIDs[Index].OutputLength = HidParser_GetReportLength((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_OUTPUT);
+        DeviceDescription->ReportIDs[Index].FeatureLength = HidParser_GetReportLength((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, HID_REPORT_TYPE_FEATURE);
 
         //
         // init collection description
@@ -131,7 +141,7 @@ HidParser_GetCollectionDescription(
         //
         // get collection usage page
         //
-        ParserStatus = HidParser_GetCollectionUsagePage(Parser, Index, &DeviceDescription->CollectionDesc[Index].Usage, &DeviceDescription->CollectionDesc[Index].UsagePage);
+        ParserStatus = HidParser_GetCollectionUsagePage((PVOID)DeviceDescription->CollectionDesc[Index].PreparsedData, &DeviceDescription->CollectionDesc[Index].Usage, &DeviceDescription->CollectionDesc[Index].UsagePage);
 
         //
         // windows seems to prepend the report id, regardless if it is required
@@ -139,24 +149,6 @@ HidParser_GetCollectionDescription(
         DeviceDescription->CollectionDesc[Index].InputLength = (DeviceDescription->ReportIDs[Index].InputLength > 0 ? DeviceDescription->ReportIDs[Index].InputLength + 1 : 0);
         DeviceDescription->CollectionDesc[Index].OutputLength = (DeviceDescription->ReportIDs[Index].OutputLength > 0 ? DeviceDescription->ReportIDs[Index].OutputLength + 1 : 0);
         DeviceDescription->CollectionDesc[Index].FeatureLength = (DeviceDescription->ReportIDs[Index].FeatureLength > 0 ? DeviceDescription->ReportIDs[Index].FeatureLength + 1 : 0);
-
-        //
-        // set preparsed data length
-        //
-        DeviceDescription->CollectionDesc[Index].PreparsedDataLength = HidParser_GetContextSize(Parser);
-        DeviceDescription->CollectionDesc[Index].PreparsedData = Parser->Alloc(DeviceDescription->CollectionDesc[Index].PreparsedDataLength);
-        if (!DeviceDescription->CollectionDesc[Index].PreparsedData)
-        {
-            //
-            // no memory
-            //
-            return STATUS_INSUFFICIENT_RESOURCES;
-        }
-
-        //
-        // copy context
-        //
-        Parser->Copy(DeviceDescription->CollectionDesc[Index].PreparsedData, Parser->ParserContext, DeviceDescription->CollectionDesc[Index].PreparsedDataLength);
     }
 
     //
@@ -185,9 +177,9 @@ HidParser_FreeCollectionDescription(
     for(Index = 0; Index < DeviceDescription->CollectionDescLength; Index++)
     {
         //
-        // free parser context
+        // free collection context
         //
-        HidParser_FreeContext(Parser, (PUCHAR)DeviceDescription->CollectionDesc[Index].PreparsedData, DeviceDescription->CollectionDesc[Index].PreparsedDataLength);
+        Parser->Free(DeviceDescription->CollectionDesc[Index].PreparsedData);
     }
 
     //
@@ -206,26 +198,21 @@ NTSTATUS
 NTAPI
 HidParser_GetCaps(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     OUT PHIDP_CAPS  Capabilities)
 {
-    ULONG CollectionNumber;
     //
     // 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);
+    HidParser_GetCollectionUsagePage(CollectionContext, &Capabilities->Usage, &Capabilities->UsagePage);
+    Capabilities->InputReportByteLength = HidParser_GetReportLength(CollectionContext, HID_REPORT_TYPE_INPUT);
+    Capabilities->OutputReportByteLength = HidParser_GetReportLength(CollectionContext, HID_REPORT_TYPE_OUTPUT);
+    Capabilities->FeatureReportByteLength = HidParser_GetReportLength(CollectionContext, HID_REPORT_TYPE_FEATURE);
 
     //
     // always pre-prend report id
@@ -237,29 +224,29 @@ HidParser_GetCaps(
     //
     // get number of link collection nodes
     //
-    Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(Parser);
+    Capabilities->NumberLinkCollectionNodes = HidParser_GetTotalCollectionCount(CollectionContext);
 
     //
     // 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(CollectionContext, HID_REPORT_TYPE_INPUT, TRUE);
+    Capabilities->NumberOutputDataIndices = HidParser_GetReportItemTypeCountFromReportType(CollectionContext, HID_REPORT_TYPE_OUTPUT, TRUE);
+    Capabilities->NumberFeatureDataIndices = HidParser_GetReportItemTypeCountFromReportType(CollectionContext, 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(CollectionContext, HID_REPORT_TYPE_INPUT, FALSE);
+    Capabilities->NumberOutputValueCaps = HidParser_GetReportItemTypeCountFromReportType(CollectionContext, HID_REPORT_TYPE_OUTPUT, FALSE);
+    Capabilities->NumberFeatureValueCaps = HidParser_GetReportItemTypeCountFromReportType(CollectionContext, 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(CollectionContext, HID_REPORT_TYPE_INPUT);
+    Capabilities->NumberOutputButtonCaps = HidParser_GetReportItemCountFromReportType(CollectionContext, HID_REPORT_TYPE_OUTPUT);
+    Capabilities->NumberFeatureButtonCaps = HidParser_GetReportItemCountFromReportType(CollectionContext, HID_REPORT_TYPE_FEATURE);
 
     //
     // done
@@ -272,6 +259,7 @@ ULONG
 NTAPI
 HidParser_MaxUsageListLength(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USAGE  UsagePage  OPTIONAL)
 {
@@ -296,21 +284,21 @@ HidParser_MaxUsageListLength(
         //
         // input report
         //
-        return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_INPUT, UsagePage);
+        return HidParser_GetMaxUsageListLengthWithReportAndPage(CollectionContext, HID_REPORT_TYPE_INPUT, UsagePage);
     }
     else if (ReportType == HidP_Output)
     {
         //
         // input report
         //
-        return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_OUTPUT, UsagePage);
+        return HidParser_GetMaxUsageListLengthWithReportAndPage(CollectionContext, HID_REPORT_TYPE_OUTPUT, UsagePage);
     }
     else if (ReportType == HidP_Feature)
     {
         //
         // input report
         //
-        return HidParser_GetMaxUsageListLengthWithReportAndPage(Parser, HID_REPORT_TYPE_FEATURE, UsagePage);
+        return HidParser_GetMaxUsageListLengthWithReportAndPage(CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage);
     }
     else
     {
@@ -328,11 +316,12 @@ NTSTATUS
 NTAPI
 HidParser_GetButtonCaps(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE ReportType,
     IN PHIDP_BUTTON_CAPS ButtonCaps,
     IN PUSHORT ButtonCapsLength)
 {
-    return HidParser_GetSpecificButtonCaps(Parser, ReportType, HID_USAGE_PAGE_UNDEFINED, HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_PAGE_UNDEFINED, ButtonCaps, (PULONG)ButtonCapsLength);
+    return HidParser_GetSpecificButtonCaps(Parser, CollectionContext, ReportType, HID_USAGE_PAGE_UNDEFINED, HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_PAGE_UNDEFINED, ButtonCaps, (PULONG)ButtonCapsLength);
 }
 
 HIDAPI
@@ -340,6 +329,7 @@ NTSTATUS
 NTAPI
 HidParser_GetSpecificValueCaps(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USAGE  UsagePage,
     IN USHORT  LinkCollection,
@@ -359,21 +349,21 @@ HidParser_GetSpecificValueCaps(
         //
         // input report
         //
-        ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, Usage, ValueCaps, ValueCapsLength);
+        ParserStatus = HidParser_GetSpecificValueCapsWithReport(Parser, CollectionContext, 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, CollectionContext, 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, CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage, Usage, ValueCaps, ValueCapsLength);
     }
     else
     {
@@ -532,6 +522,7 @@ NTSTATUS
 NTAPI
 HidParser_GetUsages(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USAGE  UsagePage,
     IN USHORT  LinkCollection  OPTIONAL,
@@ -552,21 +543,21 @@ HidParser_GetUsages(
         //
         // input report
         //
-        ParserStatus = HidParser_GetUsagesWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, UsageList, UsageLength, Report, ReportLength);
+        ParserStatus = HidParser_GetUsagesWithReport(Parser, CollectionContext, 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, CollectionContext, 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, CollectionContext, HID_REPORT_TYPE_FEATURE, UsagePage, UsageList, UsageLength, Report, ReportLength);
     }
     else
     {
@@ -595,6 +586,7 @@ NTSTATUS
 NTAPI
 HidParser_GetScaledUsageValue(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USAGE  UsagePage,
     IN USHORT  LinkCollection  OPTIONAL,
@@ -615,21 +607,21 @@ HidParser_GetScaledUsageValue(
         //
         // input report
         //
-        ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, HID_REPORT_TYPE_INPUT, UsagePage, Usage, UsageValue, Report, ReportLength);
+        ParserStatus = HidParser_GetScaledUsageValueWithReport(Parser, CollectionContext, 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, CollectionContext, 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, CollectionContext, HID_REPORT_TYPE_FEATURE,  UsagePage, Usage, UsageValue, Report, ReportLength);
     }
     else
     {
@@ -678,9 +670,7 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes(
             //
             // process usage
             //
-            //Status = HidParser_TranslateUsage(Parser, ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
-                       UNIMPLEMENTED
-                       Status = HIDPARSER_STATUS_NOT_IMPLEMENTED;
+            Status = HidParser_TranslateUsage(Parser, ChangedUsageList[Index].Usage, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
         }
         else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER)
         {
@@ -693,9 +683,8 @@ HidParser_TranslateUsageAndPagesToI8042ScanCodes(
         else
         {
             //
-            // invalid page
+            // invalid page / end of usage list page
             //
-            DPRINT1("[HIDPARSE] Error unexpected usage page %x\n", ChangedUsageList[Index].UsagePage);
             return HIDP_STATUS_I8042_TRANS_UNKNOWN;
         }
 
@@ -731,6 +720,7 @@ NTSTATUS
 NTAPI
 HidParser_GetUsagesEx(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USHORT  LinkCollection,
     OUT PUSAGE_AND_PAGE  ButtonList,
@@ -738,7 +728,7 @@ HidParser_GetUsagesEx(
     IN PCHAR  Report,
     IN ULONG  ReportLength)
 {
-    return HidParser_GetUsages(Parser, ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, (PUSAGE)ButtonList, UsageLength, Report, ReportLength);
+    return HidParser_GetUsages(Parser, CollectionContext, ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, (PUSAGE)ButtonList, UsageLength, Report, ReportLength);
 }
 
 HIDAPI
@@ -875,6 +865,7 @@ NTSTATUS
 NTAPI
 HidParser_GetSpecificButtonCaps(
     IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     IN HIDP_REPORT_TYPE  ReportType,
     IN USAGE  UsagePage,
     IN USHORT  LinkCollection,
@@ -892,12 +883,13 @@ 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 PVOID CollectionContext,
+    IN HIDP_REPORT_TYPE  ReportType,
+    OUT PHIDP_DATA  DataList,
+    IN OUT PULONG  DataLength,
+    IN PCHAR  Report,
+    IN ULONG  ReportLength)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
@@ -908,11 +900,12 @@ 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 PVOID CollectionContext,
+    IN HIDP_REPORT_TYPE  ReportType,
+    IN USHORT  DataIndex,
+    OUT PHIDP_EXTENDED_ATTRIBUTES  Attributes,
+    IN OUT PULONG  LengthAttributes)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
@@ -923,9 +916,10 @@ HIDAPI
 NTSTATUS
 NTAPI
 HidParser_GetLinkCollectionNodes(
+    IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     OUT PHIDP_LINK_COLLECTION_NODE  LinkCollectionNodes,
-    IN OUT PULONG  LinkCollectionNodesLength,
-    IN PHIDP_PREPARSED_DATA  PreparsedData)
+    IN OUT PULONG  LinkCollectionNodesLength)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
@@ -936,27 +930,28 @@ 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 PVOID CollectionContext,
+    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 PVOID CollectionContext,
     IN PCHAR HidPacket,
     IN USHORT HidPacketLength,
-    IN PHIDP_PREPARSED_DATA Ppd,
     OUT PULONG OutputBuffer)
 {
     UNIMPLEMENTED
@@ -967,7 +962,8 @@ HidParser_SysPowerEvent (
 NTSTATUS
 NTAPI
 HidParser_SysPowerCaps (
-    IN PHIDP_PREPARSED_DATA Ppd,
+    IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
     OUT PULONG OutputBuffer)
 {
     UNIMPLEMENTED
@@ -979,15 +975,16 @@ 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 PVOID CollectionContext,
+    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);
@@ -998,14 +995,15 @@ 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 PVOID CollectionContext,
+    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);
@@ -1032,14 +1030,15 @@ 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 PVOID CollectionContext,
+    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);
@@ -1050,15 +1049,16 @@ 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 PVOID CollectionContext,
+    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);
@@ -1069,14 +1069,15 @@ 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 PVOID CollectionContext,
+    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);
@@ -1087,14 +1088,15 @@ 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 PVOID CollectionContext,
+    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);
@@ -1105,12 +1107,13 @@ 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 PVOID CollectionContext,
+    IN HIDP_REPORT_TYPE  ReportType,
+    IN PHIDP_DATA  DataList,
+    IN OUT PULONG  DataLength,
+    IN OUT PCHAR  Report,
+    IN ULONG  ReportLength)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
@@ -1121,23 +1124,25 @@ HIDAPI
 ULONG
 NTAPI
 HidParser_MaxDataListLength(
-  IN HIDP_REPORT_TYPE  ReportType,
-  IN PHIDP_PREPARSED_DATA  PreparsedData)
+    IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
+    IN HIDP_REPORT_TYPE  ReportType)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
-    return STATUS_NOT_IMPLEMENTED;
+    return 0;
 }
 
 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 PVOID CollectionContext,
+    IN HIDP_REPORT_TYPE  ReportType,
+    IN UCHAR  ReportID,
+    IN OUT PCHAR  Report,
+    IN ULONG  ReportLength)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);
@@ -1150,10 +1155,11 @@ HIDAPI
 NTSTATUS
 NTAPI
 HidParser_GetValueCaps(
-  HIDP_REPORT_TYPE ReportType,
-  PHIDP_VALUE_CAPS ValueCaps,
-  PULONG ValueCapsLength,
-  PHIDP_PREPARSED_DATA PreparsedData)
+    IN PHID_PARSER Parser,
+    IN PVOID CollectionContext,
+    HIDP_REPORT_TYPE ReportType,
+    PHIDP_VALUE_CAPS ValueCaps,
+    PULONG ValueCapsLength)
 {
     UNIMPLEMENTED
     ASSERT(FALSE);