PageRenderTime 267ms CodeModel.GetById 39ms RepoModel.GetById 1ms app.codeStats 0ms

/src/archutils/Win32/ddk/hidpi.h

https://github.com/augustg/stepmania-3.9
C Header | 1788 lines | 443 code | 88 blank | 1257 comment | 1 complexity | 6aa3e1b5761adb8806ce8eacfb663ea9 MD5 | raw file
Possible License(s): ISC, LGPL-2.1, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. HIDPI.H
  5. Abstract:
  6. Public Interface to the HID parsing library.
  7. Environment:
  8. Kernel & user mode
  9. --*/
  10. #ifndef __HIDPI_H__
  11. #define __HIDPI_H__
  12. #include <pshpack4.h>
  13. // Please include "hidsdi.h" to use the user space (dll / parser)
  14. // Please include "hidpddi.h" to use the kernel space parser
  15. //
  16. // Special Link collection values for using the query functions
  17. //
  18. // Root collection references the collection at the base of the link
  19. // collection tree.
  20. // Unspecifies, references all collections in the link collection tree.
  21. //
  22. #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
  23. #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
  24. typedef enum _HIDP_REPORT_TYPE
  25. {
  26. HidP_Input,
  27. HidP_Output,
  28. HidP_Feature
  29. } HIDP_REPORT_TYPE;
  30. typedef struct _USAGE_AND_PAGE
  31. {
  32. USAGE Usage;
  33. USAGE UsagePage;
  34. } USAGE_AND_PAGE, *PUSAGE_AND_PAGE;
  35. #define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
  36. typedef struct _HIDP_BUTTON_CAPS
  37. {
  38. USAGE UsagePage;
  39. UCHAR ReportID;
  40. BOOLEAN IsAlias;
  41. USHORT BitField;
  42. USHORT LinkCollection; // A unique internal index pointer
  43. USAGE LinkUsage;
  44. USAGE LinkUsagePage;
  45. BOOLEAN IsRange;
  46. BOOLEAN IsStringRange;
  47. BOOLEAN IsDesignatorRange;
  48. BOOLEAN IsAbsolute;
  49. ULONG Reserved[10];
  50. union {
  51. struct {
  52. USAGE UsageMin, UsageMax;
  53. USHORT StringMin, StringMax;
  54. USHORT DesignatorMin, DesignatorMax;
  55. USHORT DataIndexMin, DataIndexMax;
  56. } Range;
  57. struct {
  58. USAGE Usage, Reserved1;
  59. USHORT StringIndex, Reserved2;
  60. USHORT DesignatorIndex, Reserved3;
  61. USHORT DataIndex, Reserved4;
  62. } NotRange;
  63. };
  64. } HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;
  65. typedef struct _HIDP_VALUE_CAPS
  66. {
  67. USAGE UsagePage;
  68. UCHAR ReportID;
  69. BOOLEAN IsAlias;
  70. USHORT BitField;
  71. USHORT LinkCollection; // A unique internal index pointer
  72. USAGE LinkUsage;
  73. USAGE LinkUsagePage;
  74. BOOLEAN IsRange;
  75. BOOLEAN IsStringRange;
  76. BOOLEAN IsDesignatorRange;
  77. BOOLEAN IsAbsolute;
  78. BOOLEAN HasNull; // Does this channel have a null report union
  79. UCHAR Reserved;
  80. USHORT BitSize; // How many bits are devoted to this value?
  81. USHORT ReportCount; // See Note below. Usually set to 1.
  82. USHORT Reserved2[5];
  83. ULONG UnitsExp;
  84. ULONG Units;
  85. LONG LogicalMin, LogicalMax;
  86. LONG PhysicalMin, PhysicalMax;
  87. union {
  88. struct {
  89. USAGE UsageMin, UsageMax;
  90. USHORT StringMin, StringMax;
  91. USHORT DesignatorMin, DesignatorMax;
  92. USHORT DataIndexMin, DataIndexMax;
  93. } Range;
  94. struct {
  95. USAGE Usage, Reserved1;
  96. USHORT StringIndex, Reserved2;
  97. USHORT DesignatorIndex, Reserved3;
  98. USHORT DataIndex, Reserved4;
  99. } NotRange;
  100. };
  101. } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
  102. //
  103. // Notes:
  104. //
  105. // ReportCount: When a report descriptor declares an Input, Output, or
  106. // Feature main item with fewer usage declarations than the report count, then
  107. // the last usage applies to all remaining unspecified count in that main item.
  108. // (As an example you might have data that required many fields to describe,
  109. // possibly buffered bytes.) In this case, only one value cap structure is
  110. // allocated for these associtated fields, all with the same usage, and Report
  111. // Count reflects the number of fields involved. Normally ReportCount is 1.
  112. // To access all of the fields in such a value structure would require using
  113. // HidP_GetUsageValueArray and HidP_SetUsageValueArray. HidP_GetUsageValue/
  114. // HidP_SetScaledUsageValue will also work, however, these functions will only
  115. // work with the first field of the structure.
  116. //
  117. //
  118. // The link collection tree consists of an array of LINK_COLLECTION_NODES
  119. // where the index into this array is the same as the collection number.
  120. //
  121. // Given a collection A which contains a subcollection B, A is defined to be
  122. // the parent B, and B is defined to be the child.
  123. //
  124. // Given collections A, B, and C where B and C are children of A, and B was
  125. // encountered before C in the report descriptor, B is defined as a sibling of
  126. // C. (This implies, of course, that if B is a sibling of C, then C is NOT a
  127. // sibling of B).
  128. //
  129. // B is defined as the NextSibling of C if and only if there exists NO
  130. // child collection of A, call it D, such that B is a sibling of D and D
  131. // is a sibling of C.
  132. //
  133. // E is defined to be the FirstChild of A if and only if for all children of A,
  134. // F, that are not equivalent to E, F is a sibling of E.
  135. // (This implies, of course, that the does not exist a child of A, call it G,
  136. // where E is a sibling of G). In other words the first sibling is the last
  137. // link collection found in the list.
  138. //
  139. // In other words, if a collection B is defined within the definition of another
  140. // collection A, B becomes a child of A. All collections with the same parent
  141. // are considered siblings. The FirstChild of the parent collection, A, will be
  142. // last collection defined that has A as a parent. The order of sibling pointers
  143. // is similarly determined. When a collection B is defined, it becomes the
  144. // FirstChild of it's parent collection. The previously defined FirstChild of the
  145. // parent collection becomes the NextSibling of the new collection. As new
  146. // collections with the same parent are discovered, the chain of sibling is built.
  147. //
  148. // With that in mind, the following describes conclusively a data structure
  149. // that provides direct traversal up, down, and accross the link collection
  150. // tree.
  151. //
  152. //
  153. typedef struct _HIDP_LINK_COLLECTION_NODE
  154. {
  155. USAGE LinkUsage;
  156. USAGE LinkUsagePage;
  157. USHORT Parent;
  158. USHORT NumberOfChildren;
  159. USHORT NextSibling;
  160. USHORT FirstChild;
  161. ULONG CollectionType: 8; // As defined in 6.2.2.6 of HID spec
  162. ULONG IsAlias : 1; // This link node is an allias of the next link node.
  163. ULONG Reserved: 23;
  164. PVOID UserContext; // The user can hang his coat here.
  165. } HIDP_LINK_COLLECTION_NODE, *PHIDP_LINK_COLLECTION_NODE;
  166. //
  167. // When a link collection is described by a delimiter, alias link collection
  168. // nodes are created. (One for each usage within the delimiter).
  169. // The parser assigns each capability description listed above only one
  170. // link collection.
  171. //
  172. // If a control is defined within a collection defined by
  173. // delimited usages, then that control is said to be within multiple link
  174. // collections, one for each usage within the open and close delimiter tokens.
  175. // Such multiple link collecions are said to be aliases. The first N-1 such
  176. // collections, listed in the link collection node array, have their IsAlias
  177. // bit set. The last such link collection is the link collection index used
  178. // in the capabilities described above.
  179. // Clients wishing to set a control in an aliased collection, should walk the
  180. // collection array once for each time they see the IsAlias flag set, and use
  181. // the last link collection as the index for the below accessor functions.
  182. //
  183. // NB: if IsAlias is set, then NextSibling should be one more than the current
  184. // link collection node index.
  185. //
  186. typedef PUCHAR PHIDP_REPORT_DESCRIPTOR;
  187. typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;
  188. typedef struct _HIDP_CAPS
  189. {
  190. USAGE Usage;
  191. USAGE UsagePage;
  192. USHORT InputReportByteLength;
  193. USHORT OutputReportByteLength;
  194. USHORT FeatureReportByteLength;
  195. USHORT Reserved[17];
  196. USHORT NumberLinkCollectionNodes;
  197. USHORT NumberInputButtonCaps;
  198. USHORT NumberInputValueCaps;
  199. USHORT NumberInputDataIndices;
  200. USHORT NumberOutputButtonCaps;
  201. USHORT NumberOutputValueCaps;
  202. USHORT NumberOutputDataIndices;
  203. USHORT NumberFeatureButtonCaps;
  204. USHORT NumberFeatureValueCaps;
  205. USHORT NumberFeatureDataIndices;
  206. } HIDP_CAPS, *PHIDP_CAPS;
  207. typedef struct _HIDP_DATA
  208. {
  209. USHORT DataIndex;
  210. USHORT Reserved;
  211. union {
  212. ULONG RawValue; // for values
  213. BOOLEAN On; // for buttons MUST BE TRUE for buttons.
  214. };
  215. } HIDP_DATA, *PHIDP_DATA;
  216. //
  217. // The HIDP_DATA structure is used with HidP_GetData and HidP_SetData
  218. // functions.
  219. //
  220. // The parser contiguously assigns every control (button or value) in a hid
  221. // device a unique data index from zero to NumberXXXDataIndices -1 , inclusive.
  222. // This value is found in the HIDP_BUTTON_CAPS and HIDP_VALUE_CAPS structures.
  223. //
  224. // Most clients will find the Get/Set Buttons / Value accessor functions
  225. // sufficient to their needs, as they will allow the clients to access the
  226. // data known to them while ignoring the other controls.
  227. //
  228. // More complex clients, which actually read the Button / Value Caps, and which
  229. // do a value add service to these routines (EG Direct Input), will need to
  230. // access all the data in the device without interest in the individual usage
  231. // or link collection location. These are the clients that will find
  232. // HidP_Data useful.
  233. //
  234. typedef struct _HIDP_UNKNOWN_TOKEN
  235. {
  236. UCHAR Token;
  237. UCHAR Reserved[3];
  238. ULONG BitField;
  239. } HIDP_UNKNOWN_TOKEN, *PHIDP_UNKNOWN_TOKEN;
  240. typedef struct _HIDP_EXTENDED_ATTRIBUTES
  241. {
  242. UCHAR NumGlobalUnknowns;
  243. UCHAR Reserved [3];
  244. PHIDP_UNKNOWN_TOKEN GlobalUnknowns;
  245. // ... Additional attributes
  246. ULONG Data [1]; // variableLength DO NOT ACCESS THIS FIELD
  247. } HIDP_EXTENDED_ATTRIBUTES, *PHIDP_EXTENDED_ATTRIBUTES;
  248. NTSTATUS __stdcall
  249. HidP_GetCaps (
  250. IN PHIDP_PREPARSED_DATA PreparsedData,
  251. OUT PHIDP_CAPS Capabilities
  252. );
  253. /*++
  254. Routine Description:
  255. Returns a list of capabilities of a given hid device as described by its
  256. preparsed data.
  257. Arguments:
  258. PreparsedData The preparsed data returned from HIDCLASS.
  259. Capabilities a HIDP_CAPS structure
  260. Return Value:
  261. · HIDP_STATUS_SUCCESS
  262. · HIDP_STATUS_INVALID_PREPARSED_DATA
  263. --*/
  264. NTSTATUS __stdcall
  265. HidP_GetLinkCollectionNodes (
  266. OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
  267. IN OUT PULONG LinkCollectionNodesLength,
  268. IN PHIDP_PREPARSED_DATA PreparsedData
  269. );
  270. /*++
  271. Routine Description:
  272. Return a list of PHIDP_LINK_COLLECTION_NODEs used to describe the link
  273. collection tree of this hid device. See the above description of
  274. struct _HIDP_LINK_COLLECTION_NODE.
  275. Arguments:
  276. LinkCollectionNodes - a caller allocated array into which
  277. HidP_GetLinkCollectionNodes will store the information
  278. LinKCollectionNodesLength - the caller sets this value to the length of the
  279. the array in terms of number of elements.
  280. HidP_GetLinkCollectionNodes sets this value to the actual
  281. number of elements set. The total number of nodes required to
  282. describe this HID device can be found in the
  283. NumberLinkCollectionNodes field in the HIDP_CAPS structure.
  284. --*/
  285. NTSTATUS __stdcall
  286. HidP_GetButtonCaps (
  287. IN HIDP_REPORT_TYPE ReportType,
  288. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  289. IN OUT PUSHORT ButtonCapsLength,
  290. IN PHIDP_PREPARSED_DATA PreparsedData
  291. );
  292. #define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
  293. HidP_GetSpecificButtonCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
  294. NTSTATUS __stdcall
  295. HidP_GetSpecificButtonCaps (
  296. IN HIDP_REPORT_TYPE ReportType,
  297. IN USAGE UsagePage, // Optional (0 => ignore)
  298. IN USHORT LinkCollection, // Optional (0 => ignore)
  299. IN USAGE Usage, // Optional (0 => ignore)
  300. OUT PHIDP_BUTTON_CAPS ButtonCaps,
  301. IN OUT PUSHORT ButtonCapsLength,
  302. IN PHIDP_PREPARSED_DATA PreparsedData
  303. );
  304. /*++
  305. Description:
  306. HidP_GetButtonCaps returns all the buttons (binary values) that are a part
  307. of the given report type for the Hid device represented by the given
  308. preparsed data.
  309. Parameters:
  310. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  311. UsagePage A usage page value used to limit the button caps returned to
  312. those on a given usage page. If set to 0, this parameter is
  313. ignored. Can be used with LinkCollection and Usage parameters
  314. to further limit the number of button caps structures returned.
  315. LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
  316. button caps returned to those buttons in a given link
  317. collection. If set to 0, this parameter is
  318. ignored. Can be used with UsagePage and Usage parameters
  319. to further limit the number of button caps structures
  320. returned.
  321. Usage A usage value used to limit the button caps returned to those
  322. with the specified usage value. If set to 0, this parameter
  323. is ignored. Can be used with LinkCollection and UsagePage
  324. parameters to further limit the number of button caps
  325. structures returned.
  326. ButtonCaps A _HIDP_BUTTON_CAPS array containing information about all the
  327. binary values in the given report. This buffer is provided by
  328. the caller.
  329. ButtonLength As input, this parameter specifies the length of the
  330. ButtonCaps parameter (array) in number of array elements.
  331. As output, this value is set to indicate how many of those
  332. array elements were filled in by the function. The maximum number of
  333. button caps that can be returned is found in the HIDP_CAPS
  334. structure. If HIDP_STATUS_BUFFER_TOO_SMALL is returned,
  335. this value contains the number of array elements needed to
  336. successfully complete the request.
  337. PreparsedData The preparsed data returned from HIDCLASS.
  338. Return Value
  339. HidP_GetSpecificButtonCaps returns the following error codes:
  340. · HIDP_STATUS_SUCCESS.
  341. · HIDP_STATUS_INVALID_REPORT_TYPE
  342. · HIDP_STATUS_INVALID_PREPARSED_DATA
  343. · HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
  344. · HIDP_STATUS_USAGE_NOT_FOUND
  345. --*/
  346. NTSTATUS __stdcall
  347. HidP_GetValueCaps (
  348. IN HIDP_REPORT_TYPE ReportType,
  349. OUT PHIDP_VALUE_CAPS ValueCaps,
  350. IN OUT PUSHORT ValueCapsLength,
  351. IN PHIDP_PREPARSED_DATA PreparsedData
  352. );
  353. #define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
  354. HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
  355. NTSTATUS __stdcall
  356. HidP_GetSpecificValueCaps (
  357. IN HIDP_REPORT_TYPE ReportType,
  358. IN USAGE UsagePage, // Optional (0 => ignore)
  359. IN USHORT LinkCollection, // Optional (0 => ignore)
  360. IN USAGE Usage, // Optional (0 => ignore)
  361. OUT PHIDP_VALUE_CAPS ValueCaps,
  362. IN OUT PUSHORT ValueCapsLength,
  363. IN PHIDP_PREPARSED_DATA PreparsedData
  364. );
  365. /*++
  366. Description:
  367. HidP_GetValueCaps returns all the values (non-binary) that are a part
  368. of the given report type for the Hid device represented by the given
  369. preparsed data.
  370. Parameters:
  371. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  372. UsagePage A usage page value used to limit the value caps returned to
  373. those on a given usage page. If set to 0, this parameter is
  374. ignored. Can be used with LinkCollection and Usage parameters
  375. to further limit the number of value caps structures returned.
  376. LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
  377. value caps returned to those buttons in a given link
  378. collection. If set to 0, this parameter is
  379. ignored. Can be used with UsagePage and Usage parameters
  380. to further limit the number of value caps structures
  381. returned.
  382. Usage A usage value used to limit the value caps returned to those
  383. with the specified usage value. If set to 0, this parameter
  384. is ignored. Can be used with LinkCollection and UsagePage
  385. parameters to further limit the number of value caps
  386. structures returned.
  387. ValueCaps A _HIDP_VALUE_CAPS array containing information about all the
  388. non-binary values in the given report. This buffer is provided
  389. by the caller.
  390. ValueLength As input, this parameter specifies the length of the ValueCaps
  391. parameter (array) in number of array elements. As output,
  392. this value is set to indicate how many of those array elements
  393. were filled in by the function. The maximum number of
  394. value caps that can be returned is found in the HIDP_CAPS
  395. structure. If HIDP_STATUS_BUFFER_TOO_SMALL is returned,
  396. this value contains the number of array elements needed to
  397. successfully complete the request.
  398. PreparsedData The preparsed data returned from HIDCLASS.
  399. Return Value
  400. HidP_GetValueCaps returns the following error codes:
  401. · HIDP_STATUS_SUCCESS.
  402. · HIDP_STATUS_INVALID_REPORT_TYPE
  403. · HIDP_STATUS_INVALID_PREPARSED_DATA
  404. · HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
  405. · HIDP_STATUS_USAGE_NOT_FOUND
  406. --*/
  407. NTSTATUS __stdcall
  408. HidP_GetExtendedAttributes (
  409. IN HIDP_REPORT_TYPE ReportType,
  410. IN USHORT DataIndex,
  411. IN PHIDP_PREPARSED_DATA PreparsedData,
  412. OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
  413. IN OUT PULONG LengthAttributes
  414. );
  415. /*++
  416. Description:
  417. Given a data index from the value or button capabilities of a given control
  418. return any extended attributes for the control if any exist.
  419. Parameters:
  420. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  421. DataIndex The data index for the given control, found in the capabilities
  422. structure for that control
  423. PreparsedData The preparsed data returned from HIDCLASS.
  424. Attributes Pointer to a buffer into which the extended attribute data will
  425. be copied.
  426. LengthAttributes Length of the given buffer in bytes.
  427. Return Value
  428. HIDP_STATUS_SUCCESS
  429. HIDP_STATUS_DATA_INDEX_NOT_FOUND
  430. --*/
  431. NTSTATUS __stdcall
  432. HidP_InitializeReportForID (
  433. IN HIDP_REPORT_TYPE ReportType,
  434. IN UCHAR ReportID,
  435. IN PHIDP_PREPARSED_DATA PreparsedData,
  436. IN OUT PCHAR Report,
  437. IN ULONG ReportLength
  438. );
  439. /*++
  440. Routine Description:
  441. Initialize a report based on the given report ID.
  442. Parameters:
  443. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  444. PreparasedData Preparsed data structure returned by HIDCLASS
  445. Report Buffer which to set the data into.
  446. ReportLength Length of Report...Report should be at least as long as the
  447. value indicated in the HIDP_CAPS structure for the device and
  448. the corresponding ReportType
  449. Return Value
  450. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  451. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  452. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal
  453. to the length specified in HIDP_CAPS
  454. structure for the given ReportType
  455. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  456. for the given ReportType
  457. --*/
  458. NTSTATUS __stdcall
  459. HidP_SetData (
  460. IN HIDP_REPORT_TYPE ReportType,
  461. IN PHIDP_DATA DataList,
  462. IN OUT PULONG DataLength,
  463. IN PHIDP_PREPARSED_DATA PreparsedData,
  464. IN OUT PCHAR Report,
  465. IN ULONG ReportLength
  466. );
  467. /*++
  468. Routine Description:
  469. Please Note: Since usage value arrays deal with multiple fields for
  470. for one usage value, they cannot be used with HidP_SetData
  471. and HidP_GetData. In this case,
  472. HIDP_STATUS_IS_USAGE_VALUE_ARRAY will be returned.
  473. Parameters:
  474. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  475. DataList Array of HIDP_DATA structures that contains the data values
  476. that are to be set into the given report
  477. DataLength As input, length in array elements of DataList. As output,
  478. contains the number of data elements set on successful
  479. completion or an index into the DataList array to identify
  480. the faulting HIDP_DATA value if an error code is returned.
  481. PreparasedData Preparsed data structure returned by HIDCLASS
  482. Report Buffer which to set the data into.
  483. ReportLength Length of Report...Report should be at least as long as the
  484. value indicated in the HIDP_CAPS structure for the device and
  485. the corresponding ReportType
  486. Return Value
  487. HidP_SetData returns the following error codes. The report packet will
  488. have all the data set up until the HIDP_DATA structure that caused the
  489. error. DataLength, in the error case, will return this problem index.
  490. · HIDP_STATUS_SUCCESS -- upon successful insertion of all data
  491. into the report packet.
  492. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  493. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  494. · HIDP_STATUS_DATA_INDEX_NOT_FOUND -- if a HIDP_DATA structure referenced a
  495. data index that does not exist for this
  496. device's ReportType
  497. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal
  498. to the length specified in HIDP_CAPS
  499. structure for the given ReportType
  500. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  501. for the given ReportType
  502. · HIDP_STATUS_IS_USAGE_VALUE_ARRAY -- if one of the HIDP_DATA structures
  503. references a usage value array.
  504. DataLength will contain the index into
  505. the array that was invalid
  506. · HIDP_STATUS_BUTTON_NOT_PRESSED -- if a HIDP_DATA structure attempted
  507. to unset a button that was not already
  508. set in the Report
  509. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- a HIDP_DATA structure was found with
  510. a valid index value but is contained
  511. in a different report than the one
  512. currently being processed
  513. · HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough entries in
  514. a given Main Array Item to report all
  515. buttons that have been requested to be
  516. set
  517. --*/
  518. NTSTATUS __stdcall
  519. HidP_GetData (
  520. IN HIDP_REPORT_TYPE ReportType,
  521. OUT PHIDP_DATA DataList,
  522. IN OUT PULONG DataLength,
  523. IN PHIDP_PREPARSED_DATA PreparsedData,
  524. IN PCHAR Report,
  525. IN ULONG ReportLength
  526. );
  527. /*++
  528. Routine Description:
  529. Please Note: For obvious reasons HidP_SetData and HidP_GetData will not
  530. access UsageValueArrays.
  531. Parameters:
  532. ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
  533. DataList Array of HIDP_DATA structures that will receive the data
  534. values that are set in the given report
  535. DataLength As input, length in array elements of DataList. As output,
  536. contains the number of data elements that were successfully
  537. set by HidP_GetData. The maximum size necessary for DataList
  538. can be determined by calling HidP_MaxDataListLength
  539. PreparasedData Preparsed data structure returned by HIDCLASS
  540. Report Buffer which to set the data into.
  541. ReportLength Length of Report...Report should be at least as long as the
  542. value indicated in the HIDP_CAPS structure for the device and
  543. the corresponding ReportType
  544. Return Value
  545. HidP_GetData returns the following error codes.
  546. · HIDP_STATUS_SUCCESS -- upon successful retrieval of all data
  547. from the report packet.
  548. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  549. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  550. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not equal
  551. to the length specified in HIDP_CAPS
  552. structure for the given ReportType
  553. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  554. for the given ReportType
  555. · HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough array entries in
  556. DataList to store all the indice values
  557. in the given report. DataLength will
  558. contain the number of array entries
  559. required to hold all data
  560. --*/
  561. ULONG __stdcall
  562. HidP_MaxDataListLength (
  563. IN HIDP_REPORT_TYPE ReportType,
  564. IN PHIDP_PREPARSED_DATA PreparsedData
  565. );
  566. /*++
  567. Routine Description:
  568. This function returns the maximum length of HIDP_DATA elements that
  569. HidP_GetData could return for the given report type.
  570. Parameters:
  571. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  572. PreparsedData Preparsed data structure returned by HIDCLASS
  573. Return Value:
  574. The length of the data list array required for the HidP_GetData function
  575. call. If an error occurs (either HIDP_STATUS_INVALID_REPORT_TYPE or
  576. HIDP_STATUS_INVALID_PREPARSED_DATA), this function returns 0.
  577. --*/
  578. #define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
  579. HidP_SetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
  580. NTSTATUS __stdcall
  581. HidP_SetUsages (
  582. IN HIDP_REPORT_TYPE ReportType,
  583. IN USAGE UsagePage,
  584. IN USHORT LinkCollection, // Optional
  585. IN PUSAGE UsageList,
  586. IN OUT PULONG UsageLength,
  587. IN PHIDP_PREPARSED_DATA PreparsedData,
  588. IN OUT PCHAR Report,
  589. IN ULONG ReportLength
  590. );
  591. /*++
  592. Routine Description:
  593. This function sets binary values (buttons) in a report. Given an
  594. initialized packet of correct length, it modifies the report packet so that
  595. each element in the given list of usages has been set in the report packet.
  596. For example, in an output report with 5 LED’s, each with a given usage,
  597. an application could turn on any subset of these lights by placing their
  598. usages in any order into the usage array (UsageList). HidP_SetUsages would,
  599. in turn, set the appropriate bit or add the corresponding byte into the
  600. HID Main Array Item.
  601. A properly initialized Report packet is one of the correct byte length,
  602. and all zeros.
  603. NOTE: A packet that has already been set with a call to a HidP_Set routine
  604. can also be passed in. This routine then sets processes the UsageList
  605. in the same fashion but verifies that the ReportID already set in
  606. Report matches the report ID for the given usages.
  607. Parameters:
  608. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  609. UsagePage All of the usages in the usage array, which HidP_SetUsages will
  610. set in the report, refer to this same usage page.
  611. If a client wishes to set usages in a report for multiple
  612. usage pages then that client needs to make multiple calls to
  613. HidP_SetUsages for each of the usage pages.
  614. UsageList A usage array containing the usages that HidP_SetUsages will set in
  615. the report packet.
  616. UsageLength The length of the given usage array in array elements.
  617. The parser will set this value to the position in the usage
  618. array where it stopped processing. If successful, UsageLength
  619. will be unchanged. In any error condition, this parameter
  620. reflects how many of the usages in the usage list have
  621. actually been set by the parser. This is useful for finding
  622. the usage in the list which caused the error.
  623. PreparsedData The preparsed data recevied from HIDCLASS
  624. Report The report packet.
  625. ReportLength Length of the given report packet...Must be equal to the
  626. value reported in the HIDP_CAPS structure for the device
  627. and corresponding report type.
  628. Return Value
  629. HidP_SetUsages returns the following error codes. On error, the report packet
  630. will be correct up until the usage element that caused the error.
  631. · HIDP_STATUS_SUCCESS -- upon successful insertion of all usages
  632. into the report packet.
  633. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  634. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  635. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
  636. equal to the length specified in
  637. the HIDP_CAPS structure for the given
  638. ReportType
  639. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  640. for the given ReportType
  641. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
  642. different report. If the report is
  643. zero-initialized on entry the first
  644. usage in the list will determine which
  645. report ID is used. Otherwise, the
  646. parser will verify that usage matches
  647. the passed in report's ID
  648. · HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any
  649. report (no matter what the report ID)
  650. for the given report type.
  651. · HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough entries in a
  652. given Main Array Item to list all of
  653. the given usages. The caller needs
  654. to split his request into more than
  655. one call
  656. --*/
  657. #define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
  658. HidP_UnsetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
  659. NTSTATUS __stdcall
  660. HidP_UnsetUsages (
  661. IN HIDP_REPORT_TYPE ReportType,
  662. IN USAGE UsagePage,
  663. IN USHORT LinkCollection, // Optional
  664. IN PUSAGE UsageList,
  665. IN OUT PULONG UsageLength,
  666. IN PHIDP_PREPARSED_DATA PreparsedData,
  667. IN OUT PCHAR Report,
  668. IN ULONG ReportLength
  669. );
  670. /*++
  671. Routine Description:
  672. This function unsets (turns off) binary values (buttons) in the report. Given
  673. an initialized packet of correct length, it modifies the report packet so
  674. that each element in the given list of usages has been unset in the
  675. report packet.
  676. This function is the "undo" operation for SetUsages. If the given usage
  677. is not already set in the Report, it will return an error code of
  678. HIDP_STATUS_BUTTON_NOT_PRESSED. If the button is pressed, HidP_UnsetUsages
  679. will unset the appropriate bit or remove the corresponding index value from
  680. the HID Main Array Item.
  681. A properly initialized Report packet is one of the correct byte length,
  682. and all zeros..
  683. NOTE: A packet that has already been set with a call to a HidP_Set routine
  684. can also be passed in. This routine then processes the UsageList
  685. in the same fashion but verifies that the ReportID already set in
  686. Report matches the report ID for the given usages.
  687. Parameters:
  688. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  689. UsagePage All of the usages in the usage array, which HidP_UnsetUsages will
  690. unset in the report, refer to this same usage page.
  691. If a client wishes to unset usages in a report for multiple
  692. usage pages then that client needs to make multiple calls to
  693. HidP_UnsetUsages for each of the usage pages.
  694. UsageList A usage array containing the usages that HidP_UnsetUsages will
  695. unset in the report packet.
  696. UsageLength The length of the given usage array in array elements.
  697. The parser will set this value to the position in the usage
  698. array where it stopped processing. If successful, UsageLength
  699. will be unchanged. In any error condition, this parameter
  700. reflects how many of the usages in the usage list have
  701. actually been unset by the parser. This is useful for finding
  702. the usage in the list which caused the error.
  703. PreparsedData The preparsed data recevied from HIDCLASS
  704. Report The report packet.
  705. ReportLength Length of the given report packet...Must be equal to the
  706. value reported in the HIDP_CAPS structure for the device
  707. and corresponding report type.
  708. Return Value
  709. HidP_UnsetUsages returns the following error codes. On error, the report
  710. packet will be correct up until the usage element that caused the error.
  711. · HIDP_STATUS_SUCCESS -- upon successful "unsetting" of all usages
  712. in the report packet.
  713. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  714. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  715. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
  716. equal to the length specified in
  717. the HIDP_CAPS structure for the given
  718. ReportType
  719. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  720. for the given ReportType
  721. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
  722. different report. If the report is
  723. zero-initialized on entry the first
  724. usage in the list will determine which
  725. report ID is used. Otherwise, the
  726. parser will verify that usage matches
  727. the passed in report's ID
  728. · HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any
  729. report (no matter what the report ID)
  730. for the given report type.
  731. · HIDP_STATUS_BUTTON_NOT_PRESSED -- if a usage corresponds to a button that
  732. is not already set in the given report
  733. --*/
  734. #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
  735. HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
  736. NTSTATUS __stdcall
  737. HidP_GetUsages (
  738. IN HIDP_REPORT_TYPE ReportType,
  739. IN USAGE UsagePage,
  740. IN USHORT LinkCollection, // Optional
  741. OUT USAGE * UsageList,
  742. IN OUT ULONG * UsageLength,
  743. IN PHIDP_PREPARSED_DATA PreparsedData,
  744. IN PCHAR Report,
  745. IN ULONG ReportLength
  746. );
  747. /*++
  748. Routine Description:
  749. This function returns the binary values (buttons) that are set in a HID
  750. report. Given a report packet of correct length, it searches the report
  751. packet for each usage for the given usage page and returns them in the
  752. usage list.
  753. Parameters:
  754. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  755. UsagePage All of the usages in the usage list, which HidP_GetUsages will
  756. retrieve in the report, refer to this same usage page.
  757. If the client wishes to get usages in a packet for multiple
  758. usage pages then that client needs to make multiple calls
  759. to HidP_GetUsages.
  760. LinkCollection An optional value which can limit which usages are returned
  761. in the UsageList to those usages that exist in a specific
  762. LinkCollection. A non-zero value indicates the index into
  763. the HIDP_LINK_COLLECITON_NODE list returned by
  764. HidP_GetLinkCollectionNodes of the link collection the
  765. usage should belong to. A value of 0 indicates this
  766. should value be ignored.
  767. UsageList The usage array that will contain all the usages found in
  768. the report packet.
  769. UsageLength The length of the given usage array in array elements.
  770. On input, this value describes the length of the usage list.
  771. On output, HidP_GetUsages sets this value to the number of
  772. usages that was found. Use HidP_MaxUsageListLength to
  773. determine the maximum length needed to return all the usages
  774. that a given report packet may contain.
  775. PreparsedData Preparsed data structure returned by HIDCLASS
  776. Report The report packet.
  777. ReportLength Length (in bytes) of the given report packet
  778. Return Value
  779. HidP_GetUsages returns the following error codes:
  780. · HIDP_STATUS_SUCCESS -- upon successfully retrieving all the
  781. usages from the report packet
  782. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  783. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  784. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
  785. equal to the length specified in
  786. the HIDP_CAPS structure for the given
  787. ReportType
  788. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  789. for the given ReportType
  790. · HIDP_STATUS_BUFFER_TOO_SMALL -- if the UsageList is not big enough to
  791. hold all the usages found in the report
  792. packet. If this is returned, the buffer
  793. will contain UsageLength number of
  794. usages. Use HidP_MaxUsageListLength to
  795. find the maximum length needed
  796. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
  797. that match the UsagePage and
  798. LinkCollection specified could be found
  799. in a report with a different report ID
  800. · HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in a reports for
  801. the device and ReportType that match the
  802. UsagePage and LinkCollection that were
  803. specified
  804. --*/
  805. #define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe) \
  806. HidP_GetUsagesEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)
  807. NTSTATUS __stdcall
  808. HidP_GetUsagesEx (
  809. IN HIDP_REPORT_TYPE ReportType,
  810. IN USHORT LinkCollection, // Optional
  811. OUT PUSAGE_AND_PAGE ButtonList,
  812. IN OUT ULONG * UsageLength,
  813. IN PHIDP_PREPARSED_DATA PreparsedData,
  814. IN PCHAR Report,
  815. IN ULONG ReportLength
  816. );
  817. /*++
  818. Routine Description:
  819. This function returns the binary values (buttons) in a HID report.
  820. Given a report packet of correct length, it searches the report packet
  821. for all buttons and returns the UsagePage and Usage for each of the buttons
  822. it finds.
  823. Parameters:
  824. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  825. LinkCollection An optional value which can limit which usages are returned
  826. in the ButtonList to those usages that exist in a specific
  827. LinkCollection. A non-zero value indicates the index into
  828. the HIDP_LINK_COLLECITON_NODE list returned by
  829. HidP_GetLinkCollectionNodes of the link collection the
  830. usage should belong to. A value of 0 indicates this
  831. should value be ignored.
  832. ButtonList An array of USAGE_AND_PAGE structures describing all the
  833. buttons currently ``down'' in the device.
  834. UsageLength The length of the given array in terms of elements.
  835. On input, this value describes the length of the list. On
  836. output, HidP_GetUsagesEx sets this value to the number of
  837. usages that were found. Use HidP_MaxUsageListLength to
  838. determine the maximum length needed to return all the usages
  839. that a given report packet may contain.
  840. PreparsedData Preparsed data returned by HIDCLASS
  841. Report The report packet.
  842. ReportLength Length (in bytes) of the given report packet.
  843. Return Value
  844. HidP_GetUsagesEx returns the following error codes:
  845. · HIDP_STATUS_SUCCESS -- upon successfully retrieving all the
  846. usages from the report packet
  847. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  848. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  849. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
  850. equal to the length specified in
  851. the HIDP_CAPS structure for the given
  852. ReportType
  853. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  854. for the given ReportType
  855. · HIDP_STATUS_BUFFER_TOO_SMALL -- if ButtonList is not big enough to
  856. hold all the usages found in the report
  857. packet. If this is returned, the buffer
  858. will contain UsageLength number of
  859. usages. Use HidP_MaxUsageListLength to
  860. find the maximum length needed
  861. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
  862. that match the specified LinkCollection
  863. exist in report with a different report
  864. ID.
  865. · HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in any reports that
  866. match the LinkCollection parameter
  867. --*/
  868. #define HidP_GetButtonListLength(RTy, UPa, Ppd) \
  869. HidP_GetUsageListLength(Rty, UPa, Ppd)
  870. ULONG __stdcall
  871. HidP_MaxUsageListLength (
  872. IN HIDP_REPORT_TYPE ReportType,
  873. IN USAGE UsagePage, // Optional
  874. IN PHIDP_PREPARSED_DATA PreparsedData
  875. );
  876. /*++
  877. Routine Description:
  878. This function returns the maximum number of usages that a call to
  879. HidP_GetUsages or HidP_GetUsagesEx could return for a given HID report.
  880. If calling for number of usages returned by HidP_GetUsagesEx, use 0 as
  881. the UsagePage value.
  882. Parameters:
  883. ReportType One of HidP_Input, HidP_Output or HidP_Feature.
  884. UsagePage Specifies the optional UsagePage to query for. If 0, will
  885. return all the maximum number of usage values that could be
  886. returned for a given ReportType. If non-zero, will return
  887. the maximum number of usages that would be returned for the
  888. ReportType with the given UsagePage.
  889. PreparsedData Preparsed data returned from HIDCLASS
  890. Return Value:
  891. The length of the usage list array required for the HidP_GetUsages or
  892. HidP_GetUsagesEx function call. If an error occurs (such as
  893. HIDP_STATUS_INVALID_REPORT_TYPE or HIDP_INVALID_PREPARSED_DATA, this
  894. returns 0.
  895. --*/
  896. NTSTATUS __stdcall
  897. HidP_SetUsageValue (
  898. IN HIDP_REPORT_TYPE ReportType,
  899. IN USAGE UsagePage,
  900. IN USHORT LinkCollection, // Optional
  901. IN USAGE Usage,
  902. IN ULONG UsageValue,
  903. IN PHIDP_PREPARSED_DATA PreparsedData,
  904. IN OUT PCHAR Report,
  905. IN ULONG ReportLength
  906. );
  907. /*++
  908. Description:
  909. HidP_SetUsageValue inserts a value into the HID Report Packet in the field
  910. corresponding to the given usage page and usage. HidP_SetUsageValue
  911. casts this value to the appropriate bit length. If a report packet
  912. contains two different fields with the same Usage and UsagePage,
  913. they can be distinguished with the optional LinkCollection field value.
  914. Using this function sets the raw value into the report packet with
  915. no checking done as to whether it actually falls within the logical
  916. minimum/logical maximum range. Use HidP_SetScaledUsageValue for this...
  917. NOTE: Although the UsageValue parameter is a ULONG, any casting that is
  918. done will preserve or sign-extend the value. The value being set
  919. should be considered a LONG value and will be treated as such by
  920. this function.
  921. Parameters:
  922. ReportType One of HidP_Output or HidP_Feature.
  923. UsagePage The usage page to which the given usage refers.
  924. LinkCollection (Optional) This value can be used to differentiate
  925. between two fields that may have the same
  926. UsagePage and Usage but exist in different
  927. collections. If the link collection value
  928. is zero, this function will set the first field
  929. it finds that matches the usage page and
  930. usage.
  931. Usage The usage whose value HidP_SetUsageValue will set.
  932. UsageValue The raw value to set in the report buffer. This value must be within
  933. the logical range or if a NULL value this value should be the
  934. most negative value that can be represented by the number of bits
  935. for this field.
  936. PreparsedData The preparsed data returned for HIDCLASS
  937. Report The report packet.
  938. ReportLength Length (in bytes) of the given report packet.
  939. Return Value:
  940. HidP_SetUsageValue returns the following error codes:
  941. · HIDP_STATUS_SUCCESS -- upon successfully setting the value
  942. in the report packet
  943. · HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
  944. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
  945. · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
  946. equal to the length specified in
  947. the HIDP_CAPS structure for the given
  948. ReportType
  949. · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
  950. for the given ReportType
  951. · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
  952. link collection exist but exists in
  953. a report with a different report ID
  954. than the report being passed in. To
  955. set this value, call HidP_SetUsageValue
  956. again with a zero-initizialed report
  957. packet
  958. · HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
  959. collection combination does not exist
  960. in any reports for this ReportType
  961. --*/
  962. NTSTATUS __stdcall
  963. HidP_SetScaledUsageValue (
  964. IN HIDP_REPORT_TYPE ReportType,
  965. IN USAGE UsagePage,
  966. IN USHORT LinkCollection, // Optional
  967. IN USAGE Usage,
  968. IN LONG UsageValue,
  969. IN PHIDP_PREPARSED_DATA PreparsedData,
  970. IN OUT PCHAR Report,
  971. IN ULONG ReportLength
  972. );
  973. /*++
  974. D…

Large files files are truncated, but you can click here to view the full file