Adding some hid.dll imports.
authorStephaneLenclud
Sat, 14 Feb 2015 22:11:36 +0100
changeset 50e6c103ebb155
parent 49 2ec781e51f36
child 51 5f1f1053a595
Adding some hid.dll imports.
Win32Hid.cs
pinvoke-input.txt
pinvoke-interop-assistant-input.c
     1.1 --- a/Win32Hid.cs	Wed Feb 11 19:46:21 2015 +0100
     1.2 +++ b/Win32Hid.cs	Sat Feb 14 22:11:36 2015 +0100
     1.3 @@ -19,6 +19,29 @@
     1.4  
     1.5          [DllImport("hid.dll", CharSet = CharSet.Auto, SetLastError = true)]
     1.6          public static extern Boolean HidD_GetAttributes(SafeFileHandle HidDeviceObject, ref HIDD_ATTRIBUTES Attributes);
     1.7 +
     1.8 +		/// Return Type: NTSTATUS->LONG->int
     1.9 +		///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.10 +		///Capabilities: PHIDP_CAPS->_HIDP_CAPS*
    1.11 +		[DllImportAttribute("hid.dll", EntryPoint = "HidP_GetCaps", CallingConvention = CallingConvention.StdCall)]
    1.12 +		public static extern int HidP_GetCaps(System.IntPtr PreparsedData, ref HIDP_CAPS Capabilities);
    1.13 +
    1.14 +		/// Return Type: NTSTATUS->LONG->int
    1.15 +		///ReportType: HIDP_REPORT_TYPE->_HIDP_REPORT_TYPE
    1.16 +		///ButtonCaps: PHIDP_BUTTON_CAPS->_HIDP_BUTTON_CAPS*
    1.17 +		///ButtonCapsLength: PUSHORT->USHORT*
    1.18 +		///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.19 +		[System.Runtime.InteropServices.DllImportAttribute("<Unknown>", EntryPoint = "HidP_GetButtonCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.20 +		public static extern int HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, ref HIDP_BUTTON_CAPS ButtonCaps, ref ushort ButtonCapsLength, System.IntPtr PreparsedData);
    1.21 +
    1.22 +		/// Return Type: NTSTATUS->LONG->int
    1.23 +		///ReportType: HIDP_REPORT_TYPE->_HIDP_REPORT_TYPE
    1.24 +		///ValueCaps: PHIDP_VALUE_CAPS->_HIDP_VALUE_CAPS*
    1.25 +		///ValueCapsLength: PUSHORT->USHORT*
    1.26 +		///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.27 +		[System.Runtime.InteropServices.DllImportAttribute("<Unknown>", EntryPoint = "HidP_GetValueCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.28 +		public static extern int HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, ref HIDP_VALUE_CAPS ValueCaps, ref ushort ValueCapsLength, System.IntPtr PreparsedData);
    1.29 +
    1.30      }
    1.31  
    1.32  
    1.33 @@ -86,4 +109,332 @@
    1.34      }
    1.35  
    1.36  
    1.37 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.38 +	public struct HIDP_CAPS
    1.39 +	{
    1.40 +
    1.41 +		/// USAGE->USHORT->unsigned short
    1.42 +		public ushort Usage;
    1.43 +
    1.44 +		/// USAGE->USHORT->unsigned short
    1.45 +		public ushort UsagePage;
    1.46 +
    1.47 +		/// USHORT->unsigned short
    1.48 +		public ushort InputReportByteLength;
    1.49 +
    1.50 +		/// USHORT->unsigned short
    1.51 +		public ushort OutputReportByteLength;
    1.52 +
    1.53 +		/// USHORT->unsigned short
    1.54 +		public ushort FeatureReportByteLength;
    1.55 +
    1.56 +		/// USHORT[17]
    1.57 +		[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 17, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U2)]
    1.58 +		public ushort[] Reserved;
    1.59 +
    1.60 +		/// USHORT->unsigned short
    1.61 +		public ushort NumberLinkCollectionNodes;
    1.62 +
    1.63 +		/// USHORT->unsigned short
    1.64 +		public ushort NumberInputButtonCaps;
    1.65 +
    1.66 +		/// USHORT->unsigned short
    1.67 +		public ushort NumberInputValueCaps;
    1.68 +
    1.69 +		/// USHORT->unsigned short
    1.70 +		public ushort NumberInputDataIndices;
    1.71 +
    1.72 +		/// USHORT->unsigned short
    1.73 +		public ushort NumberOutputButtonCaps;
    1.74 +
    1.75 +		/// USHORT->unsigned short
    1.76 +		public ushort NumberOutputValueCaps;
    1.77 +
    1.78 +		/// USHORT->unsigned short
    1.79 +		public ushort NumberOutputDataIndices;
    1.80 +
    1.81 +		/// USHORT->unsigned short
    1.82 +		public ushort NumberFeatureButtonCaps;
    1.83 +
    1.84 +		/// USHORT->unsigned short
    1.85 +		public ushort NumberFeatureValueCaps;
    1.86 +
    1.87 +		/// USHORT->unsigned short
    1.88 +		public ushort NumberFeatureDataIndices;
    1.89 +	}
    1.90 +
    1.91 +	/// <summary>
    1.92 +	/// Type created in place of an anonymous struct
    1.93 +	/// </summary>
    1.94 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.95 +	public struct HIDP_BUTTON_CAPS_RANGE
    1.96 +	{
    1.97 +
    1.98 +		/// USAGE->USHORT->unsigned short
    1.99 +		public ushort UsageMin;
   1.100 +
   1.101 +		/// USAGE->USHORT->unsigned short
   1.102 +		public ushort UsageMax;
   1.103 +
   1.104 +		/// USHORT->unsigned short
   1.105 +		public ushort StringMin;
   1.106 +
   1.107 +		/// USHORT->unsigned short
   1.108 +		public ushort StringMax;
   1.109 +
   1.110 +		/// USHORT->unsigned short
   1.111 +		public ushort DesignatorMin;
   1.112 +
   1.113 +		/// USHORT->unsigned short
   1.114 +		public ushort DesignatorMax;
   1.115 +
   1.116 +		/// USHORT->unsigned short
   1.117 +		public ushort DataIndexMin;
   1.118 +
   1.119 +		/// USHORT->unsigned short
   1.120 +		public ushort DataIndexMax;
   1.121 +	}
   1.122 +
   1.123 +	/// <summary>
   1.124 +	/// Type created in place of an anonymous struct
   1.125 +	/// </summary>
   1.126 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.127 +	public struct HIDP_BUTTON_CAPS_NOT_RANGE
   1.128 +	{
   1.129 +
   1.130 +		/// USAGE->USHORT->unsigned short
   1.131 +		public ushort Usage;
   1.132 +
   1.133 +		/// USAGE->USHORT->unsigned short
   1.134 +		public ushort Reserved1;
   1.135 +
   1.136 +		/// USHORT->unsigned short
   1.137 +		public ushort StringIndex;
   1.138 +
   1.139 +		/// USHORT->unsigned short
   1.140 +		public ushort Reserved2;
   1.141 +
   1.142 +		/// USHORT->unsigned short
   1.143 +		public ushort DesignatorIndex;
   1.144 +
   1.145 +		/// USHORT->unsigned short
   1.146 +		public ushort Reserved3;
   1.147 +
   1.148 +		/// USHORT->unsigned short
   1.149 +		public ushort DataIndex;
   1.150 +
   1.151 +		/// USHORT->unsigned short
   1.152 +		public ushort Reserved4;
   1.153 +	}
   1.154 +
   1.155 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
   1.156 +	public struct HIDP_BUTTON_CAPS_UNION
   1.157 +	{
   1.158 +
   1.159 +		/// 
   1.160 +		[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
   1.161 +		public HIDP_BUTTON_CAPS_RANGE Range;
   1.162 +
   1.163 +		/// 
   1.164 +		[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
   1.165 +		public HIDP_BUTTON_CAPS_NOT_RANGE NotRange;
   1.166 +	}
   1.167 +
   1.168 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.169 +	public struct HIDP_BUTTON_CAPS
   1.170 +	{
   1.171 +
   1.172 +		/// USAGE->USHORT->unsigned short
   1.173 +		public ushort UsagePage;
   1.174 +
   1.175 +		/// UCHAR->unsigned char
   1.176 +		public byte ReportID;
   1.177 +
   1.178 +		/// BOOLEAN->BYTE->unsigned char
   1.179 +		public byte IsAlias;
   1.180 +
   1.181 +		/// USHORT->unsigned short
   1.182 +		public ushort BitField;
   1.183 +
   1.184 +		/// USHORT->unsigned short
   1.185 +		public ushort LinkCollection;
   1.186 +
   1.187 +		/// USAGE->USHORT->unsigned short
   1.188 +		public ushort LinkUsage;
   1.189 +
   1.190 +		/// USAGE->USHORT->unsigned short
   1.191 +		public ushort LinkUsagePage;
   1.192 +
   1.193 +		/// BOOLEAN->BYTE->unsigned char
   1.194 +		public byte IsRange;
   1.195 +
   1.196 +		/// BOOLEAN->BYTE->unsigned char
   1.197 +		public byte IsStringRange;
   1.198 +
   1.199 +		/// BOOLEAN->BYTE->unsigned char
   1.200 +		public byte IsDesignatorRange;
   1.201 +
   1.202 +		/// BOOLEAN->BYTE->unsigned char
   1.203 +		public byte IsAbsolute;
   1.204 +
   1.205 +		/// ULONG[10]
   1.206 +		[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U4)]
   1.207 +		public uint[] Reserved;
   1.208 +
   1.209 +		/// TODO: get the proper field offset to make it nicer and get rid of union type
   1.210 +		public HIDP_BUTTON_CAPS_UNION Union;
   1.211 +	}
   1.212 +
   1.213 +	/// <summary>
   1.214 +	/// Type created in place of an anonymous struct
   1.215 +	/// </summary>
   1.216 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.217 +	public struct HIDP_VALUE_CAPS_RANGE
   1.218 +	{
   1.219 +
   1.220 +		/// USAGE->USHORT->unsigned short
   1.221 +		public ushort UsageMin;
   1.222 +
   1.223 +		/// USAGE->USHORT->unsigned short
   1.224 +		public ushort UsageMax;
   1.225 +
   1.226 +		/// USHORT->unsigned short
   1.227 +		public ushort StringMin;
   1.228 +
   1.229 +		/// USHORT->unsigned short
   1.230 +		public ushort StringMax;
   1.231 +
   1.232 +		/// USHORT->unsigned short
   1.233 +		public ushort DesignatorMin;
   1.234 +
   1.235 +		/// USHORT->unsigned short
   1.236 +		public ushort DesignatorMax;
   1.237 +
   1.238 +		/// USHORT->unsigned short
   1.239 +		public ushort DataIndexMin;
   1.240 +
   1.241 +		/// USHORT->unsigned short
   1.242 +		public ushort DataIndexMax;
   1.243 +	}
   1.244 +
   1.245 +	/// <summary>
   1.246 +	/// Type created in place of an anonymous struct
   1.247 +	/// </summary>
   1.248 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.249 +	public struct HIDP_VALUE_CAPS_NOT_RANGE
   1.250 +	{
   1.251 +
   1.252 +		/// USAGE->USHORT->unsigned short
   1.253 +		public ushort Usage;
   1.254 +
   1.255 +		/// USAGE->USHORT->unsigned short
   1.256 +		public ushort Reserved1;
   1.257 +
   1.258 +		/// USHORT->unsigned short
   1.259 +		public ushort StringIndex;
   1.260 +
   1.261 +		/// USHORT->unsigned short
   1.262 +		public ushort Reserved2;
   1.263 +
   1.264 +		/// USHORT->unsigned short
   1.265 +		public ushort DesignatorIndex;
   1.266 +
   1.267 +		/// USHORT->unsigned short
   1.268 +		public ushort Reserved3;
   1.269 +
   1.270 +		/// USHORT->unsigned short
   1.271 +		public ushort DataIndex;
   1.272 +
   1.273 +		/// USHORT->unsigned short
   1.274 +		public ushort Reserved4;
   1.275 +	}
   1.276 +
   1.277 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
   1.278 +	public struct HIDP_VALUE_CAPS_UNION
   1.279 +	{
   1.280 +
   1.281 +		/// 
   1.282 +		[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
   1.283 +		public HIDP_VALUE_CAPS_RANGE Range;
   1.284 +
   1.285 +		/// 
   1.286 +		[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
   1.287 +		public HIDP_VALUE_CAPS_NOT_RANGE NotRange;
   1.288 +	}
   1.289 +
   1.290 +	[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.291 +	public struct HIDP_VALUE_CAPS
   1.292 +	{
   1.293 +
   1.294 +		/// USAGE->USHORT->unsigned short
   1.295 +		public ushort UsagePage;
   1.296 +
   1.297 +		/// UCHAR->unsigned char
   1.298 +		public byte ReportID;
   1.299 +
   1.300 +		/// BOOLEAN->BYTE->unsigned char
   1.301 +		public byte IsAlias;
   1.302 +
   1.303 +		/// USHORT->unsigned short
   1.304 +		public ushort BitField;
   1.305 +
   1.306 +		/// USHORT->unsigned short
   1.307 +		public ushort LinkCollection;
   1.308 +
   1.309 +		/// USAGE->USHORT->unsigned short
   1.310 +		public ushort LinkUsage;
   1.311 +
   1.312 +		/// USAGE->USHORT->unsigned short
   1.313 +		public ushort LinkUsagePage;
   1.314 +
   1.315 +		/// BOOLEAN->BYTE->unsigned char
   1.316 +		public byte IsRange;
   1.317 +
   1.318 +		/// BOOLEAN->BYTE->unsigned char
   1.319 +		public byte IsStringRange;
   1.320 +
   1.321 +		/// BOOLEAN->BYTE->unsigned char
   1.322 +		public byte IsDesignatorRange;
   1.323 +
   1.324 +		/// BOOLEAN->BYTE->unsigned char
   1.325 +		public byte IsAbsolute;
   1.326 +
   1.327 +		/// BOOLEAN->BYTE->unsigned char
   1.328 +		public byte HasNull;
   1.329 +
   1.330 +		/// UCHAR->unsigned char
   1.331 +		public byte Reserved;
   1.332 +
   1.333 +		/// USHORT->unsigned short
   1.334 +		public ushort BitSize;
   1.335 +
   1.336 +		/// USHORT->unsigned short
   1.337 +		public ushort ReportCount;
   1.338 +
   1.339 +		/// USHORT[5]
   1.340 +		[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 5, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U2)]
   1.341 +		public ushort[] Reserved2;
   1.342 +
   1.343 +		/// ULONG->unsigned int
   1.344 +		public uint UnitsExp;
   1.345 +
   1.346 +		/// ULONG->unsigned int
   1.347 +		public uint Units;
   1.348 +
   1.349 +		/// LONG->int
   1.350 +		public int LogicalMin;
   1.351 +
   1.352 +		/// LONG->int
   1.353 +		public int LogicalMax;
   1.354 +
   1.355 +		/// LONG->int
   1.356 +		public int PhysicalMin;
   1.357 +
   1.358 +		/// LONG->int
   1.359 +		public int PhysicalMax;
   1.360 +
   1.361 +		/// 
   1.362 +		public HIDP_VALUE_CAPS_UNION Union;
   1.363 +	}
   1.364 +
   1.365  }
   1.366 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pinvoke-input.txt	Sat Feb 14 22:11:36 2015 +0100
     2.3 @@ -0,0 +1,2226 @@
     2.4 +//
     2.5 +// SL: We use this file to generate P/Invoke using P/Invoke Interop Assistant.
     2.6 +//
     2.7 +
     2.8 +
     2.9 +typedef USHORT USAGE, *PUSAGE;
    2.10 +typedef LONG NTSTATUS;
    2.11 +
    2.12 +#define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
    2.13 +#define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
    2.14 +
    2.15 +
    2.16 +typedef enum _HIDP_REPORT_TYPE
    2.17 +{
    2.18 +    HidP_Input,
    2.19 +    HidP_Output,
    2.20 +    HidP_Feature
    2.21 +} HIDP_REPORT_TYPE;
    2.22 +
    2.23 +typedef struct _USAGE_AND_PAGE
    2.24 +{
    2.25 +    USAGE Usage;
    2.26 +    USAGE UsagePage;
    2.27 +} USAGE_AND_PAGE, *PUSAGE_AND_PAGE;
    2.28 +
    2.29 +#define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
    2.30 +
    2.31 +typedef struct _HIDP_BUTTON_CAPS
    2.32 +{
    2.33 +    USAGE    UsagePage;
    2.34 +    UCHAR    ReportID;
    2.35 +    BOOLEAN  IsAlias;
    2.36 +
    2.37 +    USHORT   BitField;
    2.38 +    USHORT   LinkCollection;   // A unique internal index pointer
    2.39 +
    2.40 +    USAGE    LinkUsage;
    2.41 +    USAGE    LinkUsagePage;
    2.42 +
    2.43 +    BOOLEAN  IsRange;
    2.44 +    BOOLEAN  IsStringRange;
    2.45 +    BOOLEAN  IsDesignatorRange;
    2.46 +    BOOLEAN  IsAbsolute;
    2.47 +
    2.48 +    ULONG    Reserved[10];
    2.49 +    union {
    2.50 +        struct {
    2.51 +            USAGE    UsageMin,         UsageMax;
    2.52 +            USHORT   StringMin,        StringMax;
    2.53 +            USHORT   DesignatorMin,    DesignatorMax;
    2.54 +            USHORT   DataIndexMin,     DataIndexMax;
    2.55 +        } Range;
    2.56 +        struct  {
    2.57 +            USAGE    Usage,            Reserved1;
    2.58 +            USHORT   StringIndex,      Reserved2;
    2.59 +            USHORT   DesignatorIndex,  Reserved3;
    2.60 +            USHORT   DataIndex,        Reserved4;
    2.61 +        } NotRange;
    2.62 +    };
    2.63 +
    2.64 +} HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;
    2.65 +
    2.66 +
    2.67 +typedef struct _HIDP_VALUE_CAPS
    2.68 +{
    2.69 +    USAGE    UsagePage;
    2.70 +    UCHAR    ReportID;
    2.71 +    BOOLEAN  IsAlias;
    2.72 +
    2.73 +    USHORT   BitField;
    2.74 +    USHORT   LinkCollection;   // A unique internal index pointer
    2.75 +
    2.76 +    USAGE    LinkUsage;
    2.77 +    USAGE    LinkUsagePage;
    2.78 +
    2.79 +    BOOLEAN  IsRange;
    2.80 +    BOOLEAN  IsStringRange;
    2.81 +    BOOLEAN  IsDesignatorRange;
    2.82 +    BOOLEAN  IsAbsolute;
    2.83 +
    2.84 +    BOOLEAN  HasNull;        // Does this channel have a null report   union
    2.85 +    UCHAR    Reserved;
    2.86 +    USHORT   BitSize;        // How many bits are devoted to this value?
    2.87 +
    2.88 +    USHORT   ReportCount;    // See Note below.  Usually set to 1.
    2.89 +    USHORT   Reserved2[5];
    2.90 +
    2.91 +    ULONG    UnitsExp;
    2.92 +    ULONG    Units;
    2.93 +
    2.94 +    LONG     LogicalMin,       LogicalMax;
    2.95 +    LONG     PhysicalMin,      PhysicalMax;
    2.96 +
    2.97 +    union {
    2.98 +        struct {
    2.99 +            USAGE    UsageMin,         UsageMax;
   2.100 +            USHORT   StringMin,        StringMax;
   2.101 +            USHORT   DesignatorMin,    DesignatorMax;
   2.102 +            USHORT   DataIndexMin,     DataIndexMax;
   2.103 +        } Range;
   2.104 +
   2.105 +        struct {
   2.106 +            USAGE    Usage,            Reserved1;
   2.107 +            USHORT   StringIndex,      Reserved2;
   2.108 +            USHORT   DesignatorIndex,  Reserved3;
   2.109 +            USHORT   DataIndex,        Reserved4;
   2.110 +        } NotRange;
   2.111 +    };
   2.112 +} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
   2.113 +
   2.114 +//
   2.115 +// Notes:
   2.116 +//
   2.117 +// ReportCount:  When a report descriptor declares an Input, Output, or
   2.118 +// Feature main item with fewer usage declarations than the report count, then
   2.119 +// the last usage applies to all remaining unspecified count in that main item.
   2.120 +// (As an example you might have data that required many fields to describe,
   2.121 +// possibly buffered bytes.)  In this case, only one value cap structure is
   2.122 +// allocated for these associtated fields, all with the same usage, and Report
   2.123 +// Count reflects the number of fields involved.  Normally ReportCount is 1.
   2.124 +// To access all of the fields in such a value structure would require using
   2.125 +// HidP_GetUsageValueArray and HidP_SetUsageValueArray.   HidP_GetUsageValue/
   2.126 +// HidP_SetScaledUsageValue will also work, however, these functions will only
   2.127 +// work with the first field of the structure.
   2.128 +//
   2.129 +
   2.130 +//
   2.131 +// The link collection tree consists of an array of LINK_COLLECTION_NODES
   2.132 +// where the index into this array is the same as the collection number.
   2.133 +//
   2.134 +// Given a collection A which contains a subcollection B, A is defined to be
   2.135 +// the parent B, and B is defined to be the child.
   2.136 +//
   2.137 +// Given collections A, B, and C where B and C are children of A, and B was
   2.138 +// encountered before C in the report descriptor, B is defined as a sibling of
   2.139 +// C.  (This implies, of course, that if B is a sibling of C, then C is NOT a
   2.140 +// sibling of B).
   2.141 +//
   2.142 +// B is defined as the NextSibling of C if and only if there exists NO
   2.143 +// child collection of A, call it D, such that B is a sibling of D and D
   2.144 +// is a sibling of C.
   2.145 +//
   2.146 +// E is defined to be the FirstChild of A if and only if for all children of A,
   2.147 +// F, that are not equivalent to E, F is a sibling of E.
   2.148 +// (This implies, of course, that the does not exist a child of A, call it G,
   2.149 +// where E is a sibling of G).  In other words the first sibling is the last
   2.150 +// link collection found in the list.
   2.151 +//
   2.152 +// In other words, if a collection B is defined within the definition of another
   2.153 +// collection A, B becomes a child of A.  All collections with the same parent
   2.154 +// are considered siblings.  The FirstChild of the parent collection, A, will be
   2.155 +// last collection defined that has A as a parent.  The order of sibling pointers
   2.156 +// is similarly determined.  When a collection B is defined, it becomes the
   2.157 +// FirstChild of it's parent collection.  The previously defined FirstChild of the
   2.158 +// parent collection becomes the NextSibling of the new collection.  As new
   2.159 +// collections with the same parent are discovered, the chain of sibling is built.
   2.160 +//
   2.161 +// With that in mind, the following describes conclusively a data structure
   2.162 +// that provides direct traversal up, down, and accross the link collection
   2.163 +// tree.
   2.164 +//
   2.165 +//
   2.166 +typedef struct _HIDP_LINK_COLLECTION_NODE
   2.167 +{
   2.168 +    USAGE    LinkUsage;
   2.169 +    USAGE    LinkUsagePage;
   2.170 +    USHORT   Parent;
   2.171 +    USHORT   NumberOfChildren;
   2.172 +    USHORT   NextSibling;
   2.173 +    USHORT   FirstChild;
   2.174 +    ULONG    CollectionType: 8;  // As defined in 6.2.2.6 of HID spec
   2.175 +    ULONG    IsAlias : 1; // This link node is an allias of the next link node.
   2.176 +    ULONG    Reserved: 23;
   2.177 +    PVOID    UserContext; // The user can hang his coat here.
   2.178 +} HIDP_LINK_COLLECTION_NODE, *PHIDP_LINK_COLLECTION_NODE;
   2.179 +
   2.180 +//
   2.181 +// When a link collection is described by a delimiter, alias link collection
   2.182 +// nodes are created.  (One for each usage within the delimiter).
   2.183 +// The parser assigns each capability description listed above only one
   2.184 +// link collection.
   2.185 +//
   2.186 +// If a control is defined within a collection defined by
   2.187 +// delimited usages, then that control is said to be within multiple link
   2.188 +// collections, one for each usage within the open and close delimiter tokens.
   2.189 +// Such multiple link collecions are said to be aliases.  The first N-1 such
   2.190 +// collections, listed in the link collection node array, have their IsAlias
   2.191 +// bit set.  The last such link collection is the link collection index used
   2.192 +// in the capabilities described above.
   2.193 +// Clients wishing to set a control in an aliased collection, should walk the
   2.194 +// collection array once for each time they see the IsAlias flag set, and use
   2.195 +// the last link collection as the index for the below accessor functions.
   2.196 +//
   2.197 +// NB: if IsAlias is set, then NextSibling should be one more than the current
   2.198 +// link collection node index.
   2.199 +//
   2.200 +
   2.201 +typedef PUCHAR  PHIDP_REPORT_DESCRIPTOR;
   2.202 +typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;
   2.203 +
   2.204 +typedef struct _HIDP_CAPS
   2.205 +{
   2.206 +    USAGE    Usage;
   2.207 +    USAGE    UsagePage;
   2.208 +    USHORT   InputReportByteLength;
   2.209 +    USHORT   OutputReportByteLength;
   2.210 +    USHORT   FeatureReportByteLength;
   2.211 +    USHORT   Reserved[17];
   2.212 +
   2.213 +    USHORT   NumberLinkCollectionNodes;
   2.214 +
   2.215 +    USHORT   NumberInputButtonCaps;
   2.216 +    USHORT   NumberInputValueCaps;
   2.217 +    USHORT   NumberInputDataIndices;
   2.218 +
   2.219 +    USHORT   NumberOutputButtonCaps;
   2.220 +    USHORT   NumberOutputValueCaps;
   2.221 +    USHORT   NumberOutputDataIndices;
   2.222 +
   2.223 +    USHORT   NumberFeatureButtonCaps;
   2.224 +    USHORT   NumberFeatureValueCaps;
   2.225 +    USHORT   NumberFeatureDataIndices;
   2.226 +} HIDP_CAPS, *PHIDP_CAPS;
   2.227 +
   2.228 +typedef struct _HIDP_DATA
   2.229 +{
   2.230 +    USHORT  DataIndex;
   2.231 +    USHORT  Reserved;
   2.232 +    union {
   2.233 +        ULONG   RawValue; // for values
   2.234 +        BOOLEAN On; // for buttons MUST BE TRUE for buttons.
   2.235 +    };
   2.236 +} HIDP_DATA, *PHIDP_DATA;
   2.237 +//
   2.238 +// The HIDP_DATA structure is used with HidP_GetData and HidP_SetData
   2.239 +// functions.
   2.240 +//
   2.241 +// The parser contiguously assigns every control (button or value) in a hid
   2.242 +// device a unique data index from zero to NumberXXXDataIndices -1 , inclusive.
   2.243 +// This value is found in the HIDP_BUTTON_CAPS and HIDP_VALUE_CAPS structures.
   2.244 +//
   2.245 +// Most clients will find the Get/Set Buttons / Value accessor functions
   2.246 +// sufficient to their needs, as they will allow the clients to access the
   2.247 +// data known to them while ignoring the other controls.
   2.248 +//
   2.249 +// More complex clients, which actually read the Button / Value Caps, and which
   2.250 +// do a value add service to these routines (EG Direct Input), will need to
   2.251 +// access all the data in the device without interest in the individual usage
   2.252 +// or link collection location.  These are the clients that will find
   2.253 +// HidP_Data useful.
   2.254 +//
   2.255 +
   2.256 +typedef struct _HIDP_UNKNOWN_TOKEN
   2.257 +{
   2.258 +    UCHAR  Token;
   2.259 +    UCHAR  Reserved[3];
   2.260 +    ULONG  BitField;
   2.261 +} HIDP_UNKNOWN_TOKEN, *PHIDP_UNKNOWN_TOKEN;
   2.262 +
   2.263 +typedef struct _HIDP_EXTENDED_ATTRIBUTES
   2.264 +{
   2.265 +    UCHAR   NumGlobalUnknowns;
   2.266 +    UCHAR   Reserved [3];
   2.267 +    PHIDP_UNKNOWN_TOKEN  GlobalUnknowns;
   2.268 +    // ... Additional attributes
   2.269 +    ULONG   Data [1]; // variableLength  DO NOT ACCESS THIS FIELD
   2.270 +} HIDP_EXTENDED_ATTRIBUTES, *PHIDP_EXTENDED_ATTRIBUTES;
   2.271 +
   2.272 +NTSTATUS __stdcall
   2.273 +HidP_GetCaps (
   2.274 +         PHIDP_PREPARSED_DATA      PreparsedData,
   2.275 +        PHIDP_CAPS                Capabilities
   2.276 +   );
   2.277 +/*++
   2.278 +Routine Description:
   2.279 +   Returns a list of capabilities of a given hid device as described by its
   2.280 +   preparsed data.
   2.281 +
   2.282 +Arguments:
   2.283 +   PreparsedData    The preparsed data returned from HIDCLASS.
   2.284 +   Capabilities     a HIDP_CAPS structure
   2.285 +
   2.286 +Return Value:
   2.287 +   HIDP_STATUS_SUCCESS
   2.288 +   HIDP_STATUS_INVALID_PREPARSED_DATA
   2.289 +--*/
   2.290 +
   2.291 +NTSTATUS __stdcall
   2.292 +HidP_GetLinkCollectionNodes (
   2.293 +        PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
   2.294 +      PULONG                     LinkCollectionNodesLength,
   2.295 +         PHIDP_PREPARSED_DATA       PreparsedData
   2.296 +   );
   2.297 +/*++
   2.298 +Routine Description:
   2.299 +   Return a list of PHIDP_LINK_COLLECTION_NODEs used to describe the link
   2.300 +   collection tree of this hid device.  See the above description of
   2.301 +   struct _HIDP_LINK_COLLECTION_NODE.
   2.302 +
   2.303 +Arguments:
   2.304 +   LinkCollectionNodes - a caller allocated array into which
   2.305 +                 HidP_GetLinkCollectionNodes will store the information
   2.306 +
   2.307 +   LinKCollectionNodesLength - the caller sets this value to the length of the
   2.308 +                 the array in terms of number of elements.
   2.309 +                 HidP_GetLinkCollectionNodes sets this value to the actual
   2.310 +                 number of elements set. The total number of nodes required to
   2.311 +                 describe this HID device can be found in the
   2.312 +                 NumberLinkCollectionNodes field in the HIDP_CAPS structure.
   2.313 +
   2.314 +--*/
   2.315 +
   2.316 +NTSTATUS __stdcall
   2.317 +HidP_GetSpecificButtonCaps (
   2.318 +          HIDP_REPORT_TYPE     ReportType,
   2.319 +          USAGE                UsagePage,      // Optional (0 => ignore)
   2.320 +          USHORT               LinkCollection, // Optional (0 => ignore)
   2.321 +          USAGE                Usage,          // Optional (0 => ignore)
   2.322 +   PHIDP_BUTTON_CAPS    ButtonCaps,
   2.323 +     PUSHORT              ButtonCapsLength,
   2.324 +          PHIDP_PREPARSED_DATA PreparsedData
   2.325 +   );
   2.326 +/*++
   2.327 +Description:
   2.328 +   HidP_GetButtonCaps returns all the buttons (binary values) that are a part
   2.329 +   of the given report type for the Hid device represented by the given
   2.330 +   preparsed data.
   2.331 +
   2.332 +Parameters:
   2.333 +   ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.334 +
   2.335 +   UsagePage   A usage page value used to limit the button caps returned to
   2.336 +                those on a given usage page.  If set to 0, this parameter is
   2.337 +                ignored.  Can be used with LinkCollection and Usage parameters
   2.338 +                to further limit the number of button caps structures returned.
   2.339 +
   2.340 +   LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
   2.341 +                  button caps returned to those buttons in a given link
   2.342 +                  collection.  If set to 0, this parameter is
   2.343 +                  ignored.  Can be used with UsagePage and Usage parameters
   2.344 +                  to further limit the number of button caps structures
   2.345 +                  returned.
   2.346 +
   2.347 +   Usage      A usage value used to limit the button caps returned to those
   2.348 +               with the specified usage value.  If set to 0, this parameter
   2.349 +               is ignored.  Can be used with LinkCollection and UsagePage
   2.350 +               parameters to further limit the number of button caps
   2.351 +               structures returned.
   2.352 +
   2.353 +   ButtonCaps A _HIDP_BUTTON_CAPS array containing information about all the
   2.354 +               binary values in the given report.  This buffer is provided by
   2.355 +               the caller.
   2.356 +
   2.357 +   ButtonLength   As input, this parameter specifies the length of the
   2.358 +                  ButtonCaps parameter (array) in number of array elements.
   2.359 +                  As output, this value is set to indicate how many of those
   2.360 +                  array elements were filled in by the function.  The maximum number of
   2.361 +                  button caps that can be returned is found in the HIDP_CAPS
   2.362 +                  structure.  If HIDP_STATUS_BUFFER_TOO_SMALL is returned,
   2.363 +                  this value contains the number of array elements needed to
   2.364 +                  successfully complete the request.
   2.365 +
   2.366 +   PreparsedData  The preparsed data returned from HIDCLASS.
   2.367 +
   2.368 +
   2.369 +Return Value
   2.370 +HidP_GetSpecificButtonCaps returns the following error codes:
   2.371 +  HIDP_STATUS_SUCCESS.
   2.372 +  HIDP_STATUS_INVALID_REPORT_TYPE
   2.373 +  HIDP_STATUS_INVALID_PREPARSED_DATA
   2.374 +  HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
   2.375 +  HIDP_STATUS_USAGE_NOT_FOUND
   2.376 +--*/
   2.377 +NTSTATUS __stdcall
   2.378 +HidP_GetButtonCaps (
   2.379 +          HIDP_REPORT_TYPE     ReportType,
   2.380 +   PHIDP_BUTTON_CAPS ButtonCaps,
   2.381 +       PUSHORT              ButtonCapsLength,
   2.382 +          PHIDP_PREPARSED_DATA PreparsedData
   2.383 +);
   2.384 +
   2.385 +NTSTATUS __stdcall
   2.386 +HidP_GetSpecificValueCaps (
   2.387 +          HIDP_REPORT_TYPE     ReportType,
   2.388 +          USAGE                UsagePage,      // Optional (0 => ignore)
   2.389 +          USHORT               LinkCollection, // Optional (0 => ignore)
   2.390 +          USAGE                Usage,          // Optional (0 => ignore)
   2.391 +          PHIDP_VALUE_CAPS     ValueCaps,
   2.392 +       PUSHORT              ValueCapsLength,
   2.393 +          PHIDP_PREPARSED_DATA PreparsedData
   2.394 +   );
   2.395 +/*++
   2.396 +Description:
   2.397 +   HidP_GetValueCaps returns all the values (non-binary) that are a part
   2.398 +   of the given report type for the Hid device represented by the given
   2.399 +   preparsed data.
   2.400 +
   2.401 +Parameters:
   2.402 +   ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.403 +
   2.404 +   UsagePage   A usage page value used to limit the value caps returned to
   2.405 +                those on a given usage page.  If set to 0, this parameter is
   2.406 +                ignored.  Can be used with LinkCollection and Usage parameters
   2.407 +                to further limit the number of value caps structures returned.
   2.408 +
   2.409 +   LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
   2.410 +                  value caps returned to those buttons in a given link
   2.411 +                  collection.  If set to 0, this parameter is
   2.412 +                  ignored.  Can be used with UsagePage and Usage parameters
   2.413 +                  to further limit the number of value caps structures
   2.414 +                  returned.
   2.415 +
   2.416 +   Usage      A usage value used to limit the value caps returned to those
   2.417 +               with the specified usage value.  If set to 0, this parameter
   2.418 +               is ignored.  Can be used with LinkCollection and UsagePage
   2.419 +               parameters to further limit the number of value caps
   2.420 +               structures returned.
   2.421 +
   2.422 +   ValueCaps  A _HIDP_VALUE_CAPS array containing information about all the
   2.423 +               non-binary values in the given report.  This buffer is provided
   2.424 +               by the caller.
   2.425 +
   2.426 +   ValueLength   As input, this parameter specifies the length of the ValueCaps
   2.427 +                  parameter (array) in number of array elements.  As output,
   2.428 +                  this value is set to indicate how many of those array elements
   2.429 +                  were filled in by the function.  The maximum number of
   2.430 +                  value caps that can be returned is found in the HIDP_CAPS
   2.431 +                  structure.  If HIDP_STATUS_BUFFER_TOO_SMALL is returned,
   2.432 +                  this value contains the number of array elements needed to
   2.433 +                  successfully complete the request.
   2.434 +
   2.435 +   PreparsedData  The preparsed data returned from HIDCLASS.
   2.436 +
   2.437 +
   2.438 +Return Value
   2.439 +HidP_GetValueCaps returns the following error codes:
   2.440 +  HIDP_STATUS_SUCCESS.
   2.441 +  HIDP_STATUS_INVALID_REPORT_TYPE
   2.442 +  HIDP_STATUS_INVALID_PREPARSED_DATA
   2.443 +  HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
   2.444 +  HIDP_STATUS_USAGE_NOT_FOUND
   2.445 +
   2.446 +--*/
   2.447 +
   2.448 +NTSTATUS __stdcall
   2.449 +HidP_GetValueCaps (
   2.450 +          HIDP_REPORT_TYPE     ReportType,
   2.451 +   PHIDP_VALUE_CAPS ValueCaps,
   2.452 +       PUSHORT              ValueCapsLength,
   2.453 +          PHIDP_PREPARSED_DATA PreparsedData
   2.454 +);
   2.455 +
   2.456 +NTSTATUS __stdcall
   2.457 +HidP_GetExtendedAttributes (
   2.458 +          HIDP_REPORT_TYPE            ReportType,
   2.459 +          USHORT                      DataIndex,
   2.460 +          PHIDP_PREPARSED_DATA        PreparsedData,
   2.461 +    PHIDP_EXTENDED_ATTRIBUTES Attributes,
   2.462 +       PULONG                      LengthAttributes
   2.463 +    );
   2.464 +/*++
   2.465 +Description:
   2.466 +    Given a data index from the value or button capabilities of a given control
   2.467 +    return any extended attributes for the control if any exist.
   2.468 +
   2.469 +Parameters:
   2.470 +    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.471 +
   2.472 +    DataIndex   The data index for the given control, found in the capabilities
   2.473 +                structure for that control
   2.474 +
   2.475 +    PreparsedData   The preparsed data returned from HIDCLASS.
   2.476 +
   2.477 +    Attributes  Pointer to a buffer into which the extended attribute data will
   2.478 +                be copied.
   2.479 +
   2.480 +    LengthAttributes    Length of the given buffer in bytes.
   2.481 +
   2.482 +Return Value
   2.483 +    HIDP_STATUS_SUCCESS
   2.484 +    HIDP_STATUS_DATA_INDEX_NOT_FOUND
   2.485 +--*/
   2.486 +
   2.487 +NTSTATUS __stdcall
   2.488 +HidP_InitializeReportForID (
   2.489 +    HIDP_REPORT_TYPE ReportType,
   2.490 +    UCHAR ReportID,
   2.491 +    PHIDP_PREPARSED_DATA PreparsedData,
   2.492 +   PCHAR Report,
   2.493 +    ULONG ReportLength
   2.494 +   );
   2.495 +/*++
   2.496 +
   2.497 +Routine Description:
   2.498 +
   2.499 +    Initialize a report based on the given report ID.
   2.500 +
   2.501 +Parameters:
   2.502 +
   2.503 +    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.504 +
   2.505 +    PreparasedData  Preparsed data structure returned by HIDCLASS
   2.506 +
   2.507 +    Report      Buffer which to set the data into.
   2.508 +
   2.509 +    ReportLength Length of Report...Report should be at least as long as the
   2.510 +                value indicated in the HIDP_CAPS structure for the device and
   2.511 +                the corresponding ReportType
   2.512 +
   2.513 +Return Value
   2.514 +
   2.515 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.516 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.517 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal
   2.518 +                                        to the length specified in HIDP_CAPS
   2.519 +                                        structure for the given ReportType
   2.520 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.521 +                                        for the given ReportType
   2.522 +
   2.523 +--*/
   2.524 +
   2.525 +NTSTATUS __stdcall
   2.526 +HidP_SetData (
   2.527 +     HIDP_REPORT_TYPE ReportType,
   2.528 +    PHIDP_DATA DataList,
   2.529 +     PULONG DataLength,
   2.530 +     PHIDP_PREPARSED_DATA PreparsedData,
   2.531 +    PCHAR Report,
   2.532 +     ULONG ReportLength
   2.533 +    );
   2.534 +/*++
   2.535 +
   2.536 +Routine Description:
   2.537 +
   2.538 +    Please Note: Since usage value arrays deal with multiple fields for
   2.539 +                 for one usage value, they cannot be used with HidP_SetData
   2.540 +                 and HidP_GetData.  In this case,
   2.541 +                 HIDP_STATUS_IS_USAGE_VALUE_ARRAY will be returned.
   2.542 +
   2.543 +Parameters:
   2.544 +
   2.545 +    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.546 +
   2.547 +    DataList    Array of HIDP_DATA structures that contains the data values
   2.548 +                that are to be set into the given report
   2.549 +
   2.550 +    DataLength  As input, length in array elements of DataList.  As output,
   2.551 +                contains the number of data elements set on successful
   2.552 +                completion or an index into the DataList array to identify
   2.553 +                the faulting HIDP_DATA value if an error code is returned.
   2.554 +
   2.555 +    PreparasedData  Preparsed data structure returned by HIDCLASS
   2.556 +
   2.557 +    Report      Buffer which to set the data into.
   2.558 +
   2.559 +    ReportLength Length of Report...Report should be at least as long as the
   2.560 +                value indicated in the HIDP_CAPS structure for the device and
   2.561 +                the corresponding ReportType
   2.562 +
   2.563 +Return Value
   2.564 +    HidP_SetData returns the following error codes.  The report packet will
   2.565 +        have all the data set up until the HIDP_DATA structure that caused the
   2.566 +        error.  DataLength, in the error case, will return this problem index.
   2.567 +
   2.568 +  HIDP_STATUS_SUCCESS                -- upon successful insertion of all data
   2.569 +                                        into the report packet.
   2.570 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.571 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.572 +  HIDP_STATUS_DATA_INDEX_NOT_FOUND   -- if a HIDP_DATA structure referenced a
   2.573 +                                        data index that does not exist for this
   2.574 +                                        device's ReportType
   2.575 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal
   2.576 +                                        to the length specified in HIDP_CAPS
   2.577 +                                        structure for the given ReportType
   2.578 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.579 +                                        for the given ReportType
   2.580 +  HIDP_STATUS_IS_USAGE_VALUE_ARRAY   -- if one of the HIDP_DATA structures
   2.581 +                                        references a usage value array.
   2.582 +                                        DataLength will contain the index into
   2.583 +                                        the array that was invalid
   2.584 +  HIDP_STATUS_BUTTON_NOT_PRESSED     -- if a HIDP_DATA structure attempted
   2.585 +                                        to unset a button that was not already
   2.586 +                                        set in the Report
   2.587 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- a HIDP_DATA structure was found with
   2.588 +                                        a valid index value but is contained
   2.589 +                                        in a different report than the one
   2.590 +                                        currently being processed
   2.591 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough entries in
   2.592 +                                        a given Main Array Item to report all
   2.593 +                                        buttons that have been requested to be
   2.594 +                                        set
   2.595 +--*/
   2.596 +
   2.597 +NTSTATUS __stdcall
   2.598 +HidP_GetData (
   2.599 +     HIDP_REPORT_TYPE ReportType,
   2.600 +    PHIDP_DATA DataList,
   2.601 +     PULONG DataLength,
   2.602 +     PHIDP_PREPARSED_DATA PreparsedData,
   2.603 +    PCHAR Report,
   2.604 +     ULONG ReportLength
   2.605 +    );
   2.606 +/*++
   2.607 +
   2.608 +Routine Description:
   2.609 +
   2.610 +    Please Note: For obvious reasons HidP_SetData and HidP_GetData will not
   2.611 +    access UsageValueArrays.
   2.612 +
   2.613 +Parameters:
   2.614 +    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.
   2.615 +
   2.616 +    DataList    Array of HIDP_DATA structures that will receive the data
   2.617 +                values that are set in the given report
   2.618 +
   2.619 +    DataLength  As input, length in array elements of DataList.  As output,
   2.620 +                contains the number of data elements that were successfully
   2.621 +                set by HidP_GetData.  The maximum size necessary for DataList
   2.622 +                can be determined by calling HidP_MaxDataListLength
   2.623 +
   2.624 +    PreparasedData  Preparsed data structure returned by HIDCLASS
   2.625 +
   2.626 +    Report      Buffer which to set the data into.
   2.627 +
   2.628 +    ReportLength Length of Report...Report should be at least as long as the
   2.629 +                value indicated in the HIDP_CAPS structure for the device and
   2.630 +                the corresponding ReportType
   2.631 +
   2.632 +Return Value
   2.633 +    HidP_GetData returns the following error codes.
   2.634 +
   2.635 +  HIDP_STATUS_SUCCESS                -- upon successful retrieval of all data
   2.636 +                                        from the report packet.
   2.637 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.638 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.639 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal
   2.640 +                                        to the length specified in HIDP_CAPS
   2.641 +                                        structure for the given ReportType
   2.642 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.643 +                                        for the given ReportType
   2.644 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough array entries in
   2.645 +                                        DataList to store all the indice values
   2.646 +                                        in the given report.  DataLength will
   2.647 +                                        contain the number of array entries
   2.648 +                                        required to hold all data
   2.649 +--*/
   2.650 +
   2.651 +
   2.652 +ULONG __stdcall
   2.653 +HidP_MaxDataListLength (
   2.654 +    HIDP_REPORT_TYPE      ReportType,
   2.655 +    PHIDP_PREPARSED_DATA  PreparsedData
   2.656 +   );
   2.657 +/*++
   2.658 +Routine Description:
   2.659 +
   2.660 +    This function returns the maximum length of HIDP_DATA elements that
   2.661 +    HidP_GetData could return for the given report type.
   2.662 +
   2.663 +Parameters:
   2.664 +
   2.665 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
   2.666 +
   2.667 +    PreparsedData    Preparsed data structure returned by HIDCLASS
   2.668 +
   2.669 +Return Value:
   2.670 +
   2.671 +    The length of the data list array required for the HidP_GetData function
   2.672 +    call.  If an error occurs (either HIDP_STATUS_INVALID_REPORT_TYPE or
   2.673 +    HIDP_STATUS_INVALID_PREPARSED_DATA), this function returns 0.
   2.674 +
   2.675 +--*/
   2.676 +
   2.677 +#define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
   2.678 +        HidP_SetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
   2.679 +
   2.680 +
   2.681 +NTSTATUS __stdcall
   2.682 +HidP_SetUsages (
   2.683 +    HIDP_REPORT_TYPE    ReportType,
   2.684 +    USAGE   UsagePage,
   2.685 +    USHORT  LinkCollection,
   2.686 +   PUSAGE  UsageList,
   2.687 +     PULONG  UsageLength,
   2.688 +    PHIDP_PREPARSED_DATA  PreparsedData,
   2.689 +   PCHAR   Report,
   2.690 +    ULONG   ReportLength 
   2.691 +   );
   2.692 +/*++
   2.693 +
   2.694 +Routine Description:
   2.695 +    This function sets binary values (buttons) in a report.  Given an
   2.696 +    initialized packet of correct length, it modifies the report packet so that
   2.697 +    each element in the given list of usages has been set in the report packet.
   2.698 +    For example, in an output report with 5 LED's, each with a given usage,
   2.699 +    an application could turn on any subset of these lights by placing their
   2.700 +    usages in any order into the usage array (UsageList).  HidP_SetUsages would,
   2.701 +    in turn, set the appropriate bit or add the corresponding byte into the
   2.702 +    HID Main Array Item.
   2.703 +
   2.704 +    A properly initialized Report packet is one of the correct byte length,
   2.705 +    and all zeros.
   2.706 +
   2.707 +    NOTE: A packet that has already been set with a call to a HidP_Set routine
   2.708 +          can also be passed in.  This routine then sets processes the UsageList
   2.709 +          in the same fashion but verifies that the ReportID already set in
   2.710 +          Report matches the report ID for the given usages.
   2.711 +
   2.712 +Parameters:
   2.713 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
   2.714 +
   2.715 +    UsagePage   All of the usages in the usage array, which HidP_SetUsages will
   2.716 +                set in the report, refer to this same usage page.
   2.717 +                If a client wishes to set usages in a report for multiple
   2.718 +                usage pages then that client needs to make multiple calls to
   2.719 +                HidP_SetUsages for each of the usage pages.
   2.720 +
   2.721 +    UsageList   A usage array containing the usages that HidP_SetUsages will set in
   2.722 +                the report packet.
   2.723 +
   2.724 +    UsageLength The length of the given usage array in array elements.
   2.725 +                The parser will set this value to the position in the usage
   2.726 +                array where it stopped processing.  If successful, UsageLength
   2.727 +                will be unchanged.  In any error condition, this parameter
   2.728 +                reflects how many of the usages in the usage list have
   2.729 +                actually been set by the parser.  This is useful for finding
   2.730 +                the usage in the list which caused the error.
   2.731 +
   2.732 +    PreparsedData The preparsed data recevied from HIDCLASS
   2.733 +
   2.734 +    Report      The report packet.
   2.735 +
   2.736 +    ReportLength   Length of the given report packet...Must be equal to the
   2.737 +                   value reported in the HIDP_CAPS structure for the device
   2.738 +                   and corresponding report type.
   2.739 +
   2.740 +Return Value
   2.741 +    HidP_SetUsages returns the following error codes.  On error, the report packet
   2.742 +    will be correct up until the usage element that caused the error.
   2.743 +
   2.744 +  HIDP_STATUS_SUCCESS                -- upon successful insertion of all usages
   2.745 +                                        into the report packet.
   2.746 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.747 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.748 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
   2.749 +                                        equal to the length specified in
   2.750 +                                        the HIDP_CAPS structure for the given
   2.751 +                                        ReportType
   2.752 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.753 +                                        for the given ReportType
   2.754 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
   2.755 +                                        different report.  If the report is
   2.756 +                                        zero-initialized on entry the first
   2.757 +                                        usage in the list will determine which
   2.758 +                                        report ID is used.  Otherwise, the
   2.759 +                                        parser will verify that usage matches
   2.760 +                                        the passed in report's ID
   2.761 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage does not exist for any
   2.762 +                                        report (no matter what the report ID)
   2.763 +                                        for the given report type.
   2.764 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough entries in a
   2.765 +                                        given Main Array Item to list all of
   2.766 +                                        the given usages.  The caller needs
   2.767 +                                        to split his request into more than
   2.768 +                                        one call
   2.769 +--*/
   2.770 +
   2.771 +#define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
   2.772 +        HidP_UnsetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
   2.773 +
   2.774 +
   2.775 +NTSTATUS __stdcall
   2.776 +HidP_UnsetUsages (
   2.777 +    HIDP_REPORT_TYPE      ReportType,
   2.778 +    USAGE   UsagePage,
   2.779 +   USHORT  LinkCollection,
   2.780 +   PUSAGE  UsageList,
   2.781 +     PULONG  UsageLength,
   2.782 +    PHIDP_PREPARSED_DATA  PreparsedData,
   2.783 +   PCHAR   Report,
   2.784 +    ULONG   ReportLength
   2.785 +   );
   2.786 +/*++
   2.787 +
   2.788 +Routine Description:
   2.789 +    This function unsets (turns off) binary values (buttons) in the report.  Given
   2.790 +    an initialized packet of correct length, it modifies the report packet so
   2.791 +    that each element in the given list of usages has been unset in the
   2.792 +    report packet.
   2.793 +
   2.794 +    This function is the "undo" operation for SetUsages.  If the given usage
   2.795 +    is not already set in the Report, it will return an error code of
   2.796 +    HIDP_STATUS_BUTTON_NOT_PRESSED.  If the button is pressed, HidP_UnsetUsages
   2.797 +    will unset the appropriate bit or remove the corresponding index value from
   2.798 +    the HID Main Array Item.
   2.799 +
   2.800 +    A properly initialized Report packet is one of the correct byte length,
   2.801 +    and all zeros..
   2.802 +
   2.803 +    NOTE: A packet that has already been set with a call to a HidP_Set routine
   2.804 +          can also be passed in.  This routine then processes the UsageList
   2.805 +          in the same fashion but verifies that the ReportID already set in
   2.806 +          Report matches the report ID for the given usages.
   2.807 +
   2.808 +Parameters:
   2.809 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
   2.810 +
   2.811 +    UsagePage   All of the usages in the usage array, which HidP_UnsetUsages will
   2.812 +                unset in the report, refer to this same usage page.
   2.813 +                If a client wishes to unset usages in a report for multiple
   2.814 +                usage pages then that client needs to make multiple calls to
   2.815 +                HidP_UnsetUsages for each of the usage pages.
   2.816 +
   2.817 +    UsageList   A usage array containing the usages that HidP_UnsetUsages will
   2.818 +                unset in the report packet.
   2.819 +
   2.820 +    UsageLength The length of the given usage array in array elements.
   2.821 +                The parser will set this value to the position in the usage
   2.822 +                array where it stopped processing.  If successful, UsageLength
   2.823 +                will be unchanged.  In any error condition, this parameter
   2.824 +                reflects how many of the usages in the usage list have
   2.825 +                actually been unset by the parser.  This is useful for finding
   2.826 +                the usage in the list which caused the error.
   2.827 +
   2.828 +    PreparsedData The preparsed data recevied from HIDCLASS
   2.829 +
   2.830 +    Report      The report packet.
   2.831 +
   2.832 +    ReportLength   Length of the given report packet...Must be equal to the
   2.833 +                   value reported in the HIDP_CAPS structure for the device
   2.834 +                   and corresponding report type.
   2.835 +
   2.836 +Return Value
   2.837 +    HidP_UnsetUsages returns the following error codes.  On error, the report
   2.838 +    packet will be correct up until the usage element that caused the error.
   2.839 +
   2.840 +  HIDP_STATUS_SUCCESS                -- upon successful "unsetting" of all usages
   2.841 +                                        in the report packet.
   2.842 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.843 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.844 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
   2.845 +                                        equal to the length specified in
   2.846 +                                        the HIDP_CAPS structure for the given
   2.847 +                                        ReportType
   2.848 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.849 +                                        for the given ReportType
   2.850 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
   2.851 +                                        different report.  If the report is
   2.852 +                                        zero-initialized on entry the first
   2.853 +                                        usage in the list will determine which
   2.854 +                                        report ID is used.  Otherwise, the
   2.855 +                                        parser will verify that usage matches
   2.856 +                                        the passed in report's ID
   2.857 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage does not exist for any
   2.858 +                                        report (no matter what the report ID)
   2.859 +                                        for the given report type.
   2.860 +  HIDP_STATUS_BUTTON_NOT_PRESSED     -- if a usage corresponds to a button that
   2.861 +                                        is not already set in the given report
   2.862 +--*/
   2.863 +
   2.864 +#define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
   2.865 +        HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
   2.866 +
   2.867 +
   2.868 +NTSTATUS __stdcall
   2.869 +HidP_GetUsages (
   2.870 +    HIDP_REPORT_TYPE    ReportType,
   2.871 +    USAGE   UsagePage,
   2.872 +    USHORT  LinkCollection,
   2.873 +   PUSAGE UsageList,
   2.874 +       PULONG UsageLength,
   2.875 +    PHIDP_PREPARSED_DATA PreparsedData,
   2.876 +   PCHAR Report,
   2.877 +    ULONG   ReportLength
   2.878 +   );
   2.879 +/*++
   2.880 +
   2.881 +Routine Description:
   2.882 +    This function returns the binary values (buttons) that are set in a HID
   2.883 +    report.  Given a report packet of correct length, it searches the report
   2.884 +    packet for each usage for the given usage page and returns them in the
   2.885 +    usage list.
   2.886 +
   2.887 +Parameters:
   2.888 +    ReportType One of HidP_Input, HidP_Output or HidP_Feature.
   2.889 +
   2.890 +    UsagePage  All of the usages in the usage list, which HidP_GetUsages will
   2.891 +               retrieve in the report, refer to this same usage page.
   2.892 +               If the client wishes to get usages in a packet for multiple
   2.893 +               usage pages then that client needs to make multiple calls
   2.894 +               to HidP_GetUsages.
   2.895 +
   2.896 +    LinkCollection  An optional value which can limit which usages are returned
   2.897 +                    in the UsageList to those usages that exist in a specific
   2.898 +                    LinkCollection.  A non-zero value indicates the index into
   2.899 +                    the HIDP_LINK_COLLECITON_NODE list returned by
   2.900 +                    HidP_GetLinkCollectionNodes of the link collection the
   2.901 +                    usage should belong to.  A value of 0 indicates this
   2.902 +                    should value be ignored.
   2.903 +
   2.904 +    UsageList  The usage array that will contain all the usages found in
   2.905 +               the report packet.
   2.906 +
   2.907 +    UsageLength The length of the given usage array in array elements.
   2.908 +                On input, this value describes the length of the usage list.
   2.909 +                On output, HidP_GetUsages sets this value to the number of
   2.910 +                usages that was found.  Use HidP_MaxUsageListLength to
   2.911 +                determine the maximum length needed to return all the usages
   2.912 +                that a given report packet may contain.
   2.913 +
   2.914 +    PreparsedData Preparsed data structure returned by HIDCLASS
   2.915 +
   2.916 +    Report       The report packet.
   2.917 +
   2.918 +    ReportLength  Length (in bytes) of the given report packet
   2.919 +
   2.920 +
   2.921 +Return Value
   2.922 +    HidP_GetUsages returns the following error codes:
   2.923 +
   2.924 +  HIDP_STATUS_SUCCESS                -- upon successfully retrieving all the
   2.925 +                                        usages from the report packet
   2.926 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
   2.927 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
   2.928 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
   2.929 +                                        equal to the length specified in
   2.930 +                                        the HIDP_CAPS structure for the given
   2.931 +                                        ReportType
   2.932 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
   2.933 +                                        for the given ReportType
   2.934 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if the UsageList is not big enough to
   2.935 +                                        hold all the usages found in the report
   2.936 +                                        packet.  If this is returned, the buffer
   2.937 +                                        will contain UsageLength number of
   2.938 +                                        usages.  Use HidP_MaxUsageListLength to
   2.939 +                                        find the maximum length needed
   2.940 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
   2.941 +                                        that match the UsagePage and
   2.942 +                                        LinkCollection specified could be found
   2.943 +                                        in a report with a different report ID
   2.944 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if there are no usages in a reports for
   2.945 +                                        the device and ReportType that match the
   2.946 +                                        UsagePage and LinkCollection that were
   2.947 +                                        specified
   2.948 +--*/
   2.949 +
   2.950 +#define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)  \
   2.951 +         HidP_GetUsagesEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)
   2.952 +
   2.953 +NTSTATUS __stdcall
   2.954 +HidP_GetUsagesEx (
   2.955 +        HIDP_REPORT_TYPE    ReportType,
   2.956 +        USHORT  LinkCollection, // Optional
   2.957 +    PUSAGE_AND_PAGE  ButtonList,
   2.958 +       ULONG * UsageLength,
   2.959 +     PHIDP_PREPARSED_DATA PreparsedData,
   2.960 +    reads_bytes_(ReportLength)   PCHAR   Report,
   2.961 +     ULONG  ReportLength
   2.962 +   );
   2.963 +
   2.964 +/*++
   2.965 +
   2.966 +Routine Description:
   2.967 +    This function returns the binary values (buttons) in a HID report.
   2.968 +    Given a report packet of correct length, it searches the report packet
   2.969 +    for all buttons and returns the UsagePage and Usage for each of the buttons
   2.970 +    it finds.
   2.971 +
   2.972 +Parameters:
   2.973 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
   2.974 +
   2.975 +    LinkCollection  An optional value which can limit which usages are returned
   2.976 +                    in the ButtonList to those usages that exist in a specific
   2.977 +                    LinkCollection.  A non-zero value indicates the index into
   2.978 +                    the HIDP_LINK_COLLECITON_NODE list returned by
   2.979 +                    HidP_GetLinkCollectionNodes of the link collection the
   2.980 +                    usage should belong to.  A value of 0 indicates this
   2.981 +                    should value be ignored.
   2.982 +
   2.983 +    ButtonList  An array of USAGE_AND_PAGE structures describing all the
   2.984 +                buttons currently ``down'' in the device.
   2.985 +
   2.986 +    UsageLength The length of the given array in terms of elements.
   2.987 +                On input, this value describes the length of the list.  On
   2.988 +                output, HidP_GetUsagesEx sets this value to the number of
   2.989 +                usages that were found.  Use HidP_MaxUsageListLength to
   2.990 +                determine the maximum length needed to return all the usages
   2.991 +                that a given report packet may contain.
   2.992 +
   2.993 +    PreparsedData Preparsed data returned by HIDCLASS
   2.994 +
   2.995 +    Report       The report packet.
   2.996 +
   2.997 +    ReportLength Length (in bytes) of the given report packet.
   2.998 +
   2.999 +
  2.1000 +Return Value
  2.1001 +    HidP_GetUsagesEx returns the following error codes:
  2.1002 +
  2.1003 +  HIDP_STATUS_SUCCESS                -- upon successfully retrieving all the
  2.1004 +                                        usages from the report packet
  2.1005 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1006 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1007 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1008 +                                        equal to the length specified in
  2.1009 +                                        the HIDP_CAPS structure for the given
  2.1010 +                                        ReportType
  2.1011 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
  2.1012 +                                        for the given ReportType
  2.1013 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if ButtonList is not big enough to
  2.1014 +                                        hold all the usages found in the report
  2.1015 +                                        packet.  If this is returned, the buffer
  2.1016 +                                        will contain UsageLength number of
  2.1017 +                                        usages.  Use HidP_MaxUsageListLength to
  2.1018 +                                        find the maximum length needed
  2.1019 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
  2.1020 +                                        that match the specified LinkCollection
  2.1021 +                                        exist in report with a different report
  2.1022 +                                        ID.
  2.1023 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if there are no usages in any reports that
  2.1024 +                                        match the LinkCollection parameter
  2.1025 +--*/
  2.1026 +        
  2.1027 +_IRQL_requires_max_(PASSIVE_LEVEL) 
  2.1028 +ULONG __stdcall
  2.1029 +HidP_MaxUsageListLength (
  2.1030 +    HIDP_REPORT_TYPE      ReportType,
  2.1031 +    USAGE                 UsagePage, // Optional
  2.1032 +    PHIDP_PREPARSED_DATA  PreparsedData
  2.1033 +   );
  2.1034 +/*++
  2.1035 +Routine Description:
  2.1036 +    This function returns the maximum number of usages that a call to
  2.1037 +    HidP_GetUsages or HidP_GetUsagesEx could return for a given HID report.
  2.1038 +    If calling for number of usages returned by HidP_GetUsagesEx, use 0 as
  2.1039 +    the UsagePage value.
  2.1040 +
  2.1041 +Parameters:
  2.1042 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
  2.1043 +
  2.1044 +    UsagePage   Specifies the optional UsagePage to query for.  If 0, will
  2.1045 +                return all the maximum number of usage values that could be
  2.1046 +                returned for a given ReportType.   If non-zero, will return
  2.1047 +                the maximum number of usages that would be returned for the
  2.1048 +                ReportType with the given UsagePage.
  2.1049 +
  2.1050 +    PreparsedData Preparsed data returned from HIDCLASS
  2.1051 +
  2.1052 +Return Value:
  2.1053 +    The length of the usage list array required for the HidP_GetUsages or
  2.1054 +    HidP_GetUsagesEx function call.  If an error occurs (such as
  2.1055 +    HIDP_STATUS_INVALID_REPORT_TYPE or HIDP_INVALID_PREPARSED_DATA, this
  2.1056 +    returns 0.
  2.1057 +--*/
  2.1058 +
  2.1059 +
  2.1060 +NTSTATUS __stdcall
  2.1061 +HidP_SetUsageValue (
  2.1062 +     HIDP_REPORT_TYPE ReportType,
  2.1063 +     USAGE UsagePage,
  2.1064 +     USHORT LinkCollection,
  2.1065 +     USAGE Usage,
  2.1066 +     ULONG UsageValue,
  2.1067 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1068 +    updates_bytes_(ReportLength) PCHAR Report,
  2.1069 +     ULONG ReportLength
  2.1070 +    );
  2.1071 +/*++
  2.1072 +Description:
  2.1073 +    HidP_SetUsageValue inserts a value into the HID Report Packet in the field
  2.1074 +    corresponding to the given usage page and usage.  HidP_SetUsageValue
  2.1075 +    casts this value to the appropriate bit length.  If a report packet
  2.1076 +    contains two different fields with the same Usage and UsagePage,
  2.1077 +    they can be distinguished with the optional LinkCollection field value.
  2.1078 +    Using this function sets the raw value into the report packet with
  2.1079 +    no checking done as to whether it actually falls within the logical
  2.1080 +    minimum/logical maximum range.  Use HidP_SetScaledUsageValue for this...
  2.1081 +
  2.1082 +    NOTE: Although the UsageValue parameter is a ULONG, any casting that is
  2.1083 +          done will preserve or sign-extend the value.  The value being set
  2.1084 +          should be considered a LONG value and will be treated as such by
  2.1085 +          this function.
  2.1086 +
  2.1087 +Parameters:
  2.1088 +
  2.1089 +    ReportType  One of HidP_Output or HidP_Feature.
  2.1090 +
  2.1091 +    UsagePage   The usage page to which the given usage refers.
  2.1092 +
  2.1093 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1094 +                                between two fields that may have the same
  2.1095 +                                UsagePage and Usage but exist in different
  2.1096 +                                collections.  If the link collection value
  2.1097 +                                is zero, this function will set the first field
  2.1098 +                                it finds that matches the usage page and
  2.1099 +                                usage.
  2.1100 +
  2.1101 +    Usage       The usage whose value HidP_SetUsageValue will set.
  2.1102 +
  2.1103 +    UsageValue  The raw value to set in the report buffer.  This value must be within
  2.1104 +                the logical range or if a NULL value this value should be the
  2.1105 +                most negative value that can be represented by the number of bits
  2.1106 +                for this field.
  2.1107 +
  2.1108 +    PreparsedData The preparsed data returned for HIDCLASS
  2.1109 +
  2.1110 +    Report      The report packet.
  2.1111 +
  2.1112 +    ReportLength Length (in bytes) of the given report packet.
  2.1113 +
  2.1114 +
  2.1115 +Return Value:
  2.1116 +    HidP_SetUsageValue returns the following error codes:
  2.1117 +
  2.1118 +  HIDP_STATUS_SUCCESS                -- upon successfully setting the value
  2.1119 +                                        in the report packet
  2.1120 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1121 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1122 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1123 +                                        equal to the length specified in
  2.1124 +                                        the HIDP_CAPS structure for the given
  2.1125 +                                        ReportType
  2.1126 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
  2.1127 +                                        for the given ReportType
  2.1128 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1129 +                                        link collection exist but exists in
  2.1130 +                                        a report with a different report ID
  2.1131 +                                        than the report being passed in.  To
  2.1132 +                                        set this value, call HidP_SetUsageValue
  2.1133 +                                        again with a zero-initizialed report
  2.1134 +                                        packet
  2.1135 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1136 +                                        collection combination does not exist
  2.1137 +                                        in any reports for this ReportType
  2.1138 +--*/
  2.1139 +
  2.1140 +NTSTATUS __stdcall
  2.1141 +HidP_SetScaledUsageValue (
  2.1142 +     HIDP_REPORT_TYPE ReportType,
  2.1143 +     USAGE UsagePage,
  2.1144 +     USHORT LinkCollection,
  2.1145 +     USAGE Usage,
  2.1146 +     LONG UsageValue,
  2.1147 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1148 +    updates_bytes_(ReportLength) PCHAR Report,
  2.1149 +     ULONG ReportLength
  2.1150 +    );
  2.1151 +
  2.1152 +/*++
  2.1153 +Description:
  2.1154 +    HidP_SetScaledUsageValue inserts the UsageValue into the HID report packet
  2.1155 +    in the field corresponding to the given usage page and usage.  If a report
  2.1156 +    packet contains two different fields with the same Usage and UsagePage,
  2.1157 +    they can be distinguished with the optional LinkCollection field value.
  2.1158 +
  2.1159 +    If the specified field has a defined physical range, this function converts
  2.1160 +    the physical value specified to the corresponding logical value for the
  2.1161 +    report.  If a physical value does not exist, the function will verify that
  2.1162 +    the value specified falls within the logical range and set according.
  2.1163 +
  2.1164 +    If the range checking fails but the field has NULL values, the function will
  2.1165 +    set the field to the defined NULL value (most negative number possible) and
  2.1166 +    return HIDP_STATUS_NULL.  In other words, use this function to set NULL
  2.1167 +    values for a given field by passing in a value that falls outside the
  2.1168 +    physical range if it is defined or the logical range otherwise.
  2.1169 +
  2.1170 +    If the field does not support NULL values, an out of range error will be
  2.1171 +    returned instead.
  2.1172 +
  2.1173 +Parameters:
  2.1174 +
  2.1175 +    ReportType  One of HidP_Output or HidP_Feature.
  2.1176 +
  2.1177 +    UsagePage   The usage page to which the given usage refers.
  2.1178 +
  2.1179 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1180 +                                between two fields that may have the same
  2.1181 +                                UsagePage and Usage but exist in different
  2.1182 +                                collections.  If the link collection value
  2.1183 +                                is zero, this function will set the first field
  2.1184 +                                it finds that matches the usage page and
  2.1185 +                                usage.
  2.1186 +
  2.1187 +    Usage       The usage whose value HidP_SetScaledUsageValue will set.
  2.1188 +
  2.1189 +    UsageValue  The value to set in the report buffer.  See the routine
  2.1190 +                description above for the different interpretations of this
  2.1191 +                value
  2.1192 +
  2.1193 +    PreparsedData The preparsed data returned from HIDCLASS
  2.1194 +
  2.1195 +    Report      The report packet.
  2.1196 +
  2.1197 +    ReportLength Length (in bytes) of the given report packet.
  2.1198 +
  2.1199 +
  2.1200 +Return Value:
  2.1201 +   HidP_SetScaledUsageValue returns the following error codes:
  2.1202 +
  2.1203 +  HIDP_STATUS_SUCCESS                -- upon successfully setting the value
  2.1204 +                                        in the report packet
  2.1205 +  HIDP_STATUS_NULL                   -- upon successfully setting the value
  2.1206 +                                        in the report packet as a NULL value
  2.1207 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1208 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1209 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1210 +                                        equal to the length specified in
  2.1211 +                                        the HIDP_CAPS structure for the given
  2.1212 +                                        ReportType
  2.1213 +  HIDP_STATUS_VALUEOF_RANGE     -- if the value specified failed to fall
  2.1214 +                                        within the physical range if it exists
  2.1215 +                                        or within the logical range otherwise
  2.1216 +                                        and the field specified by the usage
  2.1217 +                                        does not allow NULL values
  2.1218 +  HIDP_STATUS_BAD_LOG_PHY_VALUES     -- if the field has a physical range but
  2.1219 +                                        either the logical range is invalid
  2.1220 +                                        (max <= min) or the physical range is
  2.1221 +                                        invalid
  2.1222 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1223 +                                        link collection exist but exists in
  2.1224 +                                        a report with a different report ID
  2.1225 +                                        than the report being passed in.  To
  2.1226 +                                        set this value, call
  2.1227 +                                        HidP_SetScaledUsageValue again with
  2.1228 +                                        a zero-initialized report packet
  2.1229 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1230 +                                        collection combination does not exist
  2.1231 +                                        in any reports for this ReportType
  2.1232 +--*/
  2.1233 +
  2.1234 +NTSTATUS __stdcall
  2.1235 +HidP_SetUsageValueArray (
  2.1236 +     HIDP_REPORT_TYPE ReportType,
  2.1237 +     USAGE UsagePage,
  2.1238 +     USHORT LinkCollection,
  2.1239 +     USAGE Usage,
  2.1240 +    reads_bytes_(UsageValueByteLength) PCHAR UsageValue,
  2.1241 +     USHORT UsageValueByteLength,
  2.1242 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1243 +    updates_bytes_(ReportLength) PCHAR Report,
  2.1244 +     ULONG ReportLength
  2.1245 +    );
  2.1246 +
  2.1247 +/*++
  2.1248 +Routine Descripton:
  2.1249 +    A usage value array occurs when the last usage in the list of usages
  2.1250 +    describing a main item must be repeated because there are less usages defined
  2.1251 +    than there are report counts declared for the given main item.  In this case
  2.1252 +    a single value cap is allocated for that usage and the report count of that
  2.1253 +    value cap is set to reflect the number of fields to which that usage refers.
  2.1254 +
  2.1255 +    HidP_SetUsageValueArray sets the raw bits for that usage which spans
  2.1256 +    more than one field in a report.
  2.1257 +
  2.1258 +    NOTE: This function currently does not support value arrays where the
  2.1259 +          ReportSize for each of the fields in the array is not a multiple
  2.1260 +          of 8 bits.
  2.1261 +
  2.1262 +          The UsageValue buffer should have the values set as they would appear
  2.1263 +          in the report buffer.  If this function supported non 8-bit multiples
  2.1264 +          for the ReportSize then caller should format the input buffer so that
  2.1265 +          each new value begins at the bit immediately following the last bit
  2.1266 +          of the previous value
  2.1267 +
  2.1268 +Parameters:
  2.1269 +
  2.1270 +    ReportType  One of HidP_Output or HidP_Feature.
  2.1271 +
  2.1272 +    UsagePage   The usage page to which the given usage refers.
  2.1273 +
  2.1274 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1275 +                                between two fields that may have the same
  2.1276 +                                UsagePage and Usage but exist in different
  2.1277 +                                collections.  If the link collection value
  2.1278 +                                is zero, this function will set the first field
  2.1279 +                                it finds that matches the usage page and
  2.1280 +                                usage.
  2.1281 +
  2.1282 +    Usage       The usage whose value array HidP_SetUsageValueArray will set.
  2.1283 +
  2.1284 +    UsageValue  The buffer with the values to set into the value array.
  2.1285 +                The number of BITS required is found by multiplying the
  2.1286 +                BitSize and ReportCount fields of the Value Cap for this
  2.1287 +                control.  The least significant bit of this control found in the
  2.1288 +                given report will be placed in the least significan bit location
  2.1289 +                of the array given (little-endian format), regardless of whether
  2.1290 +                or not the field is byte alligned or if the BitSize is a multiple
  2.1291 +                of sizeof (CHAR).
  2.1292 +
  2.1293 +                See the above note for current implementation limitations.
  2.1294 +
  2.1295 +    UsageValueByteLength  Length of the UsageValue buffer (in bytes)
  2.1296 +
  2.1297 +    PreparsedData The preparsed data returned from HIDCLASS
  2.1298 +
  2.1299 +    Report      The report packet.
  2.1300 +
  2.1301 +    ReportLength Length (in bytes) of the given report packet.
  2.1302 +
  2.1303 +
  2.1304 +Return Value:
  2.1305 +  HIDP_STATUS_SUCCESS                -- upon successfully setting the value
  2.1306 +                                        array in the report packet
  2.1307 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1308 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1309 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1310 +                                        equal to the length specified in
  2.1311 +                                        the HIDP_CAPS structure for the given
  2.1312 +                                        ReportType
  2.1313 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
  2.1314 +                                        for the given ReportType
  2.1315 +  HIDP_STATUS_NOT_VALUE_ARRAY        -- if the control specified is not a
  2.1316 +                                        value array -- a value array will have
  2.1317 +                                        a ReportCount field in the
  2.1318 +                                        HIDP_VALUE_CAPS structure that is > 1
  2.1319 +                                        Use HidP_SetUsageValue instead
  2.1320 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if the size of the passed in buffer with
  2.1321 +                                        the values to set is too small (ie. has
  2.1322 +                                        fewer values than the number of fields in
  2.1323 +                                        the array
  2.1324 +  HIDP_STATUS_NOT_IMPLEMENTED        -- if the usage value array has field sizes
  2.1325 +                                        that are not multiples of 8 bits, this
  2.1326 +                                        error code is returned since the function
  2.1327 +                                        currently does not handle setting into
  2.1328 +                                        such arrays.
  2.1329 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1330 +                                        link collection exist but exists in
  2.1331 +                                        a report with a different report ID
  2.1332 +                                        than the report being passed in.  To
  2.1333 +                                        set this value, call
  2.1334 +                                        HidP_SetUsageValueArray again with
  2.1335 +                                        a zero-initialized report packet
  2.1336 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1337 +                                        collection combination does not exist
  2.1338 +                                        in any reports for this ReportType
  2.1339 +--*/
  2.1340 +
  2.1341 +
  2.1342 +NTSTATUS __stdcall
  2.1343 +HidP_GetUsageValue (
  2.1344 +     HIDP_REPORT_TYPE ReportType,
  2.1345 +     USAGE UsagePage,
  2.1346 +     USHORT LinkCollection,
  2.1347 +     USAGE Usage,
  2.1348 +     PULONG UsageValue,
  2.1349 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1350 +    reads_bytes_(ReportLength) PCHAR Report,
  2.1351 +     ULONG ReportLength
  2.1352 +    );
  2.1353 +
  2.1354 +/*
  2.1355 +Description
  2.1356 +    HidP_GetUsageValue retrieves the value from the HID Report for the usage
  2.1357 +    specified by the combination of usage page, usage and link collection.
  2.1358 +    If a report packet contains two different fields with the same
  2.1359 +    Usage and UsagePage, they can be distinguished with the optional
  2.1360 +    LinkCollection field value.
  2.1361 +
  2.1362 +Parameters:
  2.1363 +
  2.1364 +    ReportType  One of HidP_Input or HidP_Feature.
  2.1365 +
  2.1366 +    UsagePage   The usage page to which the given usage refers.
  2.1367 +
  2.1368 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1369 +                                between two fields that may have the same
  2.1370 +                                UsagePage and Usage but exist in different
  2.1371 +                                collections.  If the link collection value
  2.1372 +                                is zero, this function will set the first field
  2.1373 +                                it finds that matches the usage page and
  2.1374 +                                usage.
  2.1375 +
  2.1376 +    Usage       The usage whose value HidP_GetUsageValue will retrieve
  2.1377 +
  2.1378 +    UsageValue  The raw value that is set for the specified field in the report
  2.1379 +                buffer. This value will either fall within the logical range
  2.1380 +                or if NULL values are allowed, a number outside the range to
  2.1381 +                indicate a NULL
  2.1382 +
  2.1383 +    PreparsedData The preparsed data returned for HIDCLASS
  2.1384 +
  2.1385 +    Report      The report packet.
  2.1386 +
  2.1387 +    ReportLength Length (in bytes) of the given report packet.
  2.1388 +
  2.1389 +
  2.1390 +Return Value:
  2.1391 +    HidP_GetUsageValue returns the following error codes:
  2.1392 +
  2.1393 +  HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value
  2.1394 +                                        from the report packet
  2.1395 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1396 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1397 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1398 +                                        equal to the length specified in
  2.1399 +                                        the HIDP_CAPS structure for the given
  2.1400 +                                        ReportType
  2.1401 +  HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device
  2.1402 +                                        for the given ReportType
  2.1403 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1404 +                                        link collection exist but exists in
  2.1405 +                                        a report with a different report ID
  2.1406 +                                        than the report being passed in.  To
  2.1407 +                                        set this value, call HidP_GetUsageValue
  2.1408 +                                        again with a different report packet
  2.1409 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1410 +                                        collection combination does not exist
  2.1411 +                                        in any reports for this ReportType
  2.1412 +--*/
  2.1413 +
  2.1414 +
  2.1415 +NTSTATUS __stdcall
  2.1416 +HidP_GetScaledUsageValue (
  2.1417 +     HIDP_REPORT_TYPE ReportType,
  2.1418 +     USAGE UsagePage,
  2.1419 +     USHORT LinkCollection,
  2.1420 +     USAGE Usage,
  2.1421 +     PLONG UsageValue,
  2.1422 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1423 +    reads_bytes_(ReportLength) PCHAR Report,
  2.1424 +     ULONG ReportLength
  2.1425 +    );
  2.1426 +
  2.1427 +/*++
  2.1428 +Description
  2.1429 +    HidP_GetScaledUsageValue retrieves a UsageValue from the HID report packet
  2.1430 +    in the field corresponding to the given usage page and usage.  If a report
  2.1431 +    packet contains two different fields with the same Usage and UsagePage,
  2.1432 +    they can be distinguished with the optional LinkCollection field value.
  2.1433 +
  2.1434 +    If the specified field has a defined physical range, this function converts
  2.1435 +    the logical value that exists in the report packet to the corresponding
  2.1436 +    physical value.  If a physical range does not exist, the function will
  2.1437 +    return the logical value.  This function will check to verify that the
  2.1438 +    logical value in the report falls within the declared logical range.
  2.1439 +
  2.1440 +    When doing the conversion between logical and physical values, this
  2.1441 +    function assumes a linear extrapolation between the physical max/min and
  2.1442 +    the logical max/min. (Where logical is the values reported by the device
  2.1443 +    and physical is the value returned by this function).  If the data field
  2.1444 +    size is less than 32 bits, then HidP_GetScaledUsageValue will sign extend
  2.1445 +    the value to 32 bits.
  2.1446 +
  2.1447 +    If the range checking fails but the field has NULL values, the function
  2.1448 +    will set UsageValue to 0 and return HIDP_STATUS_NULL.  Otherwise, it
  2.1449 +    returns a HIDP_STATUSOF_RANGE error.
  2.1450 +
  2.1451 +Parameters:
  2.1452 +
  2.1453 +    ReportType  One of HidP_Output or HidP_Feature.
  2.1454 +
  2.1455 +    UsagePage   The usage page to which the given usage refers.
  2.1456 +
  2.1457 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1458 +                                between two fields that may have the same
  2.1459 +                                UsagePage and Usage but exist in different
  2.1460 +                                collections.  If the link collection value
  2.1461 +                                is zero, this function will retrieve the first
  2.1462 +                                field it finds that matches the usage page
  2.1463 +                                and usage.
  2.1464 +
  2.1465 +    Usage       The usage whose value HidP_GetScaledUsageValue will retrieve
  2.1466 +
  2.1467 +    UsageValue  The value retrieved from the report buffer.  See the routine
  2.1468 +                description above for the different interpretations of this
  2.1469 +                value
  2.1470 +
  2.1471 +    PreparsedData The preparsed data returned from HIDCLASS
  2.1472 +
  2.1473 +    Report      The report packet.
  2.1474 +
  2.1475 +    ReportLength Length (in bytes) of the given report packet.
  2.1476 +
  2.1477 +
  2.1478 +Return Value:
  2.1479 +   HidP_GetScaledUsageValue returns the following error codes:
  2.1480 +
  2.1481 +  HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value
  2.1482 +                                        from the report packet
  2.1483 +  HIDP_STATUS_NULL                   -- if the report packet had a NULL value
  2.1484 +                                        set
  2.1485 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1486 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1487 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1488 +                                        equal to the length specified in
  2.1489 +                                        the HIDP_CAPS structure for the given
  2.1490 +                                        ReportType
  2.1491 +  HIDP_STATUS_VALUEOF_RANGE     -- if the value retrieved from the packet
  2.1492 +                                        falls outside the logical range and
  2.1493 +                                        the field does not support NULL values
  2.1494 +  HIDP_STATUS_BAD_LOG_PHY_VALUES     -- if the field has a physical range but
  2.1495 +                                        either the logical range is invalid
  2.1496 +                                        (max <= min) or the physical range is
  2.1497 +                                        invalid
  2.1498 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1499 +                                        link collection exist but exists in
  2.1500 +                                        a report with a different report ID
  2.1501 +                                        than the report being passed in.  To
  2.1502 +                                        set this value, call
  2.1503 +                                        HidP_GetScaledUsageValue with a
  2.1504 +                                        different report packet
  2.1505 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1506 +                                        collection combination does not exist
  2.1507 +                                        in any reports for this ReportType
  2.1508 +--*/
  2.1509 +
  2.1510 +NTSTATUS __stdcall
  2.1511 +HidP_GetUsageValueArray (
  2.1512 +     HIDP_REPORT_TYPE ReportType,
  2.1513 +     USAGE UsagePage,
  2.1514 +     USHORT LinkCollection,
  2.1515 +     USAGE Usage,
  2.1516 +    updates_bytes_(UsageValueByteLength) PCHAR UsageValue,
  2.1517 +     USHORT UsageValueByteLength,
  2.1518 +     PHIDP_PREPARSED_DATA PreparsedData,
  2.1519 +    reads_bytes_(ReportLength) PCHAR Report,
  2.1520 +     ULONG ReportLength
  2.1521 +    );
  2.1522 +
  2.1523 +/*++
  2.1524 +Routine Descripton:
  2.1525 +    A usage value array occurs when the last usage in the list of usages
  2.1526 +    describing a main item must be repeated because there are less usages defined
  2.1527 +    than there are report counts declared for the given main item.  In this case
  2.1528 +    a single value cap is allocated for that usage and the report count of that
  2.1529 +    value cap is set to reflect the number of fields to which that usage refers.
  2.1530 +
  2.1531 +    HidP_GetUsageValueArray returns the raw bits for that usage which spans
  2.1532 +    more than one field in a report.
  2.1533 +
  2.1534 +    NOTE: This function currently does not support value arrays where the
  2.1535 +          ReportSize for each of the fields in the array is not a multiple
  2.1536 +          of 8 bits.
  2.1537 +
  2.1538 +          The UsageValue buffer will have the raw values as they are set
  2.1539 +          in the report packet.
  2.1540 +
  2.1541 +Parameters:
  2.1542 +
  2.1543 +    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.
  2.1544 +
  2.1545 +    UsagePage   The usage page to which the given usage refers.
  2.1546 +
  2.1547 +    LinkCollection  (Optional)  This value can be used to differentiate
  2.1548 +                                between two fields that may have the same
  2.1549 +                                UsagePage and Usage but exist in different
  2.1550 +                                collections.  If the link collection value
  2.1551 +                                is zero, this function will set the first field
  2.1552 +                                it finds that matches the usage page and
  2.1553 +                                usage.
  2.1554 +
  2.1555 +   Usage       The usage whose value HidP_GetUsageValueArray will retreive.
  2.1556 +
  2.1557 +   UsageValue  A pointer to an array of characters where the value will be
  2.1558 +               placed.  The number of BITS required is found by multiplying the
  2.1559 +               BitSize and ReportCount fields of the Value Cap for this
  2.1560 +               control.  The least significant bit of this control found in the
  2.1561 +               given report will be placed in the least significant bit location
  2.1562 +               of the buffer (little-endian format), regardless of whether
  2.1563 +               or not the field is byte aligned or if the BitSize is a multiple
  2.1564 +               of sizeof (CHAR).
  2.1565 +
  2.1566 +               See note above about current implementation limitations
  2.1567 +
  2.1568 +   UsageValueByteLength
  2.1569 +               the length of the given UsageValue buffer.
  2.1570 +
  2.1571 +   PreparsedData The preparsed data returned by the HIDCLASS
  2.1572 +
  2.1573 +   Report      The report packet.
  2.1574 +
  2.1575 +   ReportLength   Length of the given report packet.
  2.1576 +
  2.1577 +Return Value:
  2.1578 +
  2.1579 +  HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value
  2.1580 +                                        from the report packet
  2.1581 +  HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.
  2.1582 +  HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  2.1583 +  HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not
  2.1584 +                                        equal to the length specified in
  2.1585 +                                        the HIDP_CAPS structure for the given
  2.1586 +                                        ReportType
  2.1587 +  HIDP_STATUS_NOT_VALUE_ARRAY        -- if the control specified is not a
  2.1588 +                                        value array -- a value array will have
  2.1589 +                                        a ReportCount field in the
  2.1590 +                                        HIDP_VALUE_CAPS structure that is > 1
  2.1591 +                                        Use HidP_GetUsageValue instead
  2.1592 +  HIDP_STATUS_BUFFER_TOO_SMALL       -- if the size of the passed in buffer in
  2.1593 +                                        which to return the array is too small
  2.1594 +                                        (ie. has fewer values than the number of
  2.1595 +                                        fields in the array
  2.1596 +  HIDP_STATUS_NOT_IMPLEMENTED        -- if the usage value array has field sizes
  2.1597 +                                        that are not multiples of 8 bits, this
  2.1598 +                                        error code is returned since the function
  2.1599 +                                        currently does not handle getting values
  2.1600 +                                        from such arrays.
  2.1601 +  HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  2.1602 +                                        link collection exist but exists in
  2.1603 +                                        a report with a different report ID
  2.1604 +                                        than the report being passed in.  To
  2.1605 +                                        set this value, call
  2.1606 +                                        HidP_GetUsageValueArray with a
  2.1607 +                                        different report packet
  2.1608 +  HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link
  2.1609 +                                        collection combination does not exist
  2.1610 +                                        in any reports for this ReportType
  2.1611 +--*/
  2.1612 +
  2.1613 +
  2.1614 +_IRQL_requires_max_(PASSIVE_LEVEL)
  2.1615 +NTSTATUS __stdcall
  2.1616 +HidP_UsageListDifference (
  2.1617 +   reads_(UsageListLength) PUSAGE  PreviousUsageList,
  2.1618 +   reads_(UsageListLength) PUSAGE  CurrentUsageList,
  2.1619 +   writes_(UsageListLength) PUSAGE  BreakUsageList,
  2.1620 +   writes_(UsageListLength) PUSAGE  MakeUsageList,
  2.1621 +    ULONG    UsageListLength
  2.1622 +    );
  2.1623 +/*++
  2.1624 +Routine Description:
  2.1625 +    This function will return the difference between a two lists of usages
  2.1626 +    (as might be returned from HidP_GetUsages),  In other words, it will return
  2.1627 +    return a list of usages that are in the current list but not the previous
  2.1628 +    list as well as a list of usages that are in the previous list but not
  2.1629 +    the current list.
  2.1630 +
  2.1631 +Parameters:
  2.1632 +
  2.1633 +    PreviousUsageList   The list of usages before.
  2.1634 +    CurrentUsageList    The list of usages now.
  2.1635 +    BreakUsageList      Previous - Current.
  2.1636 +    MakeUsageList       Current - Previous.
  2.1637 +    UsageListLength     Represents the length of the usage lists in array
  2.1638 +                        elements.  If comparing two lists with a differing
  2.1639 +                        number of array elements, this value should be
  2.1640 +                        the size of the larger of the two lists.  Any
  2.1641 +                        zero found with a list indicates an early termination
  2.1642 +                        of the list and any usages found after the first zero
  2.1643 +                        will be ignored.
  2.1644 +--*/
  2.1645 +
  2.1646 +
  2.1647 +_IRQL_requires_max_(PASSIVE_LEVEL)
  2.1648 +NTSTATUS __stdcall
  2.1649 +HidP_UsageAndPageListDifference (
  2.1650 +   reads_(UsageListLength) PUSAGE_AND_PAGE PreviousUsageList,
  2.1651 +   reads_(UsageListLength) PUSAGE_AND_PAGE CurrentUsageList,
  2.1652 +   writes_(UsageListLength) PUSAGE_AND_PAGE BreakUsageList,
  2.1653 +   writes_(UsageListLength) PUSAGE_AND_PAGE MakeUsageList,
  2.1654 +    ULONG           UsageListLength
  2.1655 +   );
  2.1656 +
  2.1657 +//
  2.1658 +// Produce Make or Break Codes
  2.1659 +//
  2.1660 +typedef enum _HIDP_KEYBOARD_DIRECTION {
  2.1661 +    HidP_Keyboard_Break,
  2.1662 +    HidP_Keyboard_Make
  2.1663 +} HIDP_KEYBOARD_DIRECTION;
  2.1664 +
  2.1665 +//
  2.1666 +// A bitmap of the current shift state of the keyboard when using the
  2.1667 +// below keyboard usages to i8042 translation function.
  2.1668 +//
  2.1669 +typedef struct _HIDP_KEYBOARD_MODIFIER_STATE {
  2.1670 +   union {
  2.1671 +      struct {
  2.1672 +         ULONG LeftControl: 1;
  2.1673 +         ULONG LeftShift: 1;
  2.1674 +         ULONG LeftAlt: 1;
  2.1675 +         ULONG LeftGUI: 1;
  2.1676 +         ULONG RightControl: 1;
  2.1677 +         ULONG RightShift: 1;
  2.1678 +         ULONG RightAlt: 1;
  2.1679 +         ULONG RigthGUI: 1;
  2.1680 +         ULONG CapsLock: 1;
  2.1681 +         ULONG ScollLock: 1;
  2.1682 +         ULONG NumLock: 1;
  2.1683 +         ULONG Reserved: 21;
  2.1684 +      };
  2.1685 +      ULONG ul;
  2.1686 +   };
  2.1687 +
  2.1688 +} HIDP_KEYBOARD_MODIFIER_STATE, * PHIDP_KEYBOARD_MODIFIER_STATE;
  2.1689 +
  2.1690 +//
  2.1691 +// A call back function to give the i8042 scan codes to the caller of
  2.1692 +// the below translation function.
  2.1693 +//
  2.1694 +typedef BOOLEAN (* PHIDP_INSERT_SCANCODES) (
  2.1695 +                   PVOID Context,  // Some caller supplied context.
  2.1696 +                  reads_bytes_(Length) PCHAR NewScanCodes, // A list of i8042 scan codes.
  2.1697 +                   ULONG Length // the length of the scan codes.
  2.1698 +                  );
  2.1699 +
  2.1700 +
  2.1701 +NTSTATUS __stdcall
  2.1702 +HidP_TranslateUsageAndPagesToI8042ScanCodes (
  2.1703 +    reads_(UsageListLength)     PUSAGE_AND_PAGE ChangedUsageList,
  2.1704 +         ULONG                         UsageListLength,
  2.1705 +         HIDP_KEYBOARD_DIRECTION       KeyAction,
  2.1706 +      PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
  2.1707 +         PHIDP_INSERT_SCANCODES        InsertCodesProcedure,
  2.1708 +     PVOID                         InsertCodesContext
  2.1709 +    );
  2.1710 +/*++
  2.1711 +Routine Description:
  2.1712 +Parameters:
  2.1713 +--*/
  2.1714 +
  2.1715 +NTSTATUS __stdcall
  2.1716 +HidP_TranslateUsagesToI8042ScanCodes (
  2.1717 +    reads_(UsageListLength)     PUSAGE ChangedUsageList,
  2.1718 +         ULONG                         UsageListLength,
  2.1719 +         HIDP_KEYBOARD_DIRECTION       KeyAction,
  2.1720 +      PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
  2.1721 +         PHIDP_INSERT_SCANCODES        InsertCodesProcedure,
  2.1722 +     PVOID                         InsertCodesContext
  2.1723 +    );
  2.1724 +/*++
  2.1725 +Routine Description:
  2.1726 +Parameters:
  2.1727 +--*/
  2.1728 +
  2.1729 +
  2.1730 +
  2.1731 +//
  2.1732 +// Define NT Status codes with Facility Code of FACILITY_HID_ERROR_CODE
  2.1733 +//
  2.1734 +
  2.1735 +// FACILITY_HID_ERROR_CODE defined in ntstatus.h
  2.1736 +#ifndef FACILITY_HID_ERROR_CODE
  2.1737 +#define FACILITY_HID_ERROR_CODE 0x11
  2.1738 +#endif
  2.1739 +
  2.1740 +#define HIDP_ERROR_CODES(SEV, CODE) \
  2.1741 +        ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
  2.1742 +
  2.1743 +#define HIDP_STATUS_SUCCESS                  (HIDP_ERROR_CODES(0x0,0))
  2.1744 +#define HIDP_STATUS_NULL                     (HIDP_ERROR_CODES(0x8,1))
  2.1745 +#define HIDP_STATUS_INVALID_PREPARSED_DATA   (HIDP_ERROR_CODES(0xC,1))
  2.1746 +#define HIDP_STATUS_INVALID_REPORT_TYPE      (HIDP_ERROR_CODES(0xC,2))
  2.1747 +#define HIDP_STATUS_INVALID_REPORT_LENGTH    (HIDP_ERROR_CODES(0xC,3))
  2.1748 +#define HIDP_STATUS_USAGE_NOT_FOUND          (HIDP_ERROR_CODES(0xC,4))
  2.1749 +#define HIDP_STATUS_VALUEOF_RANGE       (HIDP_ERROR_CODES(0xC,5))
  2.1750 +#define HIDP_STATUS_BAD_LOG_PHY_VALUES       (HIDP_ERROR_CODES(0xC,6))
  2.1751 +#define HIDP_STATUS_BUFFER_TOO_SMALL         (HIDP_ERROR_CODES(0xC,7))
  2.1752 +#define HIDP_STATUS_INTERNAL_ERROR           (HIDP_ERROR_CODES(0xC,8))
  2.1753 +#define HIDP_STATUS_I8042_TRANS_UNKNOWN      (HIDP_ERROR_CODES(0xC,9))
  2.1754 +#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID   (HIDP_ERROR_CODES(0xC,0xA))
  2.1755 +#define HIDP_STATUS_NOT_VALUE_ARRAY          (HIDP_ERROR_CODES(0xC,0xB))
  2.1756 +#define HIDP_STATUS_IS_VALUE_ARRAY           (HIDP_ERROR_CODES(0xC,0xC))
  2.1757 +#define HIDP_STATUS_DATA_INDEX_NOT_FOUND     (HIDP_ERROR_CODES(0xC,0xD))
  2.1758 +#define HIDP_STATUS_DATA_INDEXOF_RANGE  (HIDP_ERROR_CODES(0xC,0xE))
  2.1759 +#define HIDP_STATUS_BUTTON_NOT_PRESSED       (HIDP_ERROR_CODES(0xC,0xF))
  2.1760 +#define HIDP_STATUS_REPORT_DOES_NOT_EXIST    (HIDP_ERROR_CODES(0xC,0x10))
  2.1761 +#define HIDP_STATUS_NOT_IMPLEMENTED          (HIDP_ERROR_CODES(0xC,0x20))
  2.1762 +
  2.1763 +//
  2.1764 +// We blundered this status code.
  2.1765 +//
  2.1766 +#define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
  2.1767 +
  2.1768 +/*++
  2.1769 +
  2.1770 +Copyright (c) Microsoft Corporation. All rights reserved.
  2.1771 +
  2.1772 +Module Name:
  2.1773 +
  2.1774 +    HIDSDI.H
  2.1775 +
  2.1776 +Abstract:
  2.1777 +
  2.1778 +    This module contains the PUBLIC definitions for the
  2.1779 +    code that implements the HID dll.
  2.1780 +
  2.1781 +Environment:
  2.1782 +
  2.1783 +    Kernel & user mode
  2.1784 +
  2.1785 +--*/
  2.1786 +
  2.1787 +
  2.1788 +
  2.1789 +
  2.1790 +typedef struct _HIDD_CONFIGURATION {
  2.1791 +    PVOID    cookie;
  2.1792 +    ULONG    size;
  2.1793 +    ULONG    RingBufferSize;
  2.1794 +} HIDD_CONFIGURATION, *PHIDD_CONFIGURATION;
  2.1795 +
  2.1796 +typedef struct _HIDD_ATTRIBUTES {
  2.1797 +    ULONG   Size; // = sizeof (struct _HIDD_ATTRIBUTES)
  2.1798 +
  2.1799 +    //
  2.1800 +    // Vendor ids of this hid device
  2.1801 +    //
  2.1802 +    USHORT  VendorID;
  2.1803 +    USHORT  ProductID;
  2.1804 +    USHORT  VersionNumber;
  2.1805 +
  2.1806 +    //
  2.1807 +    // Additional fields will be added to the end of this structure.
  2.1808 +    //
  2.1809 +} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
  2.1810 +
  2.1811 +
  2.1812 +BOOLEAN __stdcall
  2.1813 +HidD_GetAttributes (
  2.1814 +      HANDLE              HidDeviceObject,
  2.1815 +     PHIDD_ATTRIBUTES    Attributes
  2.1816 +    );
  2.1817 +/*++
  2.1818 +Routine Description:
  2.1819 +    Fill in the given HIDD_ATTRIBUTES structure with the attributes of the
  2.1820 +    given hid device.
  2.1821 +
  2.1822 +--*/
  2.1823 +
  2.1824 +
  2.1825 +void __stdcall
  2.1826 +HidD_GetHidGuid (
  2.1827 +     LPGUID   HidGuid
  2.1828 +   );
  2.1829 +
  2.1830 +
  2.1831 +BOOLEAN __stdcall
  2.1832 +HidD_GetPreparsedData (
  2.1833 +      HANDLE                  HidDeviceObject,
  2.1834 +    PHIDP_PREPARSED_DATA  * PreparsedData
  2.1835 +   );
  2.1836 +/*++
  2.1837 +Routine Description:
  2.1838 +    Given a handle to a valid Hid Class Device Object, retrieve the preparsed
  2.1839 +    data for the device.  This routine will allocate the appropriately 
  2.1840 +    sized buffer to hold this preparsed data.  It is up to client to call
  2.1841 +    HidP_FreePreparsedData to free the memory allocated to this structure when
  2.1842 +    it is no longer needed.
  2.1843 +
  2.1844 +Arguments:
  2.1845 +   HidDeviceObject A handle to a Hid Device that the client obtains using 
  2.1846 +                   a call to CreateFile on a valid Hid device string name.
  2.1847 +                   The string name can be obtained using standard PnP calls.
  2.1848 +
  2.1849 +   PreparsedData   An opaque data structure used by other functions in this 
  2.1850 +                   library to retrieve information about a given device.
  2.1851 +
  2.1852 +Return Value:
  2.1853 +   TRUE if successful.
  2.1854 +   FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1855 +--*/
  2.1856 +BOOLEAN __stdcall
  2.1857 +HidD_FreePreparsedData (
  2.1858 +    __drv_freesMem(Mem) PHIDP_PREPARSED_DATA PreparsedData
  2.1859 +   );
  2.1860 +
  2.1861 +BOOLEAN __stdcall
  2.1862 +HidD_FlushQueue (
  2.1863 +       HANDLE                HidDeviceObject
  2.1864 +   );
  2.1865 +/*++
  2.1866 +Routine Description:
  2.1867 +    Flush the input queue for the given HID device.
  2.1868 +
  2.1869 +Arguments:
  2.1870 +   HidDeviceObject A handle to a Hid Device that the client obtains using 
  2.1871 +                   a call to CreateFile on a valid Hid device string name.
  2.1872 +                   The string name can be obtained using standard PnP calls.
  2.1873 +
  2.1874 +Return Value:
  2.1875 +   TRUE if successful
  2.1876 +   FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1877 +--*/
  2.1878 +
  2.1879 +BOOLEAN __stdcall
  2.1880 +HidD_GetConfiguration (
  2.1881 +      HANDLE               HidDeviceObject,
  2.1882 +   PHIDD_CONFIGURATION Configuration,
  2.1883 +      ULONG                ConfigurationLength
  2.1884 +   );
  2.1885 +/*++
  2.1886 +Routine Description:
  2.1887 +    Get the configuration information for this Hid device
  2.1888 +
  2.1889 +Arguments:
  2.1890 +   HidDeviceObject      A handle to a Hid Device Object.
  2.1891 +
  2.1892 +   Configuration        A configuration structure.  HidD_GetConfiguration MUST
  2.1893 +                        be called before the configuration can be modified and
  2.1894 +                        set using HidD_SetConfiguration
  2.1895 +
  2.1896 +   ConfigurationLength  That is ``sizeof (HIDD_CONFIGURATION)''. Using this
  2.1897 +                        parameter, we can later increase the length of the 
  2.1898 +                        configuration array and not break older apps.
  2.1899 +
  2.1900 +Return Value:
  2.1901 +   TRUE if successful
  2.1902 +   FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1903 +--*/
  2.1904 +
  2.1905 +BOOLEAN __stdcall
  2.1906 +HidD_SetConfiguration (
  2.1907 +      HANDLE               HidDeviceObject,
  2.1908 +   reads_bytes_(ConfigurationLength) PHIDD_CONFIGURATION Configuration,
  2.1909 +      ULONG                ConfigurationLength
  2.1910 +   );
  2.1911 +/*++
  2.1912 +Routine Description:
  2.1913 +   Set the configuration information for this Hid device...
  2.1914 +   
  2.1915 +   NOTE: HidD_GetConfiguration must be called to retrieve the current 
  2.1916 +         configuration information before this information can be modified 
  2.1917 +         and set.
  2.1918 +
  2.1919 +Arguments:
  2.1920 +    HidDeviceObject      A handle to a Hid Device Object.
  2.1921 + 
  2.1922 +    Configuration        A configuration structure.  HidD_GetConfiguration MUST
  2.1923 +                         be called before the configuration can be modified and
  2.1924 +                         set using HidD_SetConfiguration
  2.1925 + 
  2.1926 +    ConfigurationLength  That is ``sizeof (HIDD_CONFIGURATION)''. Using this
  2.1927 +                         parameter, we can later increase the length of the 
  2.1928 +                         configuration array and not break older apps.
  2.1929 +
  2.1930 +Return Value:
  2.1931 +    TRUE if successful
  2.1932 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1933 +--*/
  2.1934 +
  2.1935 +BOOLEAN __stdcall
  2.1936 +HidD_GetFeature (
  2.1937 +       HANDLE   HidDeviceObject,
  2.1938 +   PVOID ReportBuffer,
  2.1939 +       ULONG    ReportBufferLength
  2.1940 +   );
  2.1941 +/*++
  2.1942 +Routine Description:
  2.1943 +    Retrieve a feature report from a HID device.
  2.1944 +
  2.1945 +Arguments:
  2.1946 +    HidDeviceObject      A handle to a Hid Device Object.
  2.1947 + 
  2.1948 +    ReportBuffer         The buffer that the feature report should be placed 
  2.1949 +                         into.  The first byte of the buffer should be set to
  2.1950 +                         the report ID of the desired report
  2.1951 + 
  2.1952 +    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value 
  2.1953 +                         should be greater than or equal to the 
  2.1954 +                         FeatureReportByteLength field as specified in the 
  2.1955 +                         HIDP_CAPS structure for the device
  2.1956 +Return Value:
  2.1957 +    TRUE if successful
  2.1958 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1959 +--*/
  2.1960 +
  2.1961 +BOOLEAN __stdcall
  2.1962 +HidD_SetFeature (
  2.1963 +       HANDLE   HidDeviceObject,
  2.1964 +   reads_bytes_(ReportBufferLength) PVOID ReportBuffer,
  2.1965 +       ULONG    ReportBufferLength
  2.1966 +   );
  2.1967 +/*++
  2.1968 +Routine Description:
  2.1969 +    Send a feature report to a HID device.
  2.1970 +
  2.1971 +Arguments:
  2.1972 +    HidDeviceObject      A handle to a Hid Device Object.
  2.1973 + 
  2.1974 +    ReportBuffer         The buffer of the feature report to send to the device
  2.1975 + 
  2.1976 +    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value 
  2.1977 +                         should be greater than or equal to the 
  2.1978 +                         FeatureReportByteLength field as specified in the 
  2.1979 +                         HIDP_CAPS structure for the device
  2.1980 +Return Value:
  2.1981 +    TRUE if successful
  2.1982 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.1983 +--*/
  2.1984 +
  2.1985 +
  2.1986 +
  2.1987 +BOOLEAN __stdcall
  2.1988 +HidD_GetInputReport (
  2.1989 +       HANDLE   HidDeviceObject,
  2.1990 +   PVOID ReportBuffer,
  2.1991 +       ULONG    ReportBufferLength
  2.1992 +   );
  2.1993 +/*++
  2.1994 +Routine Description:
  2.1995 +    Retrieve an input report from a HID device.
  2.1996 +
  2.1997 +Arguments:
  2.1998 +    HidDeviceObject      A handle to a Hid Device Object.
  2.1999 + 
  2.2000 +    ReportBuffer         The buffer that the input report should be placed 
  2.2001 +                         into.  The first byte of the buffer should be set to
  2.2002 +                         the report ID of the desired report
  2.2003 + 
  2.2004 +    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value 
  2.2005 +                         should be greater than or equal to the 
  2.2006 +                         InputReportByteLength field as specified in the 
  2.2007 +                         HIDP_CAPS structure for the device
  2.2008 +Return Value:
  2.2009 +    TRUE if successful
  2.2010 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2011 +--*/
  2.2012 +
  2.2013 +BOOLEAN __stdcall
  2.2014 +HidD_SetOutputReport (
  2.2015 +       HANDLE   HidDeviceObject,
  2.2016 +   reads_bytes_(ReportBufferLength) PVOID ReportBuffer,
  2.2017 +       ULONG    ReportBufferLength
  2.2018 +   );
  2.2019 +/*++
  2.2020 +Routine Description:
  2.2021 +    Send an output report to a HID device.
  2.2022 +
  2.2023 +Arguments:
  2.2024 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2025 + 
  2.2026 +    ReportBuffer         The buffer of the output report to send to the device
  2.2027 + 
  2.2028 +    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value 
  2.2029 +                         should be greater than or equal to the 
  2.2030 +                         OutputReportByteLength field as specified in the 
  2.2031 +                         HIDP_CAPS structure for the device
  2.2032 +Return Value:
  2.2033 +    TRUE if successful
  2.2034 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2035 +--*/
  2.2036 +
  2.2037 +#endif
  2.2038 +
  2.2039 +BOOLEAN __stdcall
  2.2040 +HidD_GetNumInputBuffers (
  2.2041 +      HANDLE  HidDeviceObject,
  2.2042 +     PULONG  NumberBuffers
  2.2043 +    );
  2.2044 +/*++
  2.2045 +Routine Description:
  2.2046 +    This function returns the number of input buffers used by the specified
  2.2047 +    file handle to the Hid device.  Each file object has a number of buffers
  2.2048 +    associated with it to queue reports read from the device but which have
  2.2049 +    not yet been read by the user-mode app with a handle to that device.
  2.2050 +
  2.2051 +Arguments:
  2.2052 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2053 + 
  2.2054 +    NumberBuffers        Number of buffers currently being used for this file
  2.2055 +                         handle to the Hid device
  2.2056 +
  2.2057 +Return Value:
  2.2058 +    TRUE if successful
  2.2059 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2060 +--*/
  2.2061 +
  2.2062 +BOOLEAN __stdcall
  2.2063 +HidD_SetNumInputBuffers (
  2.2064 +     HANDLE HidDeviceObject,
  2.2065 +     ULONG  NumberBuffers
  2.2066 +    );
  2.2067 +/*++
  2.2068 +
  2.2069 +Routine Description:
  2.2070 +    This function sets the number of input buffers used by the specified
  2.2071 +    file handle to the Hid device.  Each file object has a number of buffers
  2.2072 +    associated with it to queue reports read from the device but which have
  2.2073 +    not yet been read by the user-mode app with a handle to that device.
  2.2074 +
  2.2075 +Arguments:
  2.2076 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2077 + 
  2.2078 +    NumberBuffers        New number of buffers to use for this file handle to
  2.2079 +                         the Hid device
  2.2080 +
  2.2081 +Return Value:
  2.2082 +    TRUE if successful
  2.2083 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2084 +--*/
  2.2085 +
  2.2086 +BOOLEAN __stdcall
  2.2087 +HidD_GetPhysicalDescriptor (
  2.2088 +       HANDLE   HidDeviceObject,
  2.2089 +   PVOID Buffer,
  2.2090 +       ULONG    BufferLength
  2.2091 +   );
  2.2092 +/*++
  2.2093 +Routine Description:
  2.2094 +    This function retrieves the raw physical descriptor for the specified
  2.2095 +    Hid device.  
  2.2096 +
  2.2097 +Arguments:
  2.2098 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2099 + 
  2.2100 +    Buffer               Buffer which on return will contain the physical
  2.2101 +                         descriptor if one exists for the specified device
  2.2102 +                         handle
  2.2103 +
  2.2104 +    BufferLength         Length of buffer (in bytes)
  2.2105 +
  2.2106 +
  2.2107 +Return Value:
  2.2108 +    TRUE if successful
  2.2109 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2110 +--*/
  2.2111 +
  2.2112 +BOOLEAN __stdcall
  2.2113 +HidD_GetManufacturerString (
  2.2114 +       HANDLE   HidDeviceObject,
  2.2115 +   PVOID Buffer,
  2.2116 +       ULONG    BufferLength
  2.2117 +   );
  2.2118 +/*++
  2.2119 +Routine Description:
  2.2120 +    This function retrieves the manufacturer string from the specified 
  2.2121 +    Hid device.  
  2.2122 +
  2.2123 +Arguments:
  2.2124 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2125 + 
  2.2126 +    Buffer               Buffer which on return will contain the manufacturer
  2.2127 +                         string returned from the device.  This string is a 
  2.2128 +                         wide-character string
  2.2129 +
  2.2130 +    BufferLength         Length of Buffer (in bytes)
  2.2131 +
  2.2132 +
  2.2133 +Return Value:
  2.2134 +    TRUE if successful
  2.2135 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2136 +--*/
  2.2137 +
  2.2138 +BOOLEAN __stdcall
  2.2139 +HidD_GetProductString (
  2.2140 +       HANDLE   HidDeviceObject,
  2.2141 +   PVOID Buffer,
  2.2142 +       ULONG    BufferLength
  2.2143 +   );
  2.2144 +/*++
  2.2145 +Routine Description:
  2.2146 +    This function retrieves the product string from the specified 
  2.2147 +    Hid device.  
  2.2148 +
  2.2149 +Arguments:
  2.2150 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2151 + 
  2.2152 +    Buffer               Buffer which on return will contain the product
  2.2153 +                         string returned from the device.  This string is a 
  2.2154 +                         wide-character string
  2.2155 +
  2.2156 +    BufferLength         Length of Buffer (in bytes)
  2.2157 +
  2.2158 +
  2.2159 +Return Value:
  2.2160 +    TRUE if successful
  2.2161 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2162 +--*/
  2.2163 +
  2.2164 +BOOLEAN __stdcall
  2.2165 +HidD_GetIndexedString (
  2.2166 +       HANDLE   HidDeviceObject,
  2.2167 +       ULONG    StringIndex,
  2.2168 +   PVOID Buffer,
  2.2169 +       ULONG    BufferLength
  2.2170 +   );
  2.2171 +/*++
  2.2172 +Routine Description:
  2.2173 +    This function retrieves a string from the specified Hid device that is
  2.2174 +    specified with a certain string index.
  2.2175 +
  2.2176 +Arguments:
  2.2177 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2178 + 
  2.2179 +    StringIndex          Index of the string to retrieve
  2.2180 +
  2.2181 +    Buffer               Buffer which on return will contain the product
  2.2182 +                         string returned from the device.  This string is a 
  2.2183 +                         wide-character string
  2.2184 +
  2.2185 +    BufferLength         Length of Buffer (in bytes)
  2.2186 +
  2.2187 +Return Value:
  2.2188 +    TRUE if successful
  2.2189 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2190 +--*/
  2.2191 +
  2.2192 +BOOLEAN __stdcall
  2.2193 +HidD_GetSerialNumberString (
  2.2194 +       HANDLE   HidDeviceObject,
  2.2195 +   PVOID Buffer,
  2.2196 +       ULONG    BufferLength
  2.2197 +   );
  2.2198 +/*++
  2.2199 +Routine Description:
  2.2200 +    This function retrieves the serial number string from the specified 
  2.2201 +    Hid device.  
  2.2202 +
  2.2203 +Arguments:
  2.2204 +    HidDeviceObject      A handle to a Hid Device Object.
  2.2205 + 
  2.2206 +    Buffer               Buffer which on return will contain the serial number
  2.2207 +                         string returned from the device.  This string is a 
  2.2208 +                         wide-character string
  2.2209 +
  2.2210 +    BufferLength         Length of Buffer (in bytes)
  2.2211 +
  2.2212 +Return Value:
  2.2213 +    TRUE if successful
  2.2214 +    FALSE otherwise  -- Use GetLastError() to get extended error information
  2.2215 +--*/
  2.2216 +
  2.2217 +
  2.2218 +
  2.2219 +BOOLEAN __stdcall
  2.2220 +HidD_GetMsGenreDescriptor (
  2.2221 +       HANDLE   HidDeviceObject,
  2.2222 +   PVOID Buffer,
  2.2223 +       ULONG    BufferLength
  2.2224 +   );
  2.2225 +
  2.2226 +
  2.2227 +
  2.2228 +
  2.2229 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pinvoke-interop-assistant-input.c	Sat Feb 14 22:11:36 2015 +0100
     3.3 @@ -0,0 +1,141 @@
     3.4 +
     3.5 +typedef USHORT USAGE, *PUSAGE;
     3.6 +typedef LONG NTSTATUS;
     3.7 +
     3.8 +typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;
     3.9 +
    3.10 +typedef enum _HIDP_REPORT_TYPE
    3.11 +{
    3.12 +    HidP_Input,
    3.13 +    HidP_Output,
    3.14 +    HidP_Feature
    3.15 +} HIDP_REPORT_TYPE;
    3.16 +
    3.17 +typedef struct _HIDP_CAPS
    3.18 +{
    3.19 +    USAGE    Usage;
    3.20 +    USAGE    UsagePage;
    3.21 +    USHORT   InputReportByteLength;
    3.22 +    USHORT   OutputReportByteLength;
    3.23 +    USHORT   FeatureReportByteLength;
    3.24 +    USHORT   Reserved[17];
    3.25 +
    3.26 +    USHORT   NumberLinkCollectionNodes;
    3.27 +
    3.28 +    USHORT   NumberInputButtonCaps;
    3.29 +    USHORT   NumberInputValueCaps;
    3.30 +    USHORT   NumberInputDataIndices;
    3.31 +
    3.32 +    USHORT   NumberOutputButtonCaps;
    3.33 +    USHORT   NumberOutputValueCaps;
    3.34 +    USHORT   NumberOutputDataIndices;
    3.35 +
    3.36 +    USHORT   NumberFeatureButtonCaps;
    3.37 +    USHORT   NumberFeatureValueCaps;
    3.38 +    USHORT   NumberFeatureDataIndices;
    3.39 +} HIDP_CAPS, *PHIDP_CAPS;
    3.40 +
    3.41 +
    3.42 +typedef struct _HIDP_BUTTON_CAPS
    3.43 +{
    3.44 +    USAGE    UsagePage;
    3.45 +    UCHAR    ReportID;
    3.46 +    BOOLEAN  IsAlias;
    3.47 +
    3.48 +    USHORT   BitField;
    3.49 +    USHORT   LinkCollection;   // A unique internal index pointer
    3.50 +
    3.51 +    USAGE    LinkUsage;
    3.52 +    USAGE    LinkUsagePage;
    3.53 +
    3.54 +    BOOLEAN  IsRange;
    3.55 +    BOOLEAN  IsStringRange;
    3.56 +    BOOLEAN  IsDesignatorRange;
    3.57 +    BOOLEAN  IsAbsolute;
    3.58 +
    3.59 +    ULONG    Reserved[10];
    3.60 +    union {
    3.61 +        struct {
    3.62 +            USAGE    UsageMin,         UsageMax;
    3.63 +            USHORT   StringMin,        StringMax;
    3.64 +            USHORT   DesignatorMin,    DesignatorMax;
    3.65 +            USHORT   DataIndexMin,     DataIndexMax;
    3.66 +        } Range;
    3.67 +        struct  {
    3.68 +            USAGE    Usage,            Reserved1;
    3.69 +            USHORT   StringIndex,      Reserved2;
    3.70 +            USHORT   DesignatorIndex,  Reserved3;
    3.71 +            USHORT   DataIndex,        Reserved4;
    3.72 +        } NotRange;
    3.73 +    };
    3.74 +
    3.75 +} HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;
    3.76 +
    3.77 +typedef struct _HIDP_VALUE_CAPS
    3.78 +{
    3.79 +    USAGE    UsagePage;
    3.80 +    UCHAR    ReportID;
    3.81 +    BOOLEAN  IsAlias;
    3.82 +
    3.83 +    USHORT   BitField;
    3.84 +    USHORT   LinkCollection;   // A unique internal index pointer
    3.85 +
    3.86 +    USAGE    LinkUsage;
    3.87 +    USAGE    LinkUsagePage;
    3.88 +
    3.89 +    BOOLEAN  IsRange;
    3.90 +    BOOLEAN  IsStringRange;
    3.91 +    BOOLEAN  IsDesignatorRange;
    3.92 +    BOOLEAN  IsAbsolute;
    3.93 +
    3.94 +    BOOLEAN  HasNull;        // Does this channel have a null report   union
    3.95 +    UCHAR    Reserved;
    3.96 +    USHORT   BitSize;        // How many bits are devoted to this value?
    3.97 +
    3.98 +    USHORT   ReportCount;    // See Note below.  Usually set to 1.
    3.99 +    USHORT   Reserved2[5];
   3.100 +
   3.101 +    ULONG    UnitsExp;
   3.102 +    ULONG    Units;
   3.103 +
   3.104 +    LONG     LogicalMin,       LogicalMax;
   3.105 +    LONG     PhysicalMin,      PhysicalMax;
   3.106 +
   3.107 +    union {
   3.108 +        struct {
   3.109 +            USAGE    UsageMin,         UsageMax;
   3.110 +            USHORT   StringMin,        StringMax;
   3.111 +            USHORT   DesignatorMin,    DesignatorMax;
   3.112 +            USHORT   DataIndexMin,     DataIndexMax;
   3.113 +        } Range;
   3.114 +
   3.115 +        struct {
   3.116 +            USAGE    Usage,            Reserved1;
   3.117 +            USHORT   StringIndex,      Reserved2;
   3.118 +            USHORT   DesignatorIndex,  Reserved3;
   3.119 +            USHORT   DataIndex,        Reserved4;
   3.120 +        } NotRange;
   3.121 +    };
   3.122 +} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
   3.123 +
   3.124 +NTSTATUS __stdcall
   3.125 +HidP_GetCaps (
   3.126 +         PHIDP_PREPARSED_DATA      PreparsedData,
   3.127 +        PHIDP_CAPS                Capabilities
   3.128 +   );
   3.129 +
   3.130 +   NTSTATUS __stdcall
   3.131 +HidP_GetButtonCaps (
   3.132 +          HIDP_REPORT_TYPE     ReportType,
   3.133 +   PHIDP_BUTTON_CAPS ButtonCaps,
   3.134 +       PUSHORT              ButtonCapsLength,
   3.135 +          PHIDP_PREPARSED_DATA PreparsedData
   3.136 +);
   3.137 +
   3.138 +NTSTATUS __stdcall
   3.139 +HidP_GetValueCaps (
   3.140 +          HIDP_REPORT_TYPE     ReportType,
   3.141 +   PHIDP_VALUE_CAPS ValueCaps,
   3.142 +       PUSHORT              ValueCapsLength,
   3.143 +          PHIDP_PREPARSED_DATA PreparsedData
   3.144 +);