--- /dev/null
+/*++\r
+\r
+Copyright (c) 1996-1998 Microsoft Corporation\r
+\r
+Module Name:\r
+\r
+ HIDPI.H\r
+\r
+Abstract:\r
+\r
+ Public Interface to the HID parsing library.\r
+\r
+Environment:\r
+\r
+ Kernel & user mode\r
+\r
+--*/\r
+\r
+#ifndef __HIDPI_H__\r
+#define __HIDPI_H__\r
+\r
+#include <pshpack4.h>\r
+\r
+// Please include "hidsdi.h" to use the user space (dll / parser)\r
+// Please include "hidpddi.h" to use the kernel space parser\r
+\r
+//\r
+// Special Link collection values for using the query functions\r
+//\r
+// Root collection references the collection at the base of the link\r
+// collection tree.\r
+// Unspecifies, references all collections in the link collection tree.\r
+//\r
+#define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)\r
+#define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)\r
+\r
+\r
+typedef enum _HIDP_REPORT_TYPE\r
+{\r
+ HidP_Input,\r
+ HidP_Output,\r
+ HidP_Feature\r
+} HIDP_REPORT_TYPE;\r
+\r
+typedef struct _USAGE_AND_PAGE\r
+{\r
+ USAGE Usage;\r
+ USAGE UsagePage;\r
+} USAGE_AND_PAGE, *PUSAGE_AND_PAGE;\r
+\r
+#define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))\r
+\r
+typedef struct _HIDP_BUTTON_CAPS\r
+{\r
+ USAGE UsagePage;\r
+ UCHAR ReportID;\r
+ BOOLEAN IsAlias;\r
+\r
+ USHORT BitField;\r
+ USHORT LinkCollection; // A unique internal index pointer\r
+\r
+ USAGE LinkUsage;\r
+ USAGE LinkUsagePage;\r
+\r
+ BOOLEAN IsRange;\r
+ BOOLEAN IsStringRange;\r
+ BOOLEAN IsDesignatorRange;\r
+ BOOLEAN IsAbsolute;\r
+\r
+ ULONG Reserved[10];\r
+ union {\r
+ struct {\r
+ USAGE UsageMin, UsageMax;\r
+ USHORT StringMin, StringMax;\r
+ USHORT DesignatorMin, DesignatorMax;\r
+ USHORT DataIndexMin, DataIndexMax;\r
+ } Range;\r
+ struct {\r
+ USAGE Usage, Reserved1;\r
+ USHORT StringIndex, Reserved2;\r
+ USHORT DesignatorIndex, Reserved3;\r
+ USHORT DataIndex, Reserved4;\r
+ } NotRange;\r
+ };\r
+\r
+} HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;\r
+\r
+\r
+typedef struct _HIDP_VALUE_CAPS\r
+{\r
+ USAGE UsagePage;\r
+ UCHAR ReportID;\r
+ BOOLEAN IsAlias;\r
+\r
+ USHORT BitField;\r
+ USHORT LinkCollection; // A unique internal index pointer\r
+\r
+ USAGE LinkUsage;\r
+ USAGE LinkUsagePage;\r
+\r
+ BOOLEAN IsRange;\r
+ BOOLEAN IsStringRange;\r
+ BOOLEAN IsDesignatorRange;\r
+ BOOLEAN IsAbsolute;\r
+\r
+ BOOLEAN HasNull; // Does this channel have a null report union\r
+ UCHAR Reserved;\r
+ USHORT BitSize; // How many bits are devoted to this value?\r
+\r
+ USHORT ReportCount; // See Note below. Usually set to 1.\r
+ USHORT Reserved2[5];\r
+\r
+ ULONG UnitsExp;\r
+ ULONG Units;\r
+\r
+ LONG LogicalMin, LogicalMax;\r
+ LONG PhysicalMin, PhysicalMax;\r
+\r
+ union {\r
+ struct {\r
+ USAGE UsageMin, UsageMax;\r
+ USHORT StringMin, StringMax;\r
+ USHORT DesignatorMin, DesignatorMax;\r
+ USHORT DataIndexMin, DataIndexMax;\r
+ } Range;\r
+\r
+ struct {\r
+ USAGE Usage, Reserved1;\r
+ USHORT StringIndex, Reserved2;\r
+ USHORT DesignatorIndex, Reserved3;\r
+ USHORT DataIndex, Reserved4;\r
+ } NotRange;\r
+ };\r
+} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;\r
+\r
+//\r
+// Notes:\r
+//\r
+// ReportCount: When a report descriptor declares an Input, Output, or\r
+// Feature main item with fewer usage declarations than the report count, then\r
+// the last usage applies to all remaining unspecified count in that main item.\r
+// (As an example you might have data that required many fields to describe,\r
+// possibly buffered bytes.) In this case, only one value cap structure is\r
+// allocated for these associtated fields, all with the same usage, and Report\r
+// Count reflects the number of fields involved. Normally ReportCount is 1.\r
+// To access all of the fields in such a value structure would require using\r
+// HidP_GetUsageValueArray and HidP_SetUsageValueArray. HidP_GetUsageValue/\r
+// HidP_SetScaledUsageValue will also work, however, these functions will only\r
+// work with the first field of the structure.\r
+//\r
+\r
+//\r
+// The link collection tree consists of an array of LINK_COLLECTION_NODES\r
+// where the index into this array is the same as the collection number.\r
+//\r
+// Given a collection A which contains a subcollection B, A is defined to be\r
+// the parent B, and B is defined to be the child.\r
+//\r
+// Given collections A, B, and C where B and C are children of A, and B was\r
+// encountered before C in the report descriptor, B is defined as a sibling of\r
+// C. (This implies, of course, that if B is a sibling of C, then C is NOT a\r
+// sibling of B).\r
+//\r
+// B is defined as the NextSibling of C if and only if there exists NO\r
+// child collection of A, call it D, such that B is a sibling of D and D\r
+// is a sibling of C.\r
+//\r
+// E is defined to be the FirstChild of A if and only if for all children of A,\r
+// F, that are not equivalent to E, F is a sibling of E.\r
+// (This implies, of course, that the does not exist a child of A, call it G,\r
+// where E is a sibling of G). In other words the first sibling is the last\r
+// link collection found in the list.\r
+//\r
+// In other words, if a collection B is defined within the definition of another\r
+// collection A, B becomes a child of A. All collections with the same parent\r
+// are considered siblings. The FirstChild of the parent collection, A, will be\r
+// last collection defined that has A as a parent. The order of sibling pointers\r
+// is similarly determined. When a collection B is defined, it becomes the\r
+// FirstChild of it's parent collection. The previously defined FirstChild of the\r
+// parent collection becomes the NextSibling of the new collection. As new\r
+// collections with the same parent are discovered, the chain of sibling is built.\r
+//\r
+// With that in mind, the following describes conclusively a data structure\r
+// that provides direct traversal up, down, and accross the link collection\r
+// tree.\r
+//\r
+//\r
+typedef struct _HIDP_LINK_COLLECTION_NODE\r
+{\r
+ USAGE LinkUsage;\r
+ USAGE LinkUsagePage;\r
+ USHORT Parent;\r
+ USHORT NumberOfChildren;\r
+ USHORT NextSibling;\r
+ USHORT FirstChild;\r
+ ULONG CollectionType: 8; // As defined in 6.2.2.6 of HID spec\r
+ ULONG IsAlias : 1; // This link node is an allias of the next link node.\r
+ ULONG Reserved: 23;\r
+ PVOID UserContext; // The user can hang his coat here.\r
+} HIDP_LINK_COLLECTION_NODE, *PHIDP_LINK_COLLECTION_NODE;\r
+\r
+//\r
+// When a link collection is described by a delimiter, alias link collection\r
+// nodes are created. (One for each usage within the delimiter).\r
+// The parser assigns each capability description listed above only one\r
+// link collection.\r
+//\r
+// If a control is defined within a collection defined by\r
+// delimited usages, then that control is said to be within multiple link\r
+// collections, one for each usage within the open and close delimiter tokens.\r
+// Such multiple link collecions are said to be aliases. The first N-1 such\r
+// collections, listed in the link collection node array, have their IsAlias\r
+// bit set. The last such link collection is the link collection index used\r
+// in the capabilities described above.\r
+// Clients wishing to set a control in an aliased collection, should walk the\r
+// collection array once for each time they see the IsAlias flag set, and use\r
+// the last link collection as the index for the below accessor functions.\r
+//\r
+// NB: if IsAlias is set, then NextSibling should be one more than the current\r
+// link collection node index.\r
+//\r
+\r
+typedef PUCHAR PHIDP_REPORT_DESCRIPTOR;\r
+typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;\r
+\r
+typedef struct _HIDP_CAPS\r
+{\r
+ USAGE Usage;\r
+ USAGE UsagePage;\r
+ USHORT InputReportByteLength;\r
+ USHORT OutputReportByteLength;\r
+ USHORT FeatureReportByteLength;\r
+ USHORT Reserved[17];\r
+\r
+ USHORT NumberLinkCollectionNodes;\r
+\r
+ USHORT NumberInputButtonCaps;\r
+ USHORT NumberInputValueCaps;\r
+ USHORT NumberInputDataIndices;\r
+\r
+ USHORT NumberOutputButtonCaps;\r
+ USHORT NumberOutputValueCaps;\r
+ USHORT NumberOutputDataIndices;\r
+\r
+ USHORT NumberFeatureButtonCaps;\r
+ USHORT NumberFeatureValueCaps;\r
+ USHORT NumberFeatureDataIndices;\r
+} HIDP_CAPS, *PHIDP_CAPS;\r
+\r
+typedef struct _HIDP_DATA\r
+{\r
+ USHORT DataIndex;\r
+ USHORT Reserved;\r
+ union {\r
+ ULONG RawValue; // for values\r
+ BOOLEAN On; // for buttons MUST BE TRUE for buttons.\r
+ };\r
+} HIDP_DATA, *PHIDP_DATA;\r
+//\r
+// The HIDP_DATA structure is used with HidP_GetData and HidP_SetData\r
+// functions.\r
+//\r
+// The parser contiguously assigns every control (button or value) in a hid\r
+// device a unique data index from zero to NumberXXXDataIndices -1 , inclusive.\r
+// This value is found in the HIDP_BUTTON_CAPS and HIDP_VALUE_CAPS structures.\r
+//\r
+// Most clients will find the Get/Set Buttons / Value accessor functions\r
+// sufficient to their needs, as they will allow the clients to access the\r
+// data known to them while ignoring the other controls.\r
+//\r
+// More complex clients, which actually read the Button / Value Caps, and which\r
+// do a value add service to these routines (EG Direct Input), will need to\r
+// access all the data in the device without interest in the individual usage\r
+// or link collection location. These are the clients that will find\r
+// HidP_Data useful.\r
+//\r
+\r
+typedef struct _HIDP_UNKNOWN_TOKEN\r
+{\r
+ UCHAR Token;\r
+ UCHAR Reserved[3];\r
+ ULONG BitField;\r
+} HIDP_UNKNOWN_TOKEN, *PHIDP_UNKNOWN_TOKEN;\r
+\r
+typedef struct _HIDP_EXTENDED_ATTRIBUTES\r
+{\r
+ UCHAR NumGlobalUnknowns;\r
+ UCHAR Reserved [3];\r
+ PHIDP_UNKNOWN_TOKEN GlobalUnknowns;\r
+ // ... Additional attributes\r
+ ULONG Data [1]; // variableLength DO NOT ACCESS THIS FIELD\r
+} HIDP_EXTENDED_ATTRIBUTES, *PHIDP_EXTENDED_ATTRIBUTES;\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetCaps (\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ OUT PHIDP_CAPS Capabilities\r
+ );\r
+/*++\r
+Routine Description:\r
+ Returns a list of capabilities of a given hid device as described by its\r
+ preparsed data.\r
+\r
+Arguments:\r
+ PreparsedData The preparsed data returned from HIDCLASS.\r
+ Capabilities a HIDP_CAPS structure\r
+\r
+Return Value:\r
+· HIDP_STATUS_SUCCESS\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetLinkCollectionNodes (\r
+ OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,\r
+ IN OUT PULONG LinkCollectionNodesLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+ );\r
+/*++\r
+Routine Description:\r
+ Return a list of PHIDP_LINK_COLLECTION_NODEs used to describe the link\r
+ collection tree of this hid device. See the above description of\r
+ struct _HIDP_LINK_COLLECTION_NODE.\r
+\r
+Arguments:\r
+ LinkCollectionNodes - a caller allocated array into which\r
+ HidP_GetLinkCollectionNodes will store the information\r
+\r
+ LinKCollectionNodesLength - the caller sets this value to the length of the\r
+ the array in terms of number of elements.\r
+ HidP_GetLinkCollectionNodes sets this value to the actual\r
+ number of elements set. The total number of nodes required to\r
+ describe this HID device can be found in the\r
+ NumberLinkCollectionNodes field in the HIDP_CAPS structure.\r
+\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetButtonCaps (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ OUT PHIDP_BUTTON_CAPS ButtonCaps,\r
+ IN OUT PUSHORT ButtonCapsLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+);\r
+#define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \\r
+ HidP_GetSpecificButtonCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)\r
+NTSTATUS __stdcall\r
+HidP_GetSpecificButtonCaps (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage, // Optional (0 => ignore)\r
+ IN USHORT LinkCollection, // Optional (0 => ignore)\r
+ IN USAGE Usage, // Optional (0 => ignore)\r
+ OUT PHIDP_BUTTON_CAPS ButtonCaps,\r
+ IN OUT PUSHORT ButtonCapsLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+ );\r
+/*++\r
+Description:\r
+ HidP_GetButtonCaps returns all the buttons (binary values) that are a part\r
+ of the given report type for the Hid device represented by the given\r
+ preparsed data.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ UsagePage A usage page value used to limit the button caps returned to\r
+ those on a given usage page. If set to 0, this parameter is\r
+ ignored. Can be used with LinkCollection and Usage parameters\r
+ to further limit the number of button caps structures returned.\r
+\r
+ LinkCollection HIDP_LINK_COLLECTION node array index used to limit the\r
+ button caps returned to those buttons in a given link\r
+ collection. If set to 0, this parameter is\r
+ ignored. Can be used with UsagePage and Usage parameters\r
+ to further limit the number of button caps structures\r
+ returned.\r
+\r
+ Usage A usage value used to limit the button caps returned to those\r
+ with the specified usage value. If set to 0, this parameter\r
+ is ignored. Can be used with LinkCollection and UsagePage\r
+ parameters to further limit the number of button caps\r
+ structures returned.\r
+\r
+ ButtonCaps A _HIDP_BUTTON_CAPS array containing information about all the\r
+ binary values in the given report. This buffer is provided by\r
+ the caller.\r
+\r
+ ButtonLength As input, this parameter specifies the length of the\r
+ ButtonCaps parameter (array) in number of array elements.\r
+ As output, this value is set to indicate how many of those\r
+ array elements were filled in by the function. The maximum number of\r
+ button caps that can be returned is found in the HIDP_CAPS\r
+ structure. If HIDP_STATUS_BUFFER_TOO_SMALL is returned,\r
+ this value contains the number of array elements needed to\r
+ successfully complete the request.\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS.\r
+\r
+\r
+Return Value\r
+HidP_GetSpecificButtonCaps returns the following error codes:\r
+· HIDP_STATUS_SUCCESS.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA\r
+· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)\r
+· HIDP_STATUS_USAGE_NOT_FOUND\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetValueCaps (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ OUT PHIDP_VALUE_CAPS ValueCaps,\r
+ IN OUT PUSHORT ValueCapsLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+);\r
+#define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \\r
+ HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)\r
+NTSTATUS __stdcall\r
+HidP_GetSpecificValueCaps (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage, // Optional (0 => ignore)\r
+ IN USHORT LinkCollection, // Optional (0 => ignore)\r
+ IN USAGE Usage, // Optional (0 => ignore)\r
+ OUT PHIDP_VALUE_CAPS ValueCaps,\r
+ IN OUT PUSHORT ValueCapsLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+ );\r
+/*++\r
+Description:\r
+ HidP_GetValueCaps returns all the values (non-binary) that are a part\r
+ of the given report type for the Hid device represented by the given\r
+ preparsed data.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ UsagePage A usage page value used to limit the value caps returned to\r
+ those on a given usage page. If set to 0, this parameter is\r
+ ignored. Can be used with LinkCollection and Usage parameters\r
+ to further limit the number of value caps structures returned.\r
+\r
+ LinkCollection HIDP_LINK_COLLECTION node array index used to limit the\r
+ value caps returned to those buttons in a given link\r
+ collection. If set to 0, this parameter is\r
+ ignored. Can be used with UsagePage and Usage parameters\r
+ to further limit the number of value caps structures\r
+ returned.\r
+\r
+ Usage A usage value used to limit the value caps returned to those\r
+ with the specified usage value. If set to 0, this parameter\r
+ is ignored. Can be used with LinkCollection and UsagePage\r
+ parameters to further limit the number of value caps\r
+ structures returned.\r
+\r
+ ValueCaps A _HIDP_VALUE_CAPS array containing information about all the\r
+ non-binary values in the given report. This buffer is provided\r
+ by the caller.\r
+\r
+ ValueLength As input, this parameter specifies the length of the ValueCaps\r
+ parameter (array) in number of array elements. As output,\r
+ this value is set to indicate how many of those array elements\r
+ were filled in by the function. The maximum number of\r
+ value caps that can be returned is found in the HIDP_CAPS\r
+ structure. If HIDP_STATUS_BUFFER_TOO_SMALL is returned,\r
+ this value contains the number of array elements needed to\r
+ successfully complete the request.\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS.\r
+\r
+\r
+Return Value\r
+HidP_GetValueCaps returns the following error codes:\r
+· HIDP_STATUS_SUCCESS.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA\r
+· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)\r
+· HIDP_STATUS_USAGE_NOT_FOUND\r
+\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetExtendedAttributes (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USHORT DataIndex,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,\r
+ IN OUT PULONG LengthAttributes\r
+ );\r
+/*++\r
+Description:\r
+ Given a data index from the value or button capabilities of a given control\r
+ return any extended attributes for the control if any exist.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ DataIndex The data index for the given control, found in the capabilities\r
+ structure for that control\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS.\r
+\r
+ Attributes Pointer to a buffer into which the extended attribute data will\r
+ be copied.\r
+\r
+ LengthAttributes Length of the given buffer in bytes.\r
+\r
+Return Value\r
+ HIDP_STATUS_SUCCESS\r
+ HIDP_STATUS_DATA_INDEX_NOT_FOUND\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_InitializeReportForID (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN UCHAR ReportID,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize a report based on the given report ID.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ PreparasedData Preparsed data structure returned by HIDCLASS\r
+\r
+ Report Buffer which to set the data into.\r
+\r
+ ReportLength Length of Report...Report should be at least as long as the\r
+ value indicated in the HIDP_CAPS structure for the device and\r
+ the corresponding ReportType\r
+\r
+Return Value\r
+\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal\r
+ to the length specified in HIDP_CAPS\r
+ structure for the given ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_SetData (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN PHIDP_DATA DataList,\r
+ IN OUT PULONG DataLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Please Note: Since usage value arrays deal with multiple fields for\r
+ for one usage value, they cannot be used with HidP_SetData\r
+ and HidP_GetData. In this case,\r
+ HIDP_STATUS_IS_USAGE_VALUE_ARRAY will be returned.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ DataList Array of HIDP_DATA structures that contains the data values\r
+ that are to be set into the given report\r
+\r
+ DataLength As input, length in array elements of DataList. As output,\r
+ contains the number of data elements set on successful\r
+ completion or an index into the DataList array to identify\r
+ the faulting HIDP_DATA value if an error code is returned.\r
+\r
+ PreparasedData Preparsed data structure returned by HIDCLASS\r
+\r
+ Report Buffer which to set the data into.\r
+\r
+ ReportLength Length of Report...Report should be at least as long as the\r
+ value indicated in the HIDP_CAPS structure for the device and\r
+ the corresponding ReportType\r
+\r
+Return Value\r
+ HidP_SetData returns the following error codes. The report packet will\r
+ have all the data set up until the HIDP_DATA structure that caused the\r
+ error. DataLength, in the error case, will return this problem index.\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successful insertion of all data\r
+ into the report packet.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_DATA_INDEX_NOT_FOUND -- if a HIDP_DATA structure referenced a\r
+ data index that does not exist for this\r
+ device's ReportType\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal\r
+ to the length specified in HIDP_CAPS\r
+ structure for the given ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_IS_USAGE_VALUE_ARRAY -- if one of the HIDP_DATA structures\r
+ references a usage value array.\r
+ DataLength will contain the index into\r
+ the array that was invalid\r
+· HIDP_STATUS_BUTTON_NOT_PRESSED -- if a HIDP_DATA structure attempted\r
+ to unset a button that was not already\r
+ set in the Report\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- a HIDP_DATA structure was found with\r
+ a valid index value but is contained\r
+ in a different report than the one\r
+ currently being processed\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough entries in\r
+ a given Main Array Item to report all\r
+ buttons that have been requested to be\r
+ set\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetData (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ OUT PHIDP_DATA DataList,\r
+ IN OUT PULONG DataLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Please Note: For obvious reasons HidP_SetData and HidP_GetData will not\r
+ access UsageValueArrays.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output, or HidP_Feature.\r
+\r
+ DataList Array of HIDP_DATA structures that will receive the data\r
+ values that are set in the given report\r
+\r
+ DataLength As input, length in array elements of DataList. As output,\r
+ contains the number of data elements that were successfully\r
+ set by HidP_GetData. The maximum size necessary for DataList\r
+ can be determined by calling HidP_MaxDataListLength\r
+\r
+ PreparasedData Preparsed data structure returned by HIDCLASS\r
+\r
+ Report Buffer which to set the data into.\r
+\r
+ ReportLength Length of Report...Report should be at least as long as the\r
+ value indicated in the HIDP_CAPS structure for the device and\r
+ the corresponding ReportType\r
+\r
+Return Value\r
+ HidP_GetData returns the following error codes.\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successful retrieval of all data\r
+ from the report packet.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal\r
+ to the length specified in HIDP_CAPS\r
+ structure for the given ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough array entries in\r
+ DataList to store all the indice values\r
+ in the given report. DataLength will\r
+ contain the number of array entries\r
+ required to hold all data\r
+--*/\r
+\r
+ULONG __stdcall\r
+HidP_MaxDataListLength (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+ );\r
+/*++\r
+Routine Description:\r
+\r
+ This function returns the maximum length of HIDP_DATA elements that\r
+ HidP_GetData could return for the given report type.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ PreparsedData Preparsed data structure returned by HIDCLASS\r
+\r
+Return Value:\r
+\r
+ The length of the data list array required for the HidP_GetData function\r
+ call. If an error occurs (either HIDP_STATUS_INVALID_REPORT_TYPE or\r
+ HIDP_STATUS_INVALID_PREPARSED_DATA), this function returns 0.\r
+\r
+--*/\r
+\r
+#define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \\r
+ HidP_SetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)\r
+\r
+NTSTATUS __stdcall\r
+HidP_SetUsages (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN PUSAGE UsageList,\r
+ IN OUT PULONG UsageLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+ This function sets binary values (buttons) in a report. Given an\r
+ initialized packet of correct length, it modifies the report packet so that\r
+ each element in the given list of usages has been set in the report packet.\r
+ For example, in an output report with 5 LED\92s, each with a given usage,\r
+ an application could turn on any subset of these lights by placing their\r
+ usages in any order into the usage array (UsageList). HidP_SetUsages would,\r
+ in turn, set the appropriate bit or add the corresponding byte into the\r
+ HID Main Array Item.\r
+\r
+ A properly initialized Report packet is one of the correct byte length,\r
+ and all zeros.\r
+\r
+ NOTE: A packet that has already been set with a call to a HidP_Set routine\r
+ can also be passed in. This routine then sets processes the UsageList\r
+ in the same fashion but verifies that the ReportID already set in\r
+ Report matches the report ID for the given usages.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ UsagePage All of the usages in the usage array, which HidP_SetUsages will\r
+ set in the report, refer to this same usage page.\r
+ If a client wishes to set usages in a report for multiple\r
+ usage pages then that client needs to make multiple calls to\r
+ HidP_SetUsages for each of the usage pages.\r
+\r
+ UsageList A usage array containing the usages that HidP_SetUsages will set in\r
+ the report packet.\r
+\r
+ UsageLength The length of the given usage array in array elements.\r
+ The parser will set this value to the position in the usage\r
+ array where it stopped processing. If successful, UsageLength\r
+ will be unchanged. In any error condition, this parameter\r
+ reflects how many of the usages in the usage list have\r
+ actually been set by the parser. This is useful for finding\r
+ the usage in the list which caused the error.\r
+\r
+ PreparsedData The preparsed data recevied from HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length of the given report packet...Must be equal to the\r
+ value reported in the HIDP_CAPS structure for the device\r
+ and corresponding report type.\r
+\r
+Return Value\r
+ HidP_SetUsages returns the following error codes. On error, the report packet\r
+ will be correct up until the usage element that caused the error.\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successful insertion of all usages\r
+ into the report packet.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a\r
+ different report. If the report is\r
+ zero-initialized on entry the first\r
+ usage in the list will determine which\r
+ report ID is used. Otherwise, the\r
+ parser will verify that usage matches\r
+ the passed in report's ID\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any\r
+ report (no matter what the report ID)\r
+ for the given report type.\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough entries in a\r
+ given Main Array Item to list all of\r
+ the given usages. The caller needs\r
+ to split his request into more than\r
+ one call\r
+--*/\r
+\r
+#define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \\r
+ HidP_UnsetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)\r
+\r
+NTSTATUS __stdcall\r
+HidP_UnsetUsages (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN PUSAGE UsageList,\r
+ IN OUT PULONG UsageLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+ This function unsets (turns off) binary values (buttons) in the report. Given\r
+ an initialized packet of correct length, it modifies the report packet so\r
+ that each element in the given list of usages has been unset in the\r
+ report packet.\r
+\r
+ This function is the "undo" operation for SetUsages. If the given usage\r
+ is not already set in the Report, it will return an error code of\r
+ HIDP_STATUS_BUTTON_NOT_PRESSED. If the button is pressed, HidP_UnsetUsages\r
+ will unset the appropriate bit or remove the corresponding index value from\r
+ the HID Main Array Item.\r
+\r
+ A properly initialized Report packet is one of the correct byte length,\r
+ and all zeros..\r
+\r
+ NOTE: A packet that has already been set with a call to a HidP_Set routine\r
+ can also be passed in. This routine then processes the UsageList\r
+ in the same fashion but verifies that the ReportID already set in\r
+ Report matches the report ID for the given usages.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ UsagePage All of the usages in the usage array, which HidP_UnsetUsages will\r
+ unset in the report, refer to this same usage page.\r
+ If a client wishes to unset usages in a report for multiple\r
+ usage pages then that client needs to make multiple calls to\r
+ HidP_UnsetUsages for each of the usage pages.\r
+\r
+ UsageList A usage array containing the usages that HidP_UnsetUsages will\r
+ unset in the report packet.\r
+\r
+ UsageLength The length of the given usage array in array elements.\r
+ The parser will set this value to the position in the usage\r
+ array where it stopped processing. If successful, UsageLength\r
+ will be unchanged. In any error condition, this parameter\r
+ reflects how many of the usages in the usage list have\r
+ actually been unset by the parser. This is useful for finding\r
+ the usage in the list which caused the error.\r
+\r
+ PreparsedData The preparsed data recevied from HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length of the given report packet...Must be equal to the\r
+ value reported in the HIDP_CAPS structure for the device\r
+ and corresponding report type.\r
+\r
+Return Value\r
+ HidP_UnsetUsages returns the following error codes. On error, the report\r
+ packet will be correct up until the usage element that caused the error.\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successful "unsetting" of all usages\r
+ in the report packet.\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a\r
+ different report. If the report is\r
+ zero-initialized on entry the first\r
+ usage in the list will determine which\r
+ report ID is used. Otherwise, the\r
+ parser will verify that usage matches\r
+ the passed in report's ID\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any\r
+ report (no matter what the report ID)\r
+ for the given report type.\r
+· HIDP_STATUS_BUTTON_NOT_PRESSED -- if a usage corresponds to a button that\r
+ is not already set in the given report\r
+--*/\r
+\r
+#define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \\r
+ HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetUsages (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ OUT USAGE * UsageList,\r
+ IN OUT ULONG * UsageLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+\r
+Routine Description:\r
+ This function returns the binary values (buttons) that are set in a HID\r
+ report. Given a report packet of correct length, it searches the report\r
+ packet for each usage for the given usage page and returns them in the\r
+ usage list.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ UsagePage All of the usages in the usage list, which HidP_GetUsages will\r
+ retrieve in the report, refer to this same usage page.\r
+ If the client wishes to get usages in a packet for multiple\r
+ usage pages then that client needs to make multiple calls\r
+ to HidP_GetUsages.\r
+\r
+ LinkCollection An optional value which can limit which usages are returned\r
+ in the UsageList to those usages that exist in a specific\r
+ LinkCollection. A non-zero value indicates the index into\r
+ the HIDP_LINK_COLLECITON_NODE list returned by\r
+ HidP_GetLinkCollectionNodes of the link collection the\r
+ usage should belong to. A value of 0 indicates this\r
+ should value be ignored.\r
+\r
+ UsageList The usage array that will contain all the usages found in\r
+ the report packet.\r
+\r
+ UsageLength The length of the given usage array in array elements.\r
+ On input, this value describes the length of the usage list.\r
+ On output, HidP_GetUsages sets this value to the number of\r
+ usages that was found. Use HidP_MaxUsageListLength to\r
+ determine the maximum length needed to return all the usages\r
+ that a given report packet may contain.\r
+\r
+ PreparsedData Preparsed data structure returned by HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet\r
+\r
+\r
+Return Value\r
+ HidP_GetUsages returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully retrieving all the\r
+ usages from the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if the UsageList is not big enough to\r
+ hold all the usages found in the report\r
+ packet. If this is returned, the buffer\r
+ will contain UsageLength number of\r
+ usages. Use HidP_MaxUsageListLength to\r
+ find the maximum length needed\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages\r
+ that match the UsagePage and\r
+ LinkCollection specified could be found\r
+ in a report with a different report ID\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in a reports for\r
+ the device and ReportType that match the\r
+ UsagePage and LinkCollection that were\r
+ specified\r
+--*/\r
+\r
+#define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe) \\r
+ HidP_GetUsagesEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetUsagesEx (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USHORT LinkCollection, // Optional\r
+ OUT PUSAGE_AND_PAGE ButtonList,\r
+ IN OUT ULONG * UsageLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+ This function returns the binary values (buttons) in a HID report.\r
+ Given a report packet of correct length, it searches the report packet\r
+ for all buttons and returns the UsagePage and Usage for each of the buttons\r
+ it finds.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ LinkCollection An optional value which can limit which usages are returned\r
+ in the ButtonList to those usages that exist in a specific\r
+ LinkCollection. A non-zero value indicates the index into\r
+ the HIDP_LINK_COLLECITON_NODE list returned by\r
+ HidP_GetLinkCollectionNodes of the link collection the\r
+ usage should belong to. A value of 0 indicates this\r
+ should value be ignored.\r
+\r
+ ButtonList An array of USAGE_AND_PAGE structures describing all the\r
+ buttons currently ``down'' in the device.\r
+\r
+ UsageLength The length of the given array in terms of elements.\r
+ On input, this value describes the length of the list. On\r
+ output, HidP_GetUsagesEx sets this value to the number of\r
+ usages that were found. Use HidP_MaxUsageListLength to\r
+ determine the maximum length needed to return all the usages\r
+ that a given report packet may contain.\r
+\r
+ PreparsedData Preparsed data returned by HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value\r
+ HidP_GetUsagesEx returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully retrieving all the\r
+ usages from the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if ButtonList is not big enough to\r
+ hold all the usages found in the report\r
+ packet. If this is returned, the buffer\r
+ will contain UsageLength number of\r
+ usages. Use HidP_MaxUsageListLength to\r
+ find the maximum length needed\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages\r
+ that match the specified LinkCollection\r
+ exist in report with a different report\r
+ ID.\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in any reports that\r
+ match the LinkCollection parameter\r
+--*/\r
+\r
+#define HidP_GetButtonListLength(RTy, UPa, Ppd) \\r
+ HidP_GetUsageListLength(Rty, UPa, Ppd)\r
+\r
+ULONG __stdcall\r
+HidP_MaxUsageListLength (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage, // Optional\r
+ IN PHIDP_PREPARSED_DATA PreparsedData\r
+ );\r
+/*++\r
+Routine Description:\r
+ This function returns the maximum number of usages that a call to\r
+ HidP_GetUsages or HidP_GetUsagesEx could return for a given HID report.\r
+ If calling for number of usages returned by HidP_GetUsagesEx, use 0 as\r
+ the UsagePage value.\r
+\r
+Parameters:\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ UsagePage Specifies the optional UsagePage to query for. If 0, will\r
+ return all the maximum number of usage values that could be\r
+ returned for a given ReportType. If non-zero, will return\r
+ the maximum number of usages that would be returned for the\r
+ ReportType with the given UsagePage.\r
+\r
+ PreparsedData Preparsed data returned from HIDCLASS\r
+\r
+Return Value:\r
+ The length of the usage list array required for the HidP_GetUsages or\r
+ HidP_GetUsagesEx function call. If an error occurs (such as\r
+ HIDP_STATUS_INVALID_REPORT_TYPE or HIDP_INVALID_PREPARSED_DATA, this\r
+ returns 0.\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_SetUsageValue (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ IN ULONG UsageValue,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+/*++\r
+Description:\r
+ HidP_SetUsageValue inserts a value into the HID Report Packet in the field\r
+ corresponding to the given usage page and usage. HidP_SetUsageValue\r
+ casts this value to the appropriate bit length. If a report packet\r
+ contains two different fields with the same Usage and UsagePage,\r
+ they can be distinguished with the optional LinkCollection field value.\r
+ Using this function sets the raw value into the report packet with\r
+ no checking done as to whether it actually falls within the logical\r
+ minimum/logical maximum range. Use HidP_SetScaledUsageValue for this...\r
+\r
+ NOTE: Although the UsageValue parameter is a ULONG, any casting that is\r
+ done will preserve or sign-extend the value. The value being set\r
+ should be considered a LONG value and will be treated as such by\r
+ this function.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Output or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will set the first field\r
+ it finds that matches the usage page and\r
+ usage.\r
+\r
+ Usage The usage whose value HidP_SetUsageValue will set.\r
+\r
+ UsageValue The raw value to set in the report buffer. This value must be within\r
+ the logical range or if a NULL value this value should be the\r
+ most negative value that can be represented by the number of bits\r
+ for this field.\r
+\r
+ PreparsedData The preparsed data returned for HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value:\r
+ HidP_SetUsageValue returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully setting the value\r
+ in the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call HidP_SetUsageValue\r
+ again with a zero-initizialed report\r
+ packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_SetScaledUsageValue (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ IN LONG UsageValue,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*++\r
+Description:\r
+ HidP_SetScaledUsageValue inserts the UsageValue into the HID report packet\r
+ in the field corresponding to the given usage page and usage. If a report\r
+ packet contains two different fields with the same Usage and UsagePage,\r
+ they can be distinguished with the optional LinkCollection field value.\r
+\r
+ If the specified field has a defined physical range, this function converts\r
+ the physical value specified to the corresponding logical value for the\r
+ report. If a physical value does not exist, the function will verify that\r
+ the value specified falls within the logical range and set according.\r
+\r
+ If the range checking fails but the field has NULL values, the function will\r
+ set the field to the defined NULL value (most negative number possible) and\r
+ return HIDP_STATUS_NULL. In other words, use this function to set NULL\r
+ values for a given field by passing in a value that falls outside the\r
+ physical range if it is defined or the logical range otherwise.\r
+\r
+ If the field does not support NULL values, an out of range error will be\r
+ returned instead.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Output or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will set the first field\r
+ it finds that matches the usage page and\r
+ usage.\r
+\r
+ Usage The usage whose value HidP_SetScaledUsageValue will set.\r
+\r
+ UsageValue The value to set in the report buffer. See the routine\r
+ description above for the different interpretations of this\r
+ value\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value:\r
+ HidP_SetScaledUsageValue returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully setting the value\r
+ in the report packet\r
+· HIDP_STATUS_NULL -- upon successfully setting the value\r
+ in the report packet as a NULL value\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_VALUE_OUT_OF_RANGE -- if the value specified failed to fall\r
+ within the physical range if it exists\r
+ or within the logical range otherwise\r
+ and the field specified by the usage\r
+ does not allow NULL values\r
+· HIDP_STATUS_BAD_LOG_PHY_VALUES -- if the field has a physical range but\r
+ either the logical range is invalid\r
+ (max <= min) or the physical range is\r
+ invalid\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call\r
+ HidP_SetScaledUsageValue again with\r
+ a zero-initialized report packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_SetUsageValueArray (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ IN PCHAR UsageValue,\r
+ IN USHORT UsageValueByteLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ OUT PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*++\r
+Routine Descripton:\r
+ A usage value array occurs when the last usage in the list of usages\r
+ describing a main item must be repeated because there are less usages defined\r
+ than there are report counts declared for the given main item. In this case\r
+ a single value cap is allocated for that usage and the report count of that\r
+ value cap is set to reflect the number of fields to which that usage refers.\r
+\r
+ HidP_SetUsageValueArray sets the raw bits for that usage which spans\r
+ more than one field in a report.\r
+\r
+ NOTE: This function currently does not support value arrays where the\r
+ ReportSize for each of the fields in the array is not a multiple\r
+ of 8 bits.\r
+\r
+ The UsageValue buffer should have the values set as they would appear\r
+ in the report buffer. If this function supported non 8-bit multiples\r
+ for the ReportSize then caller should format the input buffer so that\r
+ each new value begins at the bit immediately following the last bit\r
+ of the previous value\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Output or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will set the first field\r
+ it finds that matches the usage page and\r
+ usage.\r
+\r
+ Usage The usage whose value array HidP_SetUsageValueArray will set.\r
+\r
+ UsageValue The buffer with the values to set into the value array.\r
+ The number of BITS required is found by multiplying the\r
+ BitSize and ReportCount fields of the Value Cap for this\r
+ control. The least significant bit of this control found in the\r
+ given report will be placed in the least significan bit location\r
+ of the array given (little-endian format), regardless of whether\r
+ or not the field is byte alligned or if the BitSize is a multiple\r
+ of sizeof (CHAR).\r
+\r
+ See the above note for current implementation limitations.\r
+\r
+ UsageValueByteLength Length of the UsageValue buffer (in bytes)\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value:\r
+· HIDP_STATUS_SUCCESS -- upon successfully setting the value\r
+ array in the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_NOT_VALUE_ARRAY -- if the control specified is not a\r
+ value array -- a value array will have\r
+ a ReportCount field in the\r
+ HIDP_VALUE_CAPS structure that is > 1\r
+ Use HidP_SetUsageValue instead\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if the size of the passed in buffer with\r
+ the values to set is too small (ie. has\r
+ fewer values than the number of fields in\r
+ the array\r
+· HIDP_STATUS_NOT_IMPLEMENTED -- if the usage value array has field sizes\r
+ that are not multiples of 8 bits, this\r
+ error code is returned since the function\r
+ currently does not handle setting into\r
+ such arrays.\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call\r
+ HidP_SetUsageValueArray again with\r
+ a zero-initialized report packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetUsageValue (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ OUT PULONG UsageValue,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*\r
+Description\r
+ HidP_GetUsageValue retrieves the value from the HID Report for the usage\r
+ specified by the combination of usage page, usage and link collection.\r
+ If a report packet contains two different fields with the same\r
+ Usage and UsagePage, they can be distinguished with the optional\r
+ LinkCollection field value.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Input or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will set the first field\r
+ it finds that matches the usage page and\r
+ usage.\r
+\r
+ Usage The usage whose value HidP_GetUsageValue will retrieve\r
+\r
+ UsageValue The raw value that is set for the specified field in the report\r
+ buffer. This value will either fall within the logical range\r
+ or if NULL values are allowed, a number outside the range to\r
+ indicate a NULL\r
+\r
+ PreparsedData The preparsed data returned for HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value:\r
+ HidP_GetUsageValue returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value\r
+ from the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device\r
+ for the given ReportType\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call HidP_GetUsageValue\r
+ again with a different report packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetScaledUsageValue (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ OUT PLONG UsageValue,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*++\r
+Description\r
+ HidP_GetScaledUsageValue retrieves a UsageValue from the HID report packet\r
+ in the field corresponding to the given usage page and usage. If a report\r
+ packet contains two different fields with the same Usage and UsagePage,\r
+ they can be distinguished with the optional LinkCollection field value.\r
+\r
+ If the specified field has a defined physical range, this function converts\r
+ the logical value that exists in the report packet to the corresponding\r
+ physical value. If a physical range does not exist, the function will\r
+ return the logical value. This function will check to verify that the\r
+ logical value in the report falls within the declared logical range.\r
+\r
+ When doing the conversion between logical and physical values, this\r
+ function assumes a linear extrapolation between the physical max/min and\r
+ the logical max/min. (Where logical is the values reported by the device\r
+ and physical is the value returned by this function). If the data field\r
+ size is less than 32 bits, then HidP_GetScaledUsageValue will sign extend\r
+ the value to 32 bits.\r
+\r
+ If the range checking fails but the field has NULL values, the function\r
+ will set UsageValue to 0 and return HIDP_STATUS_NULL. Otherwise, it\r
+ returns a HIDP_STATUS_OUT_OF_RANGE error.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Output or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will retrieve the first\r
+ field it finds that matches the usage page\r
+ and usage.\r
+\r
+ Usage The usage whose value HidP_GetScaledUsageValue will retrieve\r
+\r
+ UsageValue The value retrieved from the report buffer. See the routine\r
+ description above for the different interpretations of this\r
+ value\r
+\r
+ PreparsedData The preparsed data returned from HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length (in bytes) of the given report packet.\r
+\r
+\r
+Return Value:\r
+ HidP_GetScaledUsageValue returns the following error codes:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value\r
+ from the report packet\r
+· HIDP_STATUS_NULL -- if the report packet had a NULL value\r
+ set\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_VALUE_OUT_OF_RANGE -- if the value retrieved from the packet\r
+ falls outside the logical range and\r
+ the field does not support NULL values\r
+· HIDP_STATUS_BAD_LOG_PHY_VALUES -- if the field has a physical range but\r
+ either the logical range is invalid\r
+ (max <= min) or the physical range is\r
+ invalid\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call\r
+ HidP_GetScaledUsageValue with a\r
+ different report packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_GetUsageValueArray (\r
+ IN HIDP_REPORT_TYPE ReportType,\r
+ IN USAGE UsagePage,\r
+ IN USHORT LinkCollection, // Optional\r
+ IN USAGE Usage,\r
+ OUT PCHAR UsageValue,\r
+ IN USHORT UsageValueByteLength,\r
+ IN PHIDP_PREPARSED_DATA PreparsedData,\r
+ IN PCHAR Report,\r
+ IN ULONG ReportLength\r
+ );\r
+\r
+/*++\r
+Routine Descripton:\r
+ A usage value array occurs when the last usage in the list of usages\r
+ describing a main item must be repeated because there are less usages defined\r
+ than there are report counts declared for the given main item. In this case\r
+ a single value cap is allocated for that usage and the report count of that\r
+ value cap is set to reflect the number of fields to which that usage refers.\r
+\r
+ HidP_GetUsageValueArray returns the raw bits for that usage which spans\r
+ more than one field in a report.\r
+\r
+ NOTE: This function currently does not support value arrays where the\r
+ ReportSize for each of the fields in the array is not a multiple\r
+ of 8 bits.\r
+\r
+ The UsageValue buffer will have the raw values as they are set\r
+ in the report packet.\r
+\r
+Parameters:\r
+\r
+ ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
+\r
+ UsagePage The usage page to which the given usage refers.\r
+\r
+ LinkCollection (Optional) This value can be used to differentiate\r
+ between two fields that may have the same\r
+ UsagePage and Usage but exist in different\r
+ collections. If the link collection value\r
+ is zero, this function will set the first field\r
+ it finds that matches the usage page and\r
+ usage.\r
+\r
+ Usage The usage whose value HidP_GetUsageValueArray will retreive.\r
+\r
+ UsageValue A pointer to an array of characters where the value will be\r
+ placed. The number of BITS required is found by multiplying the\r
+ BitSize and ReportCount fields of the Value Cap for this\r
+ control. The least significant bit of this control found in the\r
+ given report will be placed in the least significant bit location\r
+ of the buffer (little-endian format), regardless of whether\r
+ or not the field is byte aligned or if the BitSize is a multiple\r
+ of sizeof (CHAR).\r
+\r
+ See note above about current implementation limitations\r
+\r
+ UsageValueByteLength\r
+ the length of the given UsageValue buffer.\r
+\r
+ PreparsedData The preparsed data returned by the HIDCLASS\r
+\r
+ Report The report packet.\r
+\r
+ ReportLength Length of the given report packet.\r
+\r
+Return Value:\r
+\r
+· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value\r
+ from the report packet\r
+· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.\r
+· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
+· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not\r
+ equal to the length specified in\r
+ the HIDP_CAPS structure for the given\r
+ ReportType\r
+· HIDP_STATUS_NOT_VALUE_ARRAY -- if the control specified is not a\r
+ value array -- a value array will have\r
+ a ReportCount field in the\r
+ HIDP_VALUE_CAPS structure that is > 1\r
+ Use HidP_GetUsageValue instead\r
+· HIDP_STATUS_BUFFER_TOO_SMALL -- if the size of the passed in buffer in\r
+ which to return the array is too small\r
+ (ie. has fewer values than the number of\r
+ fields in the array\r
+· HIDP_STATUS_NOT_IMPLEMENTED -- if the usage value array has field sizes\r
+ that are not multiples of 8 bits, this\r
+ error code is returned since the function\r
+ currently does not handle getting values\r
+ from such arrays.\r
+· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
+ link collection exist but exists in\r
+ a report with a different report ID\r
+ than the report being passed in. To\r
+ set this value, call\r
+ HidP_GetUsageValueArray with a\r
+ different report packet\r
+· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link\r
+ collection combination does not exist\r
+ in any reports for this ReportType\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_UsageListDifference (\r
+ IN PUSAGE PreviousUsageList,\r
+ IN PUSAGE CurrentUsageList,\r
+ OUT PUSAGE BreakUsageList,\r
+ OUT PUSAGE MakeUsageList,\r
+ IN ULONG UsageListLength\r
+ );\r
+/*++\r
+Routine Description:\r
+ This function will return the difference between a two lists of usages\r
+ (as might be returned from HidP_GetUsages), In other words, it will return\r
+ return a list of usages that are in the current list but not the previous\r
+ list as well as a list of usages that are in the previous list but not\r
+ the current list.\r
+\r
+Parameters:\r
+\r
+ PreviousUsageList The list of usages before.\r
+ CurrentUsageList The list of usages now.\r
+ BreakUsageList Previous - Current.\r
+ MakeUsageList Current - Previous.\r
+ UsageListLength Represents the length of the usage lists in array\r
+ elements. If comparing two lists with a differing\r
+ number of array elements, this value should be\r
+ the size of the larger of the two lists. Any\r
+ zero found with a list indicates an early termination\r
+ of the list and any usages found after the first zero\r
+ will be ignored.\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_UsageAndPageListDifference (\r
+ IN PUSAGE_AND_PAGE PreviousUsageList,\r
+ IN PUSAGE_AND_PAGE CurrentUsageList,\r
+ OUT PUSAGE_AND_PAGE BreakUsageList,\r
+ OUT PUSAGE_AND_PAGE MakeUsageList,\r
+ IN ULONG UsageListLength\r
+ );\r
+\r
+//\r
+// Produce Make or Break Codes\r
+//\r
+typedef enum _HIDP_KEYBOARD_DIRECTION {\r
+ HidP_Keyboard_Break,\r
+ HidP_Keyboard_Make\r
+} HIDP_KEYBOARD_DIRECTION;\r
+\r
+//\r
+// A bitmap of the current shift state of the keyboard when using the\r
+// below keyboard usages to i8042 translation function.\r
+//\r
+typedef struct _HIDP_KEYBOARD_MODIFIER_STATE {\r
+ union {\r
+ struct {\r
+ ULONG LeftControl: 1;\r
+ ULONG LeftShift: 1;\r
+ ULONG LeftAlt: 1;\r
+ ULONG LeftGUI: 1;\r
+ ULONG RightControl: 1;\r
+ ULONG RightShift: 1;\r
+ ULONG RightAlt: 1;\r
+ ULONG RigthGUI: 1;\r
+ ULONG CapsLock: 1;\r
+ ULONG ScollLock: 1;\r
+ ULONG NumLock: 1;\r
+ ULONG Reserved: 21;\r
+ };\r
+ ULONG ul;\r
+ };\r
+\r
+} HIDP_KEYBOARD_MODIFIER_STATE, * PHIDP_KEYBOARD_MODIFIER_STATE;\r
+\r
+//\r
+// A call back function to give the i8042 scan codes to the caller of\r
+// the below translation function.\r
+//\r
+typedef BOOLEAN (* PHIDP_INSERT_SCANCODES) (\r
+ IN PVOID Context, // Some caller supplied context.\r
+ IN PCHAR NewScanCodes, // A list of i8042 scan codes.\r
+ IN ULONG Length // the length of the scan codes.\r
+ );\r
+\r
+NTSTATUS __stdcall\r
+HidP_TranslateUsageAndPagesToI8042ScanCodes (\r
+ IN PUSAGE_AND_PAGE ChangedUsageList,\r
+ IN ULONG UsageListLength,\r
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,\r
+ IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,\r
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,\r
+ IN PVOID InsertCodesContext\r
+ );\r
+/*++\r
+Routine Description:\r
+Parameters:\r
+--*/\r
+\r
+NTSTATUS __stdcall\r
+HidP_TranslateUsagesToI8042ScanCodes (\r
+ IN PUSAGE ChangedUsageList,\r
+ IN ULONG UsageListLength,\r
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,\r
+ IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,\r
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,\r
+ IN PVOID InsertCodesContext\r
+ );\r
+/*++\r
+Routine Description:\r
+Parameters:\r
+--*/\r
+\r
+\r
+\r
+//\r
+// Define NT Status codes with Facility Code of FACILITY_HID_ERROR_CODE\r
+//\r
+\r
+// FACILITY_HID_ERROR_CODE defined in ntstatus.h\r
+#ifndef FACILITY_HID_ERROR_CODE\r
+#define FACILITY_HID_ERROR_CODE 0x11\r
+#endif\r
+\r
+#define HIDP_ERROR_CODES(SEV, CODE) \\r
+ ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))\r
+\r
+#define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0,0))\r
+#define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8,1))\r
+#define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC,1))\r
+#define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC,2))\r
+#define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC,3))\r
+#define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC,4))\r
+#define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC,5))\r
+#define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC,6))\r
+#define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC,7))\r
+#define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC,8))\r
+#define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC,9))\r
+#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC,0xA))\r
+#define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC,0xB))\r
+#define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC,0xC))\r
+#define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC,0xD))\r
+#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC,0xE))\r
+#define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC,0xF))\r
+#define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC,0x10))\r
+#define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC,0x20))\r
+\r
+//\r
+// We blundered this status code.\r
+//\r
+#define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN\r
+\r
+#include <poppack.h>\r
+\r
+#endif\r