Etterna 0.74.4
Loading...
Searching...
No Matches
hidpi.h
1/*++
2
3Copyright (c) 1996-1998 Microsoft Corporation
4
5Module Name:
6
7 HIDPI.H
8
9Abstract:
10
11 Public Interface to the HID parsing library.
12
13Environment:
14
15 Kernel & user mode
16
17--*/
18
19#ifndef __HIDPI_H__
20#define __HIDPI_H__
21
22#include <pshpack4.h>
23
24// Please include "hidsdi.h" to use the user space (dll / parser)
25// Please include "hidpddi.h" to use the kernel space parser
26
27//
28// Special Link collection values for using the query functions
29//
30// Root collection references the collection at the base of the link
31// collection tree.
32// Unspecifies, references all collections in the link collection tree.
33//
34#define HIDP_LINK_COLLECTION_ROOT ((USHORT)-1)
35#define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT)0)
36
37typedef enum _HIDP_REPORT_TYPE
38{
39 HidP_Input,
40 HidP_Output,
41 HidP_Feature
42} HIDP_REPORT_TYPE;
43
44typedef struct _USAGE_AND_PAGE
45{
46 USAGE Usage;
47 USAGE UsagePage;
49
50#define HidP_IsSameUsageAndPage(u1, u2) ((*(PULONG)&u1) == (*(PULONG)&u2))
51
52typedef struct _HIDP_BUTTON_CAPS
53{
54 USAGE UsagePage;
55 UCHAR ReportID;
56 BOOLEAN IsAlias;
57
58 USHORT BitField;
59 USHORT LinkCollection; // A unique internal index pointer
60
61 USAGE LinkUsage;
62 USAGE LinkUsagePage;
63
64 BOOLEAN IsRange;
65 BOOLEAN IsStringRange;
66 BOOLEAN IsDesignatorRange;
67 BOOLEAN IsAbsolute;
68
69 ULONG Reserved[10];
70 union {
71 struct
72 {
73 USAGE UsageMin, UsageMax;
74 USHORT StringMin, StringMax;
75 USHORT DesignatorMin, DesignatorMax;
76 USHORT DataIndexMin, DataIndexMax;
77 } Range;
78 struct
79 {
80 USAGE Usage, Reserved1;
81 USHORT StringIndex, Reserved2;
82 USHORT DesignatorIndex, Reserved3;
83 USHORT DataIndex, Reserved4;
84 } NotRange;
85 };
86
88
89typedef struct _HIDP_VALUE_CAPS
90{
91 USAGE UsagePage;
92 UCHAR ReportID;
93 BOOLEAN IsAlias;
94
95 USHORT BitField;
96 USHORT LinkCollection; // A unique internal index pointer
97
98 USAGE LinkUsage;
99 USAGE LinkUsagePage;
100
101 BOOLEAN IsRange;
102 BOOLEAN IsStringRange;
103 BOOLEAN IsDesignatorRange;
104 BOOLEAN IsAbsolute;
105
106 BOOLEAN HasNull; // Does this channel have a null report union
107 UCHAR Reserved;
108 USHORT BitSize; // How many bits are devoted to this value?
109
110 USHORT ReportCount; // See Note below. Usually set to 1.
111 USHORT Reserved2[5];
112
113 ULONG UnitsExp;
114 ULONG Units;
115
116 LONG LogicalMin, LogicalMax;
117 LONG PhysicalMin, PhysicalMax;
118
119 union {
120 struct
121 {
122 USAGE UsageMin, UsageMax;
123 USHORT StringMin, StringMax;
124 USHORT DesignatorMin, DesignatorMax;
125 USHORT DataIndexMin, DataIndexMax;
126 } Range;
127
128 struct
129 {
130 USAGE Usage, Reserved1;
131 USHORT StringIndex, Reserved2;
132 USHORT DesignatorIndex, Reserved3;
133 USHORT DataIndex, Reserved4;
134 } NotRange;
135 };
137
138//
139// Notes:
140//
141// ReportCount: When a report descriptor declares an Input, Output, or
142// Feature main item with fewer usage declarations than the report count, then
143// the last usage applies to all remaining unspecified count in that main item.
144// (As an example you might have data that required many fields to describe,
145// possibly buffered bytes.) In this case, only one value cap structure is
146// allocated for these associtated fields, all with the same usage, and Report
147// Count reflects the number of fields involved. Normally ReportCount is 1.
148// To access all of the fields in such a value structure would require using
149// HidP_GetUsageValueArray and HidP_SetUsageValueArray. HidP_GetUsageValue/
150// HidP_SetScaledUsageValue will also work, however, these functions will only
151// work with the first field of the structure.
152//
153
154//
155// The link collection tree consists of an array of LINK_COLLECTION_NODES
156// where the index into this array is the same as the collection number.
157//
158// Given a collection A which contains a subcollection B, A is defined to be
159// the parent B, and B is defined to be the child.
160//
161// Given collections A, B, and C where B and C are children of A, and B was
162// encountered before C in the report descriptor, B is defined as a sibling of
163// C. (This implies, of course, that if B is a sibling of C, then C is NOT a
164// sibling of B).
165//
166// B is defined as the NextSibling of C if and only if there exists NO
167// child collection of A, call it D, such that B is a sibling of D and D
168// is a sibling of C.
169//
170// E is defined to be the FirstChild of A if and only if for all children of A,
171// F, that are not equivalent to E, F is a sibling of E.
172// (This implies, of course, that the does not exist a child of A, call it G,
173// where E is a sibling of G). In other words the first sibling is the last
174// link collection found in the list.
175//
176// In other words, if a collection B is defined within the definition of another
177// collection A, B becomes a child of A. All collections with the same parent
178// are considered siblings. The FirstChild of the parent collection, A, will be
179// last collection defined that has A as a parent. The order of sibling
180// pointers is similarly determined. When a collection B is defined, it becomes
181// the FirstChild of it's parent collection. The previously defined FirstChild
182// of the parent collection becomes the NextSibling of the new collection. As
183// new collections with the same parent are discovered, the chain of sibling is
184// built.
185//
186// With that in mind, the following describes conclusively a data structure
187// that provides direct traversal up, down, and accross the link collection
188// tree.
189//
190//
192{
193 USAGE LinkUsage;
194 USAGE LinkUsagePage;
195 USHORT Parent;
196 USHORT NumberOfChildren;
197 USHORT NextSibling;
198 USHORT FirstChild;
199 ULONG CollectionType : 8; // As defined in 6.2.2.6 of HID spec
200 ULONG IsAlias : 1; // This link node is an allias of the next link node.
201 ULONG Reserved : 23;
202 PVOID UserContext; // The user can hang his coat here.
204
205//
206// When a link collection is described by a delimiter, alias link collection
207// nodes are created. (One for each usage within the delimiter).
208// The parser assigns each capability description listed above only one
209// link collection.
210//
211// If a control is defined within a collection defined by
212// delimited usages, then that control is said to be within multiple link
213// collections, one for each usage within the open and close delimiter tokens.
214// Such multiple link collecions are said to be aliases. The first N-1 such
215// collections, listed in the link collection node array, have their IsAlias
216// bit set. The last such link collection is the link collection index used
217// in the capabilities described above.
218// Clients wishing to set a control in an aliased collection, should walk the
219// collection array once for each time they see the IsAlias flag set, and use
220// the last link collection as the index for the below accessor functions.
221//
222// NB: if IsAlias is set, then NextSibling should be one more than the current
223// link collection node index.
224//
225
226typedef PUCHAR PHIDP_REPORT_DESCRIPTOR;
227typedef struct _HIDP_PREPARSED_DATA* PHIDP_PREPARSED_DATA;
228
229typedef struct _HIDP_CAPS
230{
231 USAGE Usage;
232 USAGE UsagePage;
233 USHORT InputReportByteLength;
234 USHORT OutputReportByteLength;
235 USHORT FeatureReportByteLength;
236 USHORT Reserved[17];
237
238 USHORT NumberLinkCollectionNodes;
239
240 USHORT NumberInputButtonCaps;
241 USHORT NumberInputValueCaps;
242 USHORT NumberInputDataIndices;
243
244 USHORT NumberOutputButtonCaps;
245 USHORT NumberOutputValueCaps;
246 USHORT NumberOutputDataIndices;
247
248 USHORT NumberFeatureButtonCaps;
249 USHORT NumberFeatureValueCaps;
250 USHORT NumberFeatureDataIndices;
252
253typedef struct _HIDP_DATA
254{
255 USHORT DataIndex;
256 USHORT Reserved;
257 union {
258 ULONG RawValue; // for values
259 BOOLEAN On; // for buttons MUST BE TRUE for buttons.
260 };
262//
263// The HIDP_DATA structure is used with HidP_GetData and HidP_SetData
264// functions.
265//
266// The parser contiguously assigns every control (button or value) in a hid
267// device a unique data index from zero to NumberXXXDataIndices -1 , inclusive.
268// This value is found in the HIDP_BUTTON_CAPS and HIDP_VALUE_CAPS structures.
269//
270// Most clients will find the Get/Set Buttons / Value accessor functions
271// sufficient to their needs, as they will allow the clients to access the
272// data known to them while ignoring the other controls.
273//
274// More complex clients, which actually read the Button / Value Caps, and which
275// do a value add service to these routines (EG Direct Input), will need to
276// access all the data in the device without interest in the individual usage
277// or link collection location. These are the clients that will find
278// HidP_Data useful.
279//
280
282{
283 UCHAR Token;
284 UCHAR Reserved[3];
285 ULONG BitField;
287
289{
290 UCHAR NumGlobalUnknowns;
291 UCHAR Reserved[3];
292 PHIDP_UNKNOWN_TOKEN GlobalUnknowns;
293 // ... Additional attributes
294 ULONG Data[1]; // variableLength DO NOT ACCESS THIS FIELD
296
297NTSTATUS __stdcall HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData,
298 OUT PHIDP_CAPS Capabilities);
299/*++
300Routine Description:
301 Returns a list of capabilities of a given hid device as described by its
302 preparsed data.
303
304Arguments:
305 PreparsedData The preparsed data returned from HIDCLASS.
306 Capabilities a HIDP_CAPS structure
307
308Return Value:
309· HIDP_STATUS_SUCCESS
310· HIDP_STATUS_INVALID_PREPARSED_DATA
311--*/
312
313NTSTATUS __stdcall HidP_GetLinkCollectionNodes(
314 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
315 IN OUT PULONG LinkCollectionNodesLength,
316 IN PHIDP_PREPARSED_DATA PreparsedData);
317/*++
318Routine Description:
319 Return a list of PHIDP_LINK_COLLECTION_NODEs used to describe the link
320 collection tree of this hid device. See the above description of
321 struct _HIDP_LINK_COLLECTION_NODE.
322
323Arguments:
324 LinkCollectionNodes - a caller allocated array into which
325 HidP_GetLinkCollectionNodes will store the information
326
327 LinKCollectionNodesLength - the caller sets this value to the length of the
328 the array in terms of number of elements.
329 HidP_GetLinkCollectionNodes sets this value to the actual
330 number of elements set. The total number of nodes required to
331 describe this HID device can be found in the
332 NumberLinkCollectionNodes field in the HIDP_CAPS structure.
333
334--*/
335
336NTSTATUS __stdcall HidP_GetButtonCaps(IN HIDP_REPORT_TYPE ReportType,
337 OUT PHIDP_BUTTON_CAPS ButtonCaps,
338 IN OUT PUSHORT ButtonCapsLength,
339 IN PHIDP_PREPARSED_DATA PreparsedData);
340#define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
341 HidP_GetSpecificButtonCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
342NTSTATUS __stdcall HidP_GetSpecificButtonCaps(
343 IN HIDP_REPORT_TYPE ReportType,
344 IN USAGE UsagePage, // Optional (0 => ignore)
345 IN USHORT LinkCollection, // Optional (0 => ignore)
346 IN USAGE Usage, // Optional (0 => ignore)
347 OUT PHIDP_BUTTON_CAPS ButtonCaps,
348 IN OUT PUSHORT ButtonCapsLength,
349 IN PHIDP_PREPARSED_DATA PreparsedData);
350/*++
351Description:
352 HidP_GetButtonCaps returns all the buttons (binary values) that are a part
353 of the given report type for the Hid device represented by the given
354 preparsed data.
355
356Parameters:
357 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
358
359 UsagePage A usage page value used to limit the button caps returned to
360 those on a given usage page. If set to 0, this parameter is
361 ignored. Can be used with LinkCollection and Usage parameters
362 to further limit the number of button caps structures returned.
363
364 LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
365 button caps returned to those buttons in a given link
366 collection. If set to 0, this parameter is
367 ignored. Can be used with UsagePage and Usage parameters
368 to further limit the number of button caps structures
369 returned.
370
371 Usage A usage value used to limit the button caps returned to those
372 with the specified usage value. If set to 0, this parameter
373 is ignored. Can be used with LinkCollection and UsagePage
374 parameters to further limit the number of button caps
375 structures returned.
376
377 ButtonCaps A _HIDP_BUTTON_CAPS array containing information about all the
378 binary values in the given report. This buffer is provided by
379 the caller.
380
381 ButtonLength As input, this parameter specifies the length of the
382 ButtonCaps parameter (array) in number of array elements.
383 As output, this value is set to indicate how many of those
384 array elements were filled in by the function. The maximum
385number of button caps that can be returned is found in the HIDP_CAPS structure.
386If HIDP_STATUS_BUFFER_TOO_SMALL is returned, this value contains the number of
387array elements needed to successfully complete the request.
388
389 PreparsedData The preparsed data returned from HIDCLASS.
390
391
392Return Value
393HidP_GetSpecificButtonCaps returns the following error codes:
394· HIDP_STATUS_SUCCESS.
395· HIDP_STATUS_INVALID_REPORT_TYPE
396· HIDP_STATUS_INVALID_PREPARSED_DATA
397· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
398· HIDP_STATUS_USAGE_NOT_FOUND
399--*/
400
401NTSTATUS __stdcall HidP_GetValueCaps(IN HIDP_REPORT_TYPE ReportType,
402 OUT PHIDP_VALUE_CAPS ValueCaps,
403 IN OUT PUSHORT ValueCapsLength,
404 IN PHIDP_PREPARSED_DATA PreparsedData);
405#define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
406 HidP_GetSpecificValueCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
407NTSTATUS __stdcall HidP_GetSpecificValueCaps(
408 IN HIDP_REPORT_TYPE ReportType,
409 IN USAGE UsagePage, // Optional (0 => ignore)
410 IN USHORT LinkCollection, // Optional (0 => ignore)
411 IN USAGE Usage, // Optional (0 => ignore)
412 OUT PHIDP_VALUE_CAPS ValueCaps,
413 IN OUT PUSHORT ValueCapsLength,
414 IN PHIDP_PREPARSED_DATA PreparsedData);
415/*++
416Description:
417 HidP_GetValueCaps returns all the values (non-binary) that are a part
418 of the given report type for the Hid device represented by the given
419 preparsed data.
420
421Parameters:
422 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
423
424 UsagePage A usage page value used to limit the value caps returned to
425 those on a given usage page. If set to 0, this parameter is
426 ignored. Can be used with LinkCollection and Usage parameters
427 to further limit the number of value caps structures returned.
428
429 LinkCollection HIDP_LINK_COLLECTION node array index used to limit the
430 value caps returned to those buttons in a given link
431 collection. If set to 0, this parameter is
432 ignored. Can be used with UsagePage and Usage parameters
433 to further limit the number of value caps structures
434 returned.
435
436 Usage A usage value used to limit the value caps returned to those
437 with the specified usage value. If set to 0, this parameter
438 is ignored. Can be used with LinkCollection and UsagePage
439 parameters to further limit the number of value caps
440 structures returned.
441
442 ValueCaps A _HIDP_VALUE_CAPS array containing information about all the
443 non-binary values in the given report. This buffer is provided
444 by the caller.
445
446 ValueLength As input, this parameter specifies the length of the ValueCaps
447 parameter (array) in number of array elements. As output,
448 this value is set to indicate how many of those array elements
449 were filled in by the function. The maximum number of
450 value caps that can be returned is found in the HIDP_CAPS
451 structure. If HIDP_STATUS_BUFFER_TOO_SMALL is returned,
452 this value contains the number of array elements needed to
453 successfully complete the request.
454
455 PreparsedData The preparsed data returned from HIDCLASS.
456
457
458Return Value
459HidP_GetValueCaps returns the following error codes:
460· HIDP_STATUS_SUCCESS.
461· HIDP_STATUS_INVALID_REPORT_TYPE
462· HIDP_STATUS_INVALID_PREPARSED_DATA
463· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)
464· HIDP_STATUS_USAGE_NOT_FOUND
465
466--*/
467
468NTSTATUS __stdcall HidP_GetExtendedAttributes(
469 IN HIDP_REPORT_TYPE ReportType,
470 IN USHORT DataIndex,
471 IN PHIDP_PREPARSED_DATA PreparsedData,
472 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
473 IN OUT PULONG LengthAttributes);
474/*++
475Description:
476 Given a data index from the value or button capabilities of a given control
477 return any extended attributes for the control if any exist.
478
479Parameters:
480 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
481
482 DataIndex The data index for the given control, found in the capabilities
483 structure for that control
484
485 PreparsedData The preparsed data returned from HIDCLASS.
486
487 Attributes Pointer to a buffer into which the extended attribute data will
488 be copied.
489
490 LengthAttributes Length of the given buffer in bytes.
491
492Return Value
493 HIDP_STATUS_SUCCESS
494 HIDP_STATUS_DATA_INDEX_NOT_FOUND
495--*/
496
497NTSTATUS __stdcall HidP_InitializeReportForID(IN HIDP_REPORT_TYPE ReportType,
498 IN UCHAR ReportID,
499 IN PHIDP_PREPARSED_DATA
500 PreparsedData,
501 IN OUT PCHAR Report,
502 IN ULONG ReportLength);
503/*++
504
505Routine Description:
506
507 Initialize a report based on the given report ID.
508
509Parameters:
510
511 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
512
513 PreparasedData Preparsed data structure returned by HIDCLASS
514
515 Report Buffer which to set the data into.
516
517 ReportLength Length of Report...Report should be at least as long as the
518 value indicated in the HIDP_CAPS structure for the device and
519 the corresponding ReportType
520
521Return Value
522
523· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
524· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
525· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
526equal to the length specified in HIDP_CAPS structure for the given ReportType ·
527HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device for
528the given ReportType
529
530--*/
531
532NTSTATUS __stdcall HidP_SetData(IN HIDP_REPORT_TYPE ReportType,
533 IN PHIDP_DATA DataList,
534 IN OUT PULONG DataLength,
535 IN PHIDP_PREPARSED_DATA PreparsedData,
536 IN OUT PCHAR Report,
537 IN ULONG ReportLength);
538/*++
539
540Routine Description:
541
542 Please Note: Since usage value arrays deal with multiple fields for
543 for one usage value, they cannot be used with HidP_SetData
544 and HidP_GetData. In this case,
545 HIDP_STATUS_IS_USAGE_VALUE_ARRAY will be returned.
546
547Parameters:
548
549 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
550
551 DataList Array of HIDP_DATA structures that contains the data values
552 that are to be set into the given report
553
554 DataLength As input, length in array elements of DataList. As output,
555 contains the number of data elements set on successful
556 completion or an index into the DataList array to identify
557 the faulting HIDP_DATA value if an error code is returned.
558
559 PreparasedData Preparsed data structure returned by HIDCLASS
560
561 Report Buffer which to set the data into.
562
563 ReportLength Length of Report...Report should be at least as long as the
564 value indicated in the HIDP_CAPS structure for the device and
565 the corresponding ReportType
566
567Return Value
568 HidP_SetData returns the following error codes. The report packet will
569 have all the data set up until the HIDP_DATA structure that caused the
570 error. DataLength, in the error case, will return this problem index.
571
572· HIDP_STATUS_SUCCESS -- upon successful insertion of all data
573 into the report packet.
574· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
575· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
576· HIDP_STATUS_DATA_INDEX_NOT_FOUND -- if a HIDP_DATA structure referenced a
577 data index that does not exist for this
578 device's ReportType
579· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
580equal to the length specified in HIDP_CAPS structure for the given ReportType ·
581HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device for
582the given ReportType · HIDP_STATUS_IS_USAGE_VALUE_ARRAY -- if one of the
583HIDP_DATA structures references a usage value array. DataLength will contain the
584index into the array that was invalid · HIDP_STATUS_BUTTON_NOT_PRESSED -- if
585a HIDP_DATA structure attempted to unset a button that was not already set in
586the Report · HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- a HIDP_DATA structure was
587found with a valid index value but is contained in a different report than the
588one currently being processed · HIDP_STATUS_BUFFER_TOO_SMALL -- if there
589are not enough entries in a given Main Array Item to report all buttons that
590have been requested to be set
591--*/
592
593NTSTATUS __stdcall HidP_GetData(IN HIDP_REPORT_TYPE ReportType,
594 OUT PHIDP_DATA DataList,
595 IN OUT PULONG DataLength,
596 IN PHIDP_PREPARSED_DATA PreparsedData,
597 IN PCHAR Report,
598 IN ULONG ReportLength);
599/*++
600
601Routine Description:
602
603 Please Note: For obvious reasons HidP_SetData and HidP_GetData will not
604 access UsageValueArrays.
605
606Parameters:
607 ReportType One of HidP_Input, HidP_Output, or HidP_Feature.
608
609 DataList Array of HIDP_DATA structures that will receive the data
610 values that are set in the given report
611
612 DataLength As input, length in array elements of DataList. As output,
613 contains the number of data elements that were successfully
614 set by HidP_GetData. The maximum size necessary for DataList
615 can be determined by calling HidP_MaxDataListLength
616
617 PreparasedData Preparsed data structure returned by HIDCLASS
618
619 Report Buffer which to set the data into.
620
621 ReportLength Length of Report...Report should be at least as long as the
622 value indicated in the HIDP_CAPS structure for the device and
623 the corresponding ReportType
624
625Return Value
626 HidP_GetData returns the following error codes.
627
628· HIDP_STATUS_SUCCESS -- upon successful retrieval of all data
629 from the report packet.
630· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
631· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
632· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
633equal to the length specified in HIDP_CAPS structure for the given ReportType ·
634HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device for
635the given ReportType · HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not
636enough array entries in DataList to store all the indice values in the given
637report. DataLength will contain the number of array entries required to hold
638all data
639--*/
640
641ULONG __stdcall HidP_MaxDataListLength(IN HIDP_REPORT_TYPE ReportType,
642 IN PHIDP_PREPARSED_DATA PreparsedData);
643/*++
644Routine Description:
645
646 This function returns the maximum length of HIDP_DATA elements that
647 HidP_GetData could return for the given report type.
648
649Parameters:
650
651 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
652
653 PreparsedData Preparsed data structure returned by HIDCLASS
654
655Return Value:
656
657 The length of the data list array required for the HidP_GetData function
658 call. If an error occurs (either HIDP_STATUS_INVALID_REPORT_TYPE or
659 HIDP_STATUS_INVALID_PREPARSED_DATA), this function returns 0.
660
661--*/
662
663#define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
664 HidP_SetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
665
666NTSTATUS __stdcall HidP_SetUsages(IN HIDP_REPORT_TYPE ReportType,
667 IN USAGE UsagePage,
668 IN USHORT LinkCollection, // Optional
669 IN PUSAGE UsageList,
670 IN OUT PULONG UsageLength,
671 IN PHIDP_PREPARSED_DATA PreparsedData,
672 IN OUT PCHAR Report,
673 IN ULONG ReportLength);
674/*++
675
676Routine Description:
677 This function sets binary values (buttons) in a report. Given an
678 initialized packet of correct length, it modifies the report packet so that
679 each element in the given list of usages has been set in the report packet.
680 For example, in an output report with 5 LED’s, each with a given usage,
681 an application could turn on any subset of these lights by placing their
682 usages in any order into the usage array (UsageList). HidP_SetUsages would,
683 in turn, set the appropriate bit or add the corresponding byte into the
684 HID Main Array Item.
685
686 A properly initialized Report packet is one of the correct byte length,
687 and all zeros.
688
689 NOTE: A packet that has already been set with a call to a HidP_Set routine
690 can also be passed in. This routine then sets processes the UsageList
691 in the same fashion but verifies that the ReportID already set in
692 Report matches the report ID for the given usages.
693
694Parameters:
695 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
696
697 UsagePage All of the usages in the usage array, which HidP_SetUsages will
698 set in the report, refer to this same usage page.
699 If a client wishes to set usages in a report for multiple
700 usage pages then that client needs to make multiple calls to
701 HidP_SetUsages for each of the usage pages.
702
703 UsageList A usage array containing the usages that HidP_SetUsages will set
704in the report packet.
705
706 UsageLength The length of the given usage array in array elements.
707 The parser will set this value to the position in the usage
708 array where it stopped processing. If successful, UsageLength
709 will be unchanged. In any error condition, this parameter
710 reflects how many of the usages in the usage list have
711 actually been set by the parser. This is useful for finding
712 the usage in the list which caused the error.
713
714 PreparsedData The preparsed data recevied from HIDCLASS
715
716 Report The report packet.
717
718 ReportLength Length of the given report packet...Must be equal to the
719 value reported in the HIDP_CAPS structure for the device
720 and corresponding report type.
721
722Return Value
723 HidP_SetUsages returns the following error codes. On error, the report
724packet will be correct up until the usage element that caused the error.
725
726· HIDP_STATUS_SUCCESS -- upon successful insertion of all usages
727 into the report packet.
728· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
729· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
730· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
731 equal to the length specified in
732 the HIDP_CAPS structure for the given
733 ReportType
734· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
735 for the given ReportType
736· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
737 different report. If the report is
738 zero-initialized on entry the first
739 usage in the list will determine which
740 report ID is used. Otherwise, the
741 parser will verify that usage matches
742 the passed in report's ID
743· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any
744 report (no matter what the report ID)
745 for the given report type.
746· HIDP_STATUS_BUFFER_TOO_SMALL -- if there are not enough entries in a
747 given Main Array Item to list all of
748 the given usages. The caller needs
749 to split his request into more than
750 one call
751--*/
752
753#define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \
754 HidP_UnsetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)
755
756NTSTATUS __stdcall HidP_UnsetUsages(IN HIDP_REPORT_TYPE ReportType,
757 IN USAGE UsagePage,
758 IN USHORT LinkCollection, // Optional
759 IN PUSAGE UsageList,
760 IN OUT PULONG UsageLength,
761 IN PHIDP_PREPARSED_DATA PreparsedData,
762 IN OUT PCHAR Report,
763 IN ULONG ReportLength);
764/*++
765
766Routine Description:
767 This function unsets (turns off) binary values (buttons) in the report.
768Given an initialized packet of correct length, it modifies the report packet so
769 that each element in the given list of usages has been unset in the
770 report packet.
771
772 This function is the "undo" operation for SetUsages. If the given usage
773 is not already set in the Report, it will return an error code of
774 HIDP_STATUS_BUTTON_NOT_PRESSED. If the button is pressed, HidP_UnsetUsages
775 will unset the appropriate bit or remove the corresponding index value from
776 the HID Main Array Item.
777
778 A properly initialized Report packet is one of the correct byte length,
779 and all zeros..
780
781 NOTE: A packet that has already been set with a call to a HidP_Set routine
782 can also be passed in. This routine then processes the UsageList
783 in the same fashion but verifies that the ReportID already set in
784 Report matches the report ID for the given usages.
785
786Parameters:
787 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
788
789 UsagePage All of the usages in the usage array, which HidP_UnsetUsages
790will unset in the report, refer to this same usage page. If a client wishes to
791unset usages in a report for multiple usage pages then that client needs to make
792multiple calls to HidP_UnsetUsages for each of the usage pages.
793
794 UsageList A usage array containing the usages that HidP_UnsetUsages will
795 unset in the report packet.
796
797 UsageLength The length of the given usage array in array elements.
798 The parser will set this value to the position in the usage
799 array where it stopped processing. If successful, UsageLength
800 will be unchanged. In any error condition, this parameter
801 reflects how many of the usages in the usage list have
802 actually been unset by the parser. This is useful for finding
803 the usage in the list which caused the error.
804
805 PreparsedData The preparsed data recevied from HIDCLASS
806
807 Report The report packet.
808
809 ReportLength Length of the given report packet...Must be equal to the
810 value reported in the HIDP_CAPS structure for the device
811 and corresponding report type.
812
813Return Value
814 HidP_UnsetUsages returns the following error codes. On error, the report
815 packet will be correct up until the usage element that caused the error.
816
817· HIDP_STATUS_SUCCESS -- upon successful "unsetting" of all
818usages in the report packet. · HIDP_STATUS_INVALID_REPORT_TYPE -- if
819ReportType is not valid. · HIDP_STATUS_INVALID_PREPARSED_DATA -- if
820PreparsedData is not valid · HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of
821the report packet is not equal to the length specified in the HIDP_CAPS
822structure for the given ReportType · HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if
823there are no reports on this device for the given ReportType ·
824HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a
825 different report. If the report is
826 zero-initialized on entry the first
827 usage in the list will determine which
828 report ID is used. Otherwise, the
829 parser will verify that usage matches
830 the passed in report's ID
831· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage does not exist for any
832 report (no matter what the report ID)
833 for the given report type.
834· HIDP_STATUS_BUTTON_NOT_PRESSED -- if a usage corresponds to a button that
835 is not already set in the given report
836--*/
837
838#define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
839 HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
840
841NTSTATUS __stdcall HidP_GetUsages(IN HIDP_REPORT_TYPE ReportType,
842 IN USAGE UsagePage,
843 IN USHORT LinkCollection, // Optional
844 OUT USAGE* UsageList,
845 IN OUT ULONG* UsageLength,
846 IN PHIDP_PREPARSED_DATA PreparsedData,
847 IN PCHAR Report,
848 IN ULONG ReportLength);
849/*++
850
851Routine Description:
852 This function returns the binary values (buttons) that are set in a HID
853 report. Given a report packet of correct length, it searches the report
854 packet for each usage for the given usage page and returns them in the
855 usage list.
856
857Parameters:
858 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
859
860 UsagePage All of the usages in the usage list, which HidP_GetUsages will
861 retrieve in the report, refer to this same usage page.
862 If the client wishes to get usages in a packet for multiple
863 usage pages then that client needs to make multiple calls
864 to HidP_GetUsages.
865
866 LinkCollection An optional value which can limit which usages are returned
867 in the UsageList to those usages that exist in a specific
868 LinkCollection. A non-zero value indicates the index into
869 the HIDP_LINK_COLLECITON_NODE list returned by
870 HidP_GetLinkCollectionNodes of the link collection the
871 usage should belong to. A value of 0 indicates this
872 should value be ignored.
873
874 UsageList The usage array that will contain all the usages found in
875 the report packet.
876
877 UsageLength The length of the given usage array in array elements.
878 On input, this value describes the length of the usage list.
879 On output, HidP_GetUsages sets this value to the number of
880 usages that was found. Use HidP_MaxUsageListLength to
881 determine the maximum length needed to return all the usages
882 that a given report packet may contain.
883
884 PreparsedData Preparsed data structure returned by HIDCLASS
885
886 Report The report packet.
887
888 ReportLength Length (in bytes) of the given report packet
889
890
891Return Value
892 HidP_GetUsages returns the following error codes:
893
894· HIDP_STATUS_SUCCESS -- upon successfully retrieving all the
895 usages from the report packet
896· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
897· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
898· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
899 equal to the length specified in
900 the HIDP_CAPS structure for the given
901 ReportType
902· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
903 for the given ReportType
904· HIDP_STATUS_BUFFER_TOO_SMALL -- if the UsageList is not big enough to
905 hold all the usages found in the report
906 packet. If this is returned, the buffer
907 will contain UsageLength number of
908 usages. Use HidP_MaxUsageListLength to
909 find the maximum length needed
910· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
911 that match the UsagePage and
912 LinkCollection specified could be found
913 in a report with a different report ID
914· HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in a reports for
915 the device and ReportType that match the
916 UsagePage and LinkCollection that were
917 specified
918--*/
919
920#define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe) \
921 HidP_GetUsagesEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)
922
923NTSTATUS __stdcall HidP_GetUsagesEx(IN HIDP_REPORT_TYPE ReportType,
924 IN USHORT LinkCollection, // Optional
925 OUT PUSAGE_AND_PAGE ButtonList,
926 IN OUT ULONG* UsageLength,
927 IN PHIDP_PREPARSED_DATA PreparsedData,
928 IN PCHAR Report,
929 IN ULONG ReportLength);
930
931/*++
932
933Routine Description:
934 This function returns the binary values (buttons) in a HID report.
935 Given a report packet of correct length, it searches the report packet
936 for all buttons and returns the UsagePage and Usage for each of the buttons
937 it finds.
938
939Parameters:
940 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
941
942 LinkCollection An optional value which can limit which usages are returned
943 in the ButtonList to those usages that exist in a specific
944 LinkCollection. A non-zero value indicates the index into
945 the HIDP_LINK_COLLECITON_NODE list returned by
946 HidP_GetLinkCollectionNodes of the link collection the
947 usage should belong to. A value of 0 indicates this
948 should value be ignored.
949
950 ButtonList An array of USAGE_AND_PAGE structures describing all the
951 buttons currently ``down'' in the device.
952
953 UsageLength The length of the given array in terms of elements.
954 On input, this value describes the length of the list. On
955 output, HidP_GetUsagesEx sets this value to the number of
956 usages that were found. Use HidP_MaxUsageListLength to
957 determine the maximum length needed to return all the usages
958 that a given report packet may contain.
959
960 PreparsedData Preparsed data returned by HIDCLASS
961
962 Report The report packet.
963
964 ReportLength Length (in bytes) of the given report packet.
965
966
967Return Value
968 HidP_GetUsagesEx returns the following error codes:
969
970· HIDP_STATUS_SUCCESS -- upon successfully retrieving all the
971 usages from the report packet
972· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
973· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
974· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
975 equal to the length specified in
976 the HIDP_CAPS structure for the given
977 ReportType
978· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
979 for the given ReportType
980· HIDP_STATUS_BUFFER_TOO_SMALL -- if ButtonList is not big enough to
981 hold all the usages found in the report
982 packet. If this is returned, the buffer
983 will contain UsageLength number of
984 usages. Use HidP_MaxUsageListLength to
985 find the maximum length needed
986· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages
987 that match the specified LinkCollection
988 exist in report with a different report
989 ID.
990· HIDP_STATUS_USAGE_NOT_FOUND -- if there are no usages in any reports
991that match the LinkCollection parameter
992--*/
993
994#define HidP_GetButtonListLength(RTy, UPa, Ppd) \
995 HidP_GetUsageListLength(Rty, UPa, Ppd)
996
997ULONG __stdcall HidP_MaxUsageListLength(IN HIDP_REPORT_TYPE ReportType,
998 IN USAGE UsagePage, // Optional
999 IN PHIDP_PREPARSED_DATA PreparsedData);
1000/*++
1001Routine Description:
1002 This function returns the maximum number of usages that a call to
1003 HidP_GetUsages or HidP_GetUsagesEx could return for a given HID report.
1004 If calling for number of usages returned by HidP_GetUsagesEx, use 0 as
1005 the UsagePage value.
1006
1007Parameters:
1008 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
1009
1010 UsagePage Specifies the optional UsagePage to query for. If 0, will
1011 return all the maximum number of usage values that could be
1012 returned for a given ReportType. If non-zero, will return
1013 the maximum number of usages that would be returned for the
1014 ReportType with the given UsagePage.
1015
1016 PreparsedData Preparsed data returned from HIDCLASS
1017
1018Return Value:
1019 The length of the usage list array required for the HidP_GetUsages or
1020 HidP_GetUsagesEx function call. If an error occurs (such as
1021 HIDP_STATUS_INVALID_REPORT_TYPE or HIDP_INVALID_PREPARSED_DATA, this
1022 returns 0.
1023--*/
1024
1025NTSTATUS __stdcall HidP_SetUsageValue(IN HIDP_REPORT_TYPE ReportType,
1026 IN USAGE UsagePage,
1027 IN USHORT LinkCollection, // Optional
1028 IN USAGE Usage,
1029 IN ULONG UsageValue,
1030 IN PHIDP_PREPARSED_DATA PreparsedData,
1031 IN OUT PCHAR Report,
1032 IN ULONG ReportLength);
1033/*++
1034Description:
1035 HidP_SetUsageValue inserts a value into the HID Report Packet in the field
1036 corresponding to the given usage page and usage. HidP_SetUsageValue
1037 casts this value to the appropriate bit length. If a report packet
1038 contains two different fields with the same Usage and UsagePage,
1039 they can be distinguished with the optional LinkCollection field value.
1040 Using this function sets the raw value into the report packet with
1041 no checking done as to whether it actually falls within the logical
1042 minimum/logical maximum range. Use HidP_SetScaledUsageValue for this...
1043
1044 NOTE: Although the UsageValue parameter is a ULONG, any casting that is
1045 done will preserve or sign-extend the value. The value being set
1046 should be considered a LONG value and will be treated as such by
1047 this function.
1048
1049Parameters:
1050
1051 ReportType One of HidP_Output or HidP_Feature.
1052
1053 UsagePage The usage page to which the given usage refers.
1054
1055 LinkCollection (Optional) This value can be used to differentiate
1056 between two fields that may have the same
1057 UsagePage and Usage but exist in different
1058 collections. If the link collection value
1059 is zero, this function will set the first field
1060 it finds that matches the usage page and
1061 usage.
1062
1063 Usage The usage whose value HidP_SetUsageValue will set.
1064
1065 UsageValue The raw value to set in the report buffer. This value must be
1066within the logical range or if a NULL value this value should be the most
1067negative value that can be represented by the number of bits for this field.
1068
1069 PreparsedData The preparsed data returned for HIDCLASS
1070
1071 Report The report packet.
1072
1073 ReportLength Length (in bytes) of the given report packet.
1074
1075
1076Return Value:
1077 HidP_SetUsageValue returns the following error codes:
1078
1079· HIDP_STATUS_SUCCESS -- upon successfully setting the value
1080 in the report packet
1081· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1082· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1083· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1084 equal to the length specified in
1085 the HIDP_CAPS structure for the given
1086 ReportType
1087· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
1088 for the given ReportType
1089· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
1090 link collection exist but exists in
1091 a report with a different report ID
1092 than the report being passed in. To
1093 set this value, call HidP_SetUsageValue
1094 again with a zero-initizialed report
1095 packet
1096· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
1097 collection combination does not exist
1098 in any reports for this ReportType
1099--*/
1100
1101NTSTATUS __stdcall HidP_SetScaledUsageValue(
1102 IN HIDP_REPORT_TYPE ReportType,
1103 IN USAGE UsagePage,
1104 IN USHORT LinkCollection, // Optional
1105 IN USAGE Usage,
1106 IN LONG UsageValue,
1107 IN PHIDP_PREPARSED_DATA PreparsedData,
1108 IN OUT PCHAR Report,
1109 IN ULONG ReportLength);
1110
1111/*++
1112Description:
1113 HidP_SetScaledUsageValue inserts the UsageValue into the HID report packet
1114 in the field corresponding to the given usage page and usage. If a report
1115 packet contains two different fields with the same Usage and UsagePage,
1116 they can be distinguished with the optional LinkCollection field value.
1117
1118 If the specified field has a defined physical range, this function converts
1119 the physical value specified to the corresponding logical value for the
1120 report. If a physical value does not exist, the function will verify that
1121 the value specified falls within the logical range and set according.
1122
1123 If the range checking fails but the field has NULL values, the function will
1124 set the field to the defined NULL value (most negative number possible) and
1125 return HIDP_STATUS_NULL. In other words, use this function to set NULL
1126 values for a given field by passing in a value that falls outside the
1127 physical range if it is defined or the logical range otherwise.
1128
1129 If the field does not support NULL values, an out of range error will be
1130 returned instead.
1131
1132Parameters:
1133
1134 ReportType One of HidP_Output or HidP_Feature.
1135
1136 UsagePage The usage page to which the given usage refers.
1137
1138 LinkCollection (Optional) This value can be used to differentiate
1139 between two fields that may have the same
1140 UsagePage and Usage but exist in different
1141 collections. If the link collection value
1142 is zero, this function will set the first field
1143 it finds that matches the usage page and
1144 usage.
1145
1146 Usage The usage whose value HidP_SetScaledUsageValue will set.
1147
1148 UsageValue The value to set in the report buffer. See the routine
1149 description above for the different interpretations of this
1150 value
1151
1152 PreparsedData The preparsed data returned from HIDCLASS
1153
1154 Report The report packet.
1155
1156 ReportLength Length (in bytes) of the given report packet.
1157
1158
1159Return Value:
1160 HidP_SetScaledUsageValue returns the following error codes:
1161
1162· HIDP_STATUS_SUCCESS -- upon successfully setting the value
1163 in the report packet
1164· HIDP_STATUS_NULL -- upon successfully setting the value
1165 in the report packet as a NULL value
1166· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1167· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1168· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1169 equal to the length specified in
1170 the HIDP_CAPS structure for the given
1171 ReportType
1172· HIDP_STATUS_VALUE_OUT_OF_RANGE -- if the value specified failed to fall
1173 within the physical range if it exists
1174 or within the logical range otherwise
1175 and the field specified by the usage
1176 does not allow NULL values
1177· HIDP_STATUS_BAD_LOG_PHY_VALUES -- if the field has a physical range but
1178 either the logical range is invalid
1179 (max <= min) or the physical range is
1180 invalid
1181· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
1182 link collection exist but exists in
1183 a report with a different report ID
1184 than the report being passed in. To
1185 set this value, call
1186 HidP_SetScaledUsageValue again with
1187 a zero-initialized report packet
1188· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
1189 collection combination does not exist
1190 in any reports for this ReportType
1191--*/
1192
1193NTSTATUS __stdcall HidP_SetUsageValueArray(IN HIDP_REPORT_TYPE ReportType,
1194 IN USAGE UsagePage,
1195 IN USHORT LinkCollection, // Optional
1196 IN USAGE Usage,
1197 IN PCHAR UsageValue,
1198 IN USHORT UsageValueByteLength,
1199 IN PHIDP_PREPARSED_DATA
1200 PreparsedData,
1201 OUT PCHAR Report,
1202 IN ULONG ReportLength);
1203
1204/*++
1205Routine Descripton:
1206 A usage value array occurs when the last usage in the list of usages
1207 describing a main item must be repeated because there are less usages
1208defined than there are report counts declared for the given main item. In this
1209case a single value cap is allocated for that usage and the report count of that
1210 value cap is set to reflect the number of fields to which that usage refers.
1211
1212 HidP_SetUsageValueArray sets the raw bits for that usage which spans
1213 more than one field in a report.
1214
1215 NOTE: This function currently does not support value arrays where the
1216 ReportSize for each of the fields in the array is not a multiple
1217 of 8 bits.
1218
1219 The UsageValue buffer should have the values set as they would appear
1220 in the report buffer. If this function supported non 8-bit multiples
1221 for the ReportSize then caller should format the input buffer so that
1222 each new value begins at the bit immediately following the last bit
1223 of the previous value
1224
1225Parameters:
1226
1227 ReportType One of HidP_Output or HidP_Feature.
1228
1229 UsagePage The usage page to which the given usage refers.
1230
1231 LinkCollection (Optional) This value can be used to differentiate
1232 between two fields that may have the same
1233 UsagePage and Usage but exist in different
1234 collections. If the link collection value
1235 is zero, this function will set the first field
1236 it finds that matches the usage page and
1237 usage.
1238
1239 Usage The usage whose value array HidP_SetUsageValueArray will set.
1240
1241 UsageValue The buffer with the values to set into the value array.
1242 The number of BITS required is found by multiplying the
1243 BitSize and ReportCount fields of the Value Cap for this
1244 control. The least significant bit of this control found in the
1245 given report will be placed in the least significan bit location
1246 of the array given (little-endian format), regardless of whether
1247 or not the field is byte alligned or if the BitSize is a
1248multiple of sizeof (CHAR).
1249
1250 See the above note for current implementation limitations.
1251
1252 UsageValueByteLength Length of the UsageValue buffer (in bytes)
1253
1254 PreparsedData The preparsed data returned from HIDCLASS
1255
1256 Report The report packet.
1257
1258 ReportLength Length (in bytes) of the given report packet.
1259
1260
1261Return Value:
1262· HIDP_STATUS_SUCCESS -- upon successfully setting the value
1263 array in the report packet
1264· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1265· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1266· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1267 equal to the length specified in
1268 the HIDP_CAPS structure for the given
1269 ReportType
1270· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
1271 for the given ReportType
1272· HIDP_STATUS_NOT_VALUE_ARRAY -- if the control specified is not a
1273 value array -- a value array will have
1274 a ReportCount field in the
1275 HIDP_VALUE_CAPS structure that is > 1
1276 Use HidP_SetUsageValue instead
1277· HIDP_STATUS_BUFFER_TOO_SMALL -- if the size of the passed in buffer with
1278 the values to set is too small (ie. has
1279 fewer values than the number of fields
1280in the array · HIDP_STATUS_NOT_IMPLEMENTED -- if the usage value array
1281has field sizes that are not multiples of 8 bits, this error code is returned
1282since the function currently does not handle setting into such arrays. ·
1283HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and link
1284collection exist but exists in a report with a different report ID than the
1285report being passed in. To set this value, call HidP_SetUsageValueArray again
1286with a zero-initialized report packet · HIDP_STATUS_USAGE_NOT_FOUND -- if
1287the usage page, usage, and link collection combination does not exist in any
1288reports for this ReportType
1289--*/
1290
1291NTSTATUS __stdcall HidP_GetUsageValue(IN HIDP_REPORT_TYPE ReportType,
1292 IN USAGE UsagePage,
1293 IN USHORT LinkCollection, // Optional
1294 IN USAGE Usage,
1295 OUT PULONG UsageValue,
1296 IN PHIDP_PREPARSED_DATA PreparsedData,
1297 IN PCHAR Report,
1298 IN ULONG ReportLength);
1299
1300/*
1301Description
1302 HidP_GetUsageValue retrieves the value from the HID Report for the usage
1303 specified by the combination of usage page, usage and link collection.
1304 If a report packet contains two different fields with the same
1305 Usage and UsagePage, they can be distinguished with the optional
1306 LinkCollection field value.
1307
1308Parameters:
1309
1310 ReportType One of HidP_Input or HidP_Feature.
1311
1312 UsagePage The usage page to which the given usage refers.
1313
1314 LinkCollection (Optional) This value can be used to differentiate
1315 between two fields that may have the same
1316 UsagePage and Usage but exist in different
1317 collections. If the link collection value
1318 is zero, this function will set the first field
1319 it finds that matches the usage page and
1320 usage.
1321
1322 Usage The usage whose value HidP_GetUsageValue will retrieve
1323
1324 UsageValue The raw value that is set for the specified field in the report
1325 buffer. This value will either fall within the logical range
1326 or if NULL values are allowed, a number outside the range to
1327 indicate a NULL
1328
1329 PreparsedData The preparsed data returned for HIDCLASS
1330
1331 Report The report packet.
1332
1333 ReportLength Length (in bytes) of the given report packet.
1334
1335
1336Return Value:
1337 HidP_GetUsageValue returns the following error codes:
1338
1339· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value
1340 from the report packet
1341· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1342· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1343· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1344 equal to the length specified in
1345 the HIDP_CAPS structure for the given
1346 ReportType
1347· HIDP_STATUS_REPORT_DOES_NOT_EXIST -- if there are no reports on this device
1348 for the given ReportType
1349· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
1350 link collection exist but exists in
1351 a report with a different report ID
1352 than the report being passed in. To
1353 set this value, call HidP_GetUsageValue
1354 again with a different report packet
1355· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
1356 collection combination does not exist
1357 in any reports for this ReportType
1358--*/
1359
1360NTSTATUS __stdcall HidP_GetScaledUsageValue(
1361 IN HIDP_REPORT_TYPE ReportType,
1362 IN USAGE UsagePage,
1363 IN USHORT LinkCollection, // Optional
1364 IN USAGE Usage,
1365 OUT PLONG UsageValue,
1366 IN PHIDP_PREPARSED_DATA PreparsedData,
1367 IN PCHAR Report,
1368 IN ULONG ReportLength);
1369
1370/*++
1371Description
1372 HidP_GetScaledUsageValue retrieves a UsageValue from the HID report packet
1373 in the field corresponding to the given usage page and usage. If a report
1374 packet contains two different fields with the same Usage and UsagePage,
1375 they can be distinguished with the optional LinkCollection field value.
1376
1377 If the specified field has a defined physical range, this function converts
1378 the logical value that exists in the report packet to the corresponding
1379 physical value. If a physical range does not exist, the function will
1380 return the logical value. This function will check to verify that the
1381 logical value in the report falls within the declared logical range.
1382
1383 When doing the conversion between logical and physical values, this
1384 function assumes a linear extrapolation between the physical max/min and
1385 the logical max/min. (Where logical is the values reported by the device
1386 and physical is the value returned by this function). If the data field
1387 size is less than 32 bits, then HidP_GetScaledUsageValue will sign extend
1388 the value to 32 bits.
1389
1390 If the range checking fails but the field has NULL values, the function
1391 will set UsageValue to 0 and return HIDP_STATUS_NULL. Otherwise, it
1392 returns a HIDP_STATUS_OUT_OF_RANGE error.
1393
1394Parameters:
1395
1396 ReportType One of HidP_Output or HidP_Feature.
1397
1398 UsagePage The usage page to which the given usage refers.
1399
1400 LinkCollection (Optional) This value can be used to differentiate
1401 between two fields that may have the same
1402 UsagePage and Usage but exist in different
1403 collections. If the link collection value
1404 is zero, this function will retrieve the first
1405 field it finds that matches the usage page
1406 and usage.
1407
1408 Usage The usage whose value HidP_GetScaledUsageValue will retrieve
1409
1410 UsageValue The value retrieved from the report buffer. See the routine
1411 description above for the different interpretations of this
1412 value
1413
1414 PreparsedData The preparsed data returned from HIDCLASS
1415
1416 Report The report packet.
1417
1418 ReportLength Length (in bytes) of the given report packet.
1419
1420
1421Return Value:
1422 HidP_GetScaledUsageValue returns the following error codes:
1423
1424· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value
1425 from the report packet
1426· HIDP_STATUS_NULL -- if the report packet had a NULL value
1427 set
1428· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1429· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1430· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1431 equal to the length specified in
1432 the HIDP_CAPS structure for the given
1433 ReportType
1434· HIDP_STATUS_VALUE_OUT_OF_RANGE -- if the value retrieved from the packet
1435 falls outside the logical range and
1436 the field does not support NULL values
1437· HIDP_STATUS_BAD_LOG_PHY_VALUES -- if the field has a physical range but
1438 either the logical range is invalid
1439 (max <= min) or the physical range is
1440 invalid
1441· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and
1442 link collection exist but exists in
1443 a report with a different report ID
1444 than the report being passed in. To
1445 set this value, call
1446 HidP_GetScaledUsageValue with a
1447 different report packet
1448· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
1449 collection combination does not exist
1450 in any reports for this ReportType
1451--*/
1452
1453NTSTATUS __stdcall HidP_GetUsageValueArray(IN HIDP_REPORT_TYPE ReportType,
1454 IN USAGE UsagePage,
1455 IN USHORT LinkCollection, // Optional
1456 IN USAGE Usage,
1457 OUT PCHAR UsageValue,
1458 IN USHORT UsageValueByteLength,
1459 IN PHIDP_PREPARSED_DATA
1460 PreparsedData,
1461 IN PCHAR Report,
1462 IN ULONG ReportLength);
1463
1464/*++
1465Routine Descripton:
1466 A usage value array occurs when the last usage in the list of usages
1467 describing a main item must be repeated because there are less usages
1468defined than there are report counts declared for the given main item. In this
1469case a single value cap is allocated for that usage and the report count of that
1470 value cap is set to reflect the number of fields to which that usage refers.
1471
1472 HidP_GetUsageValueArray returns the raw bits for that usage which spans
1473 more than one field in a report.
1474
1475 NOTE: This function currently does not support value arrays where the
1476 ReportSize for each of the fields in the array is not a multiple
1477 of 8 bits.
1478
1479 The UsageValue buffer will have the raw values as they are set
1480 in the report packet.
1481
1482Parameters:
1483
1484 ReportType One of HidP_Input, HidP_Output or HidP_Feature.
1485
1486 UsagePage The usage page to which the given usage refers.
1487
1488 LinkCollection (Optional) This value can be used to differentiate
1489 between two fields that may have the same
1490 UsagePage and Usage but exist in different
1491 collections. If the link collection value
1492 is zero, this function will set the first field
1493 it finds that matches the usage page and
1494 usage.
1495
1496 Usage The usage whose value HidP_GetUsageValueArray will retreive.
1497
1498 UsageValue A pointer to an array of characters where the value will be
1499 placed. The number of BITS required is found by multiplying the
1500 BitSize and ReportCount fields of the Value Cap for this
1501 control. The least significant bit of this control found in the
1502 given report will be placed in the least significant bit location
1503 of the buffer (little-endian format), regardless of whether
1504 or not the field is byte aligned or if the BitSize is a multiple
1505 of sizeof (CHAR).
1506
1507 See note above about current implementation limitations
1508
1509 UsageValueByteLength
1510 the length of the given UsageValue buffer.
1511
1512 PreparsedData The preparsed data returned by the HIDCLASS
1513
1514 Report The report packet.
1515
1516 ReportLength Length of the given report packet.
1517
1518Return Value:
1519
1520· HIDP_STATUS_SUCCESS -- upon successfully retrieving the value
1521 from the report packet
1522· HIDP_STATUS_INVALID_REPORT_TYPE -- if ReportType is not valid.
1523· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid
1524· HIDP_STATUS_INVALID_REPORT_LENGTH -- the length of the report packet is not
1525 equal to the length specified in
1526 the HIDP_CAPS structure for the given
1527 ReportType
1528· HIDP_STATUS_NOT_VALUE_ARRAY -- if the control specified is not a
1529 value array -- a value array will have
1530 a ReportCount field in the
1531 HIDP_VALUE_CAPS structure that is > 1
1532 Use HidP_GetUsageValue instead
1533· HIDP_STATUS_BUFFER_TOO_SMALL -- if the size of the passed in buffer in
1534 which to return the array is too small
1535 (ie. has fewer values than the number of
1536 fields in the array
1537· HIDP_STATUS_NOT_IMPLEMENTED -- if the usage value array has field sizes
1538 that are not multiples of 8 bits, this
1539 error code is returned since the
1540function currently does not handle getting values from such arrays. ·
1541HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and link
1542collection exist but exists in a report with a different report ID than the
1543report being passed in. To set this value, call HidP_GetUsageValueArray with a
1544 different report packet
1545· HIDP_STATUS_USAGE_NOT_FOUND -- if the usage page, usage, and link
1546 collection combination does not exist
1547 in any reports for this ReportType
1548--*/
1549
1550NTSTATUS __stdcall HidP_UsageListDifference(IN PUSAGE PreviousUsageList,
1551 IN PUSAGE CurrentUsageList,
1552 OUT PUSAGE BreakUsageList,
1553 OUT PUSAGE MakeUsageList,
1554 IN ULONG UsageListLength);
1555/*++
1556Routine Description:
1557 This function will return the difference between a two lists of usages
1558 (as might be returned from HidP_GetUsages), In other words, it will return
1559 return a list of usages that are in the current list but not the previous
1560 list as well as a list of usages that are in the previous list but not
1561 the current list.
1562
1563Parameters:
1564
1565 PreviousUsageList The list of usages before.
1566 CurrentUsageList The list of usages now.
1567 BreakUsageList Previous - Current.
1568 MakeUsageList Current - Previous.
1569 UsageListLength Represents the length of the usage lists in array
1570 elements. If comparing two lists with a differing
1571 number of array elements, this value should be
1572 the size of the larger of the two lists. Any
1573 zero found with a list indicates an early termination
1574 of the list and any usages found after the first zero
1575 will be ignored.
1576--*/
1577
1578NTSTATUS __stdcall HidP_UsageAndPageListDifference(
1579 IN PUSAGE_AND_PAGE PreviousUsageList,
1580 IN PUSAGE_AND_PAGE CurrentUsageList,
1581 OUT PUSAGE_AND_PAGE BreakUsageList,
1582 OUT PUSAGE_AND_PAGE MakeUsageList,
1583 IN ULONG UsageListLength);
1584
1585//
1586// Produce Make or Break Codes
1587//
1588typedef enum _HIDP_KEYBOARD_DIRECTION
1589{
1590 HidP_Keyboard_Break,
1591 HidP_Keyboard_Make
1592} HIDP_KEYBOARD_DIRECTION;
1593
1594//
1595// A bitmap of the current shift state of the keyboard when using the
1596// below keyboard usages to i8042 translation function.
1597//
1599{
1600 union {
1601 struct
1602 {
1603 ULONG LeftControl : 1;
1604 ULONG LeftShift : 1;
1605 ULONG LeftAlt : 1;
1606 ULONG LeftGUI : 1;
1607 ULONG RightControl : 1;
1608 ULONG RightShift : 1;
1609 ULONG RightAlt : 1;
1610 ULONG RigthGUI : 1;
1611 ULONG CapsLock : 1;
1612 ULONG ScollLock : 1;
1613 ULONG NumLock : 1;
1614 ULONG Reserved : 21;
1615 };
1616 ULONG ul;
1617 };
1618
1620
1621//
1622// A call back function to give the i8042 scan codes to the caller of
1623// the below translation function.
1624//
1625typedef BOOLEAN (*PHIDP_INSERT_SCANCODES)(
1626 IN PVOID Context, // Some caller supplied context.
1627 IN PCHAR NewScanCodes, // A list of i8042 scan codes.
1628 IN ULONG Length // the length of the scan codes.
1629);
1630
1631NTSTATUS __stdcall HidP_TranslateUsageAndPagesToI8042ScanCodes(
1632 IN PUSAGE_AND_PAGE ChangedUsageList,
1633 IN ULONG UsageListLength,
1634 IN HIDP_KEYBOARD_DIRECTION KeyAction,
1635 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
1636 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
1637 IN PVOID InsertCodesContext);
1638/*++
1639Routine Description:
1640Parameters:
1641--*/
1642
1643NTSTATUS __stdcall HidP_TranslateUsagesToI8042ScanCodes(
1644 IN PUSAGE ChangedUsageList,
1645 IN ULONG UsageListLength,
1646 IN HIDP_KEYBOARD_DIRECTION KeyAction,
1647 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
1648 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
1649 IN PVOID InsertCodesContext);
1650/*++
1651Routine Description:
1652Parameters:
1653--*/
1654
1655//
1656// Define NT Status codes with Facility Code of FACILITY_HID_ERROR_CODE
1657//
1658
1659// FACILITY_HID_ERROR_CODE defined in ntstatus.h
1660#ifndef FACILITY_HID_ERROR_CODE
1661#define FACILITY_HID_ERROR_CODE 0x11
1662#endif
1663
1664#define HIDP_ERROR_CODES(SEV, CODE) \
1665 ((NTSTATUS)(((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
1666
1667#define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0, 0))
1668#define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8, 1))
1669#define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC, 1))
1670#define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC, 2))
1671#define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC, 3))
1672#define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC, 4))
1673#define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 5))
1674#define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC, 6))
1675#define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC, 7))
1676#define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC, 8))
1677#define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC, 9))
1678#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC, 0xA))
1679#define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xB))
1680#define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xC))
1681#define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC, 0xD))
1682#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 0xE))
1683#define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC, 0xF))
1684#define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC, 0x10))
1685#define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC, 0x20))
1686
1687//
1688// We blundered this status code.
1689//
1690#define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
1691
1692#include <poppack.h>
1693
1694#endif
Definition hidpi.h:53
Definition hidpi.h:230
Definition hidpi.h:254
Definition hidpi.h:289
Definition hidpi.h:1599
Definition hidpi.h:282
Definition hidpi.h:90
Definition hidpi.h:45