4 * Public Interface for HID parsing library.
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35 #define HIDAPI DECLSPEC_IMPORT
38 typedef PUCHAR PHIDP_REPORT_DESCRIPTOR
;
39 typedef struct _HIDP_PREPARSED_DATA
* PHIDP_PREPARSED_DATA
;
41 typedef struct _HIDP_UNKNOWN_TOKEN
{
45 } HIDP_UNKNOWN_TOKEN
, *PHIDP_UNKNOWN_TOKEN
;
47 typedef enum _HIDP_KEYBOARD_DIRECTION
{
50 } HIDP_KEYBOARD_DIRECTION
;
52 typedef struct _HIDP_KEYBOARD_MODIFIER_STATE
{
53 _ANONYMOUS_UNION
union {
54 _ANONYMOUS_STRUCT
struct {
55 ULONG LeftControl
: 1;
59 ULONG RightControl
: 1;
70 } HIDP_KEYBOARD_MODIFIER_STATE
, *PHIDP_KEYBOARD_MODIFIER_STATE
;
72 typedef BOOLEAN (NTAPI
*PHIDP_INSERT_SCANCODES
)(
74 IN PCHAR NewScanCodes
,
77 typedef struct _USAGE_AND_PAGE
{
80 } USAGE_AND_PAGE
, *PUSAGE_AND_PAGE
;
82 typedef struct _HIDD_ATTRIBUTES
{
87 } HIDD_ATTRIBUTES
, *PHIDD_ATTRIBUTES
;
89 typedef struct _HIDD_CONFIGURATION
{
93 } HIDD_CONFIGURATION
, *PHIDD_CONFIGURATION
;
98 HidP_TranslateUsageAndPagesToI8042ScanCodes(
99 IN PUSAGE_AND_PAGE ChangedUsageList
,
100 IN ULONG UsageListLength
,
101 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
102 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
103 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
104 IN PVOID InsertCodesContext
);
109 HidP_TranslateUsagesToI8042ScanCodes(
110 IN PUSAGE ChangedUsageList
,
111 IN ULONG UsageListLength
,
112 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
113 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
114 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
115 IN PVOID InsertCodesContext
);
117 typedef struct _HIDP_BUTTON_CAPS
{
122 USHORT LinkCollection
;
126 BOOLEAN IsStringRange
;
127 BOOLEAN IsDesignatorRange
;
130 _ANONYMOUS_UNION
union {
132 USAGE UsageMin
, UsageMax
;
133 USHORT StringMin
, StringMax
;
134 USHORT DesignatorMin
, DesignatorMax
;
135 USHORT DataIndexMin
, DataIndexMax
;
138 USAGE Usage
, Reserved1
;
139 USHORT StringIndex
, Reserved2
;
140 USHORT DesignatorIndex
, Reserved3
;
141 USHORT DataIndex
, Reserved4
;
144 } HIDP_BUTTON_CAPS
, *PHIDP_BUTTON_CAPS
;
146 typedef struct _HIDP_CAPS
{
149 USHORT InputReportByteLength
;
150 USHORT OutputReportByteLength
;
151 USHORT FeatureReportByteLength
;
153 USHORT NumberLinkCollectionNodes
;
154 USHORT NumberInputButtonCaps
;
155 USHORT NumberInputValueCaps
;
156 USHORT NumberInputDataIndices
;
157 USHORT NumberOutputButtonCaps
;
158 USHORT NumberOutputValueCaps
;
159 USHORT NumberOutputDataIndices
;
160 USHORT NumberFeatureButtonCaps
;
161 USHORT NumberFeatureValueCaps
;
162 USHORT NumberFeatureDataIndices
;
163 } HIDP_CAPS
, *PHIDP_CAPS
;
165 typedef struct _HIDP_DATA
{
168 _ANONYMOUS_UNION
union {
172 } HIDP_DATA
, *PHIDP_DATA
;
174 typedef struct _HIDP_EXTENDED_ATTRIBUTES
{
175 UCHAR NumGlobalUnknowns
;
177 PHIDP_UNKNOWN_TOKEN GlobalUnknowns
;
179 } HIDP_EXTENDED_ATTRIBUTES
, *PHIDP_EXTENDED_ATTRIBUTES
;
181 #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
182 #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
184 typedef struct _HIDP_LINK_COLLECTION_NODE
{
188 USHORT NumberOfChildren
;
191 ULONG CollectionType
: 8;
195 } HIDP_LINK_COLLECTION_NODE
, *PHIDP_LINK_COLLECTION_NODE
;
197 typedef struct _HIDP_VALUE_CAPS
{
202 USHORT LinkCollection
;
206 BOOLEAN IsStringRange
;
207 BOOLEAN IsDesignatorRange
;
216 LONG LogicalMin
, LogicalMax
;
217 LONG PhysicalMin
, PhysicalMax
;
218 _ANONYMOUS_UNION
union {
220 USAGE UsageMin
, UsageMax
;
221 USHORT StringMin
, StringMax
;
222 USHORT DesignatorMin
, DesignatorMax
;
223 USHORT DataIndexMin
, DataIndexMax
;
226 USAGE Usage
, Reserved1
;
227 USHORT StringIndex
, Reserved2
;
228 USHORT DesignatorIndex
, Reserved3
;
229 USHORT DataIndex
, Reserved4
;
232 } HIDP_VALUE_CAPS
, *PHIDP_VALUE_CAPS
;
234 typedef enum _HIDP_REPORT_TYPE
{
240 #define FACILITY_HID_ERROR_CODE 0x11
242 #define HIDP_ERROR_CODES(SEV, CODE) \
243 ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
245 #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0, 0))
246 #define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8, 1))
247 #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC, 1))
248 #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC, 2))
249 #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC, 3))
250 #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC, 4))
251 #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 5))
252 #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC, 6))
253 #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC, 7))
254 #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC, 8))
255 #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC, 9))
256 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC, 0xA))
257 #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xB))
258 #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xC))
259 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC, 0xD))
260 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 0xE))
261 #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC, 0xF))
262 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC, 0x10))
263 #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC, 0x20))
264 #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
267 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
270 * HidP_GetButtonCaps(
271 * IN HIDP_REPORT_TYPE ReportType,
272 * OUT PHIDP_BUTTON_CAPS ButtonCaps,
273 * IN OUT PULONG ButtonCapsLength,
274 * IN PHIDP_PREPARSED_DATA PreparsedData);
276 #define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
277 HidP_GetSpecificButtonCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
282 * IN HIDP_REPORT_TYPE ReportType,
283 * IN USAGE UsagePage,
284 * IN USHORT LinkCollection,
285 * OUT USAGE *UsageList,
286 * IN OUT ULONG *UsageLength,
287 * IN PHIDP_PREPARSED_DATA PreparsedData,
289 * IN ULONG ReportLength);
291 #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
292 HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
294 #define HidP_GetButtonListLength(RTy, UPa, Ppd) \
295 HidP_GetUsageListLength(Rty, UPa, Ppd)
301 * IN HIDP_REPORT_TYPE ReportType,
302 * IN USHORT LinkCollection,
303 * OUT PUSAGE_AND_PAGE ButtonList,
304 * IN OUT ULONG *UsageLength,
305 * IN PHIDP_PREPARSED_DATA PreparsedData,
307 * IN ULONG ReportLength);
309 #define HidP_GetButtonsEx(RT, LC, BL, UL, PD, R, RL) \
310 HidP_GetUsagesEx(RT, LC, BL, UL, PD, R, RL)
312 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
318 IN PHIDP_PREPARSED_DATA PreparsedData
,
319 OUT PHIDP_CAPS Capabilities
);
325 IN HIDP_REPORT_TYPE ReportType
,
326 OUT PHIDP_DATA DataList
,
327 IN OUT PULONG DataLength
,
328 IN PHIDP_PREPARSED_DATA PreparsedData
,
330 IN ULONG ReportLength
);
335 HidP_GetExtendedAttributes(
336 IN HIDP_REPORT_TYPE ReportType
,
338 IN PHIDP_PREPARSED_DATA PreparsedData
,
339 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
340 IN OUT PULONG LengthAttributes
);
345 HidP_GetLinkCollectionNodes(
346 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
347 IN OUT PULONG LinkCollectionNodesLength
,
348 IN PHIDP_PREPARSED_DATA PreparsedData
);
353 HidP_GetScaledUsageValue(
354 IN HIDP_REPORT_TYPE ReportType
,
356 IN USHORT LinkCollection OPTIONAL
,
358 OUT PLONG UsageValue
,
359 IN PHIDP_PREPARSED_DATA PreparsedData
,
361 IN ULONG ReportLength
);
366 HidP_GetSpecificButtonCaps(
367 IN HIDP_REPORT_TYPE ReportType
,
369 IN USHORT LinkCollection
,
371 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
372 IN OUT PULONG ButtonCapsLength
,
373 IN PHIDP_PREPARSED_DATA PreparsedData
);
378 HidP_GetSpecificValueCaps(
379 IN HIDP_REPORT_TYPE ReportType
,
381 IN USHORT LinkCollection
,
383 OUT PHIDP_VALUE_CAPS ValueCaps
,
384 IN OUT PULONG ValueCapsLength
,
385 IN PHIDP_PREPARSED_DATA PreparsedData
);
391 IN HIDP_REPORT_TYPE ReportType
,
393 IN USHORT LinkCollection OPTIONAL
,
394 OUT USAGE
*UsageList
,
395 IN OUT ULONG
*UsageLength
,
396 IN PHIDP_PREPARSED_DATA PreparsedData
,
398 IN ULONG ReportLength
);
404 IN HIDP_REPORT_TYPE ReportType
,
405 IN USHORT LinkCollection
,
406 OUT PUSAGE_AND_PAGE ButtonList
,
407 IN OUT ULONG
*UsageLength
,
408 IN PHIDP_PREPARSED_DATA PreparsedData
,
410 IN ULONG ReportLength
);
416 IN HIDP_REPORT_TYPE ReportType
,
418 IN USHORT LinkCollection
,
420 OUT PULONG UsageValue
,
421 IN PHIDP_PREPARSED_DATA PreparsedData
,
423 IN ULONG ReportLength
);
428 HidP_GetUsageValueArray(
429 IN HIDP_REPORT_TYPE ReportType
,
431 IN USHORT LinkCollection OPTIONAL
,
433 OUT PCHAR UsageValue
,
434 IN USHORT UsageValueByteLength
,
435 IN PHIDP_PREPARSED_DATA PreparsedData
,
437 IN ULONG ReportLength
);
439 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
444 * IN HIDP_REPORT_TYPE ReportType,
445 * OUT PHIDP_VALUE_CAPS ValueCaps,
446 * IN OUT PULONG ValueCapsLength,
447 * IN PHIDP_PREPARSED_DATA PreparsedData);
449 #define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
450 HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
452 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
457 HidP_InitializeReportForID(
458 IN HIDP_REPORT_TYPE ReportType
,
460 IN PHIDP_PREPARSED_DATA PreparsedData
,
462 IN ULONG ReportLength
);
464 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
468 * HidP_IsSameUsageAndPage(
470 * USAGE_AND_PAGE u2);
472 #define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
474 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
479 HidP_MaxDataListLength(
480 IN HIDP_REPORT_TYPE ReportType
,
481 IN PHIDP_PREPARSED_DATA PreparsedData
);
486 HidP_MaxUsageListLength(
487 IN HIDP_REPORT_TYPE ReportType
,
488 IN USAGE UsagePage OPTIONAL
,
489 IN PHIDP_PREPARSED_DATA PreparsedData
);
491 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
496 * IN HIDP_REPORT_TYPE ReportType,
497 * IN USAGE UsagePage,
498 * IN USHORT LinkCollection,
499 * IN PUSAGE UsageList,
500 * IN OUT PULONG UsageLength,
501 * IN PHIDP_PREPARSED_DATA PreparsedData,
502 * IN OUT PCHAR Report,
503 * IN ULONG ReportLength);
505 #define HidP_SetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
506 HidP_SetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
508 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
514 IN HIDP_REPORT_TYPE ReportType
,
515 IN PHIDP_DATA DataList
,
516 IN OUT PULONG DataLength
,
517 IN PHIDP_PREPARSED_DATA PreparsedData
,
519 IN ULONG ReportLength
);
524 HidP_SetScaledUsageValue(
525 IN HIDP_REPORT_TYPE ReportType
,
527 IN USHORT LinkCollection OPTIONAL
,
530 IN PHIDP_PREPARSED_DATA PreparsedData
,
532 IN ULONG ReportLength
);
538 IN HIDP_REPORT_TYPE ReportType
,
540 IN USHORT LinkCollection
, /* Optional */
542 IN OUT PULONG UsageLength
,
543 IN PHIDP_PREPARSED_DATA PreparsedData
,
545 IN ULONG ReportLength
);
551 IN HIDP_REPORT_TYPE ReportType
,
553 IN USHORT LinkCollection
,
556 IN PHIDP_PREPARSED_DATA PreparsedData
,
558 IN ULONG ReportLength
);
563 HidP_SetUsageValueArray(
564 IN HIDP_REPORT_TYPE ReportType
,
566 IN USHORT LinkCollection OPTIONAL
,
569 IN USHORT UsageValueByteLength
,
570 IN PHIDP_PREPARSED_DATA PreparsedData
,
572 IN ULONG ReportLength
);
574 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
579 * IN HIDP_REPORT_TYPE ReportType,
580 * IN USAGE UsagePage,
581 * IN USHORT LinkCollection,
582 * IN PUSAGE UsageList,
583 * IN OUT PULONG UsageLength,
584 * IN PHIDP_PREPARSED_DATA PreparsedData,
585 * IN OUT PCHAR Report,
586 * IN ULONG ReportLength);
588 #define HidP_UnsetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
589 HidP_UnsetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
591 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
597 IN HIDP_REPORT_TYPE ReportType
,
599 IN USHORT LinkCollection
,
601 IN OUT PULONG UsageLength
,
602 IN PHIDP_PREPARSED_DATA PreparsedData
,
604 IN ULONG ReportLength
);
609 HidP_UsageAndPageListDifference(
610 IN PUSAGE_AND_PAGE PreviousUsageList
,
611 IN PUSAGE_AND_PAGE CurrentUsageList
,
612 OUT PUSAGE_AND_PAGE BreakUsageList
,
613 OUT PUSAGE_AND_PAGE MakeUsageList
,
614 IN ULONG UsageListLength
);
619 HidP_UsageListDifference(
620 IN PUSAGE PreviousUsageList
,
621 IN PUSAGE CurrentUsageList
,
622 OUT PUSAGE BreakUsageList
,
623 OUT PUSAGE MakeUsageList
,
624 IN ULONG UsageListLength
);
630 #endif /* __HIDPI_H */