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.
27 #pragma GCC system_header
38 #define HIDAPI DECLSPEC_EXPORT
40 #define HIDAPI DECLSPEC_IMPORT
43 typedef PUCHAR PHIDP_REPORT_DESCRIPTOR
;
44 typedef struct _HIDP_PREPARSED_DATA
* PHIDP_PREPARSED_DATA
;
46 typedef struct _HIDP_UNKNOWN_TOKEN
{
50 } HIDP_UNKNOWN_TOKEN
, *PHIDP_UNKNOWN_TOKEN
;
52 typedef enum _HIDP_KEYBOARD_DIRECTION
{
55 } HIDP_KEYBOARD_DIRECTION
;
57 typedef struct _HIDP_KEYBOARD_MODIFIER_STATE
{
58 _ANONYMOUS_UNION
union {
59 _ANONYMOUS_STRUCT
struct {
60 ULONG LeftControl
: 1;
64 ULONG RightControl
: 1;
75 } HIDP_KEYBOARD_MODIFIER_STATE
, *PHIDP_KEYBOARD_MODIFIER_STATE
;
77 typedef BOOLEAN (DDKAPI
*PHIDP_INSERT_SCANCODES
)(
79 IN PCHAR NewScanCodes
,
82 typedef struct _USAGE_AND_PAGE
{
85 } USAGE_AND_PAGE
, *PUSAGE_AND_PAGE
;
87 typedef struct _HIDD_ATTRIBUTES
{
92 } HIDD_ATTRIBUTES
, *PHIDD_ATTRIBUTES
;
94 typedef struct _HIDD_CONFIGURATION
{
98 } HIDD_CONFIGURATION
, *PHIDD_CONFIGURATION
;
103 HidP_TranslateUsageAndPagesToI8042ScanCodes(
104 IN PUSAGE_AND_PAGE ChangedUsageList
,
105 IN ULONG UsageListLength
,
106 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
107 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
108 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
109 IN PVOID InsertCodesContext
);
114 HidP_TranslateUsagesToI8042ScanCodes(
115 IN PUSAGE ChangedUsageList
,
116 IN ULONG UsageListLength
,
117 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
118 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
119 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
120 IN PVOID InsertCodesContext
);
122 typedef struct _HIDP_BUTTON_CAPS
{
127 USHORT LinkCollection
;
131 BOOLEAN IsStringRange
;
132 BOOLEAN IsDesignatorRange
;
135 _ANONYMOUS_UNION
union {
137 USAGE UsageMin
, UsageMax
;
138 USHORT StringMin
, StringMax
;
139 USHORT DesignatorMin
, DesignatorMax
;
140 USHORT DataIndexMin
, DataIndexMax
;
143 USAGE Usage
, Reserved1
;
144 USHORT StringIndex
, Reserved2
;
145 USHORT DesignatorIndex
, Reserved3
;
146 USHORT DataIndex
, Reserved4
;
149 } HIDP_BUTTON_CAPS
, *PHIDP_BUTTON_CAPS
;
151 typedef struct _HIDP_CAPS
{
154 USHORT InputReportByteLength
;
155 USHORT OutputReportByteLength
;
156 USHORT FeatureReportByteLength
;
158 USHORT NumberLinkCollectionNodes
;
159 USHORT NumberInputButtonCaps
;
160 USHORT NumberInputValueCaps
;
161 USHORT NumberInputDataIndices
;
162 USHORT NumberOutputButtonCaps
;
163 USHORT NumberOutputValueCaps
;
164 USHORT NumberOutputDataIndices
;
165 USHORT NumberFeatureButtonCaps
;
166 USHORT NumberFeatureValueCaps
;
167 USHORT NumberFeatureDataIndices
;
168 } HIDP_CAPS
, *PHIDP_CAPS
;
170 typedef struct _HIDP_DATA
{
173 _ANONYMOUS_UNION
union {
177 } HIDP_DATA
, *PHIDP_DATA
;
179 typedef struct _HIDP_EXTENDED_ATTRIBUTES
{
180 UCHAR NumGlobalUnknowns
;
182 PHIDP_UNKNOWN_TOKEN GlobalUnknowns
;
184 } HIDP_EXTENDED_ATTRIBUTES
, *PHIDP_EXTENDED_ATTRIBUTES
;
186 #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
187 #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
189 typedef struct _HIDP_LINK_COLLECTION_NODE
{
193 USHORT NumberOfChildren
;
196 ULONG CollectionType
: 8;
200 } HIDP_LINK_COLLECTION_NODE
, *PHIDP_LINK_COLLECTION_NODE
;
202 typedef struct _HIDP_VALUE_CAPS
{
207 USHORT LinkCollection
;
211 BOOLEAN IsStringRange
;
212 BOOLEAN IsDesignatorRange
;
221 LONG LogicalMin
, LogicalMax
;
222 LONG PhysicalMin
, PhysicalMax
;
223 _ANONYMOUS_UNION
union {
225 USAGE UsageMin
, UsageMax
;
226 USHORT StringMin
, StringMax
;
227 USHORT DesignatorMin
, DesignatorMax
;
228 USHORT DataIndexMin
, DataIndexMax
;
231 USAGE Usage
, Reserved1
;
232 USHORT StringIndex
, Reserved2
;
233 USHORT DesignatorIndex
, Reserved3
;
234 USHORT DataIndex
, Reserved4
;
237 } HIDP_VALUE_CAPS
, *PHIDP_VALUE_CAPS
;
239 typedef enum _HIDP_REPORT_TYPE
{
245 #define FACILITY_HID_ERROR_CODE 0x11
247 #define HIDP_ERROR_CODES(SEV, CODE) \
248 ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
250 #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0, 0))
251 #define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8, 1))
252 #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC, 1))
253 #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC, 2))
254 #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC, 3))
255 #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC, 4))
256 #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 5))
257 #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC, 6))
258 #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC, 7))
259 #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC, 8))
260 #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC, 9))
261 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC, 0xA))
262 #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xB))
263 #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xC))
264 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC, 0xD))
265 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 0xE))
266 #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC, 0xF))
267 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC, 0x10))
268 #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC, 0x20))
269 #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
272 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
275 * HidP_GetButtonCaps(
276 * IN HIDP_REPORT_TYPE ReportType,
277 * OUT PHIDP_BUTTON_CAPS ButtonCaps,
278 * IN OUT PULONG ButtonCapsLength,
279 * IN PHIDP_PREPARSED_DATA PreparsedData);
281 #define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
282 HidP_GetSpecificButtonCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
287 * IN HIDP_REPORT_TYPE ReportType,
288 * IN USAGE UsagePage,
289 * IN USHORT LinkCollection,
290 * OUT USAGE *UsageList,
291 * IN OUT ULONG *UsageLength,
292 * IN PHIDP_PREPARSED_DATA PreparsedData,
294 * IN ULONG ReportLength);
296 #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
297 HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
299 #define HidP_GetButtonListLength(RTy, UPa, Ppd) \
300 HidP_GetUsageListLength(Rty, UPa, Ppd)
306 * IN HIDP_REPORT_TYPE ReportType,
307 * IN USHORT LinkCollection,
308 * OUT PUSAGE_AND_PAGE ButtonList,
309 * IN OUT ULONG *UsageLength,
310 * IN PHIDP_PREPARSED_DATA PreparsedData,
312 * IN ULONG ReportLength);
314 #define HidP_GetButtonsEx(RT, LC, BL, UL, PD, R, RL) \
315 HidP_GetUsagesEx(RT, LC, BL, UL, PD, R, RL)
317 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
323 IN PHIDP_PREPARSED_DATA PreparsedData
,
324 OUT PHIDP_CAPS Capabilities
);
330 IN HIDP_REPORT_TYPE ReportType
,
331 OUT PHIDP_DATA DataList
,
332 IN OUT PULONG DataLength
,
333 IN PHIDP_PREPARSED_DATA PreparsedData
,
335 IN ULONG ReportLength
);
340 HidP_GetExtendedAttributes(
341 IN HIDP_REPORT_TYPE ReportType
,
343 IN PHIDP_PREPARSED_DATA PreparsedData
,
344 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
345 IN OUT PULONG LengthAttributes
);
350 HidP_GetLinkCollectionNodes(
351 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
352 IN OUT PULONG LinkCollectionNodesLength
,
353 IN PHIDP_PREPARSED_DATA PreparsedData
);
358 HidP_GetScaledUsageValue(
359 IN HIDP_REPORT_TYPE ReportType
,
361 IN USHORT LinkCollection OPTIONAL
,
363 OUT PLONG UsageValue
,
364 IN PHIDP_PREPARSED_DATA PreparsedData
,
366 IN ULONG ReportLength
);
371 HidP_GetSpecificButtonCaps(
372 IN HIDP_REPORT_TYPE ReportType
,
374 IN USHORT LinkCollection
,
376 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
377 IN OUT PULONG ButtonCapsLength
,
378 IN PHIDP_PREPARSED_DATA PreparsedData
);
383 HidP_GetSpecificValueCaps(
384 IN HIDP_REPORT_TYPE ReportType
,
386 IN USHORT LinkCollection
,
388 OUT PHIDP_VALUE_CAPS ValueCaps
,
389 IN OUT PULONG ValueCapsLength
,
390 IN PHIDP_PREPARSED_DATA PreparsedData
);
396 IN HIDP_REPORT_TYPE ReportType
,
398 IN USHORT LinkCollection OPTIONAL
,
399 OUT USAGE
*UsageList
,
400 IN OUT ULONG
*UsageLength
,
401 IN PHIDP_PREPARSED_DATA PreparsedData
,
403 IN ULONG ReportLength
);
409 IN HIDP_REPORT_TYPE ReportType
,
410 IN USHORT LinkCollection
,
411 OUT PUSAGE_AND_PAGE ButtonList
,
412 IN OUT ULONG
*UsageLength
,
413 IN PHIDP_PREPARSED_DATA PreparsedData
,
415 IN ULONG ReportLength
);
421 IN HIDP_REPORT_TYPE ReportType
,
423 IN USHORT LinkCollection
,
425 OUT PULONG UsageValue
,
426 IN PHIDP_PREPARSED_DATA PreparsedData
,
428 IN ULONG ReportLength
);
433 HidP_GetUsageValueArray(
434 IN HIDP_REPORT_TYPE ReportType
,
436 IN USHORT LinkCollection OPTIONAL
,
438 OUT PCHAR UsageValue
,
439 IN USHORT UsageValueByteLength
,
440 IN PHIDP_PREPARSED_DATA PreparsedData
,
442 IN ULONG ReportLength
);
444 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
449 * IN HIDP_REPORT_TYPE ReportType,
450 * OUT PHIDP_VALUE_CAPS ValueCaps,
451 * IN OUT PULONG ValueCapsLength,
452 * IN PHIDP_PREPARSED_DATA PreparsedData);
454 #define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
455 HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
457 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
462 HidP_InitializeReportForID(
463 IN HIDP_REPORT_TYPE ReportType
,
465 IN PHIDP_PREPARSED_DATA PreparsedData
,
467 IN ULONG ReportLength
);
469 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
473 * HidP_IsSameUsageAndPage(
475 * USAGE_AND_PAGE u2);
477 #define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
479 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
484 HidP_MaxDataListLength(
485 IN HIDP_REPORT_TYPE ReportType
,
486 IN PHIDP_PREPARSED_DATA PreparsedData
);
491 HidP_MaxUsageListLength(
492 IN HIDP_REPORT_TYPE ReportType
,
493 IN USAGE UsagePage OPTIONAL
,
494 IN PHIDP_PREPARSED_DATA PreparsedData
);
496 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
501 * IN HIDP_REPORT_TYPE ReportType,
502 * IN USAGE UsagePage,
503 * IN USHORT LinkCollection,
504 * IN PUSAGE UsageList,
505 * IN OUT PULONG UsageLength,
506 * IN PHIDP_PREPARSED_DATA PreparsedData,
507 * IN OUT PCHAR Report,
508 * IN ULONG ReportLength);
510 #define HidP_SetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
511 HidP_SetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
513 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
519 IN HIDP_REPORT_TYPE ReportType
,
520 IN PHIDP_DATA DataList
,
521 IN OUT PULONG DataLength
,
522 IN PHIDP_PREPARSED_DATA PreparsedData
,
524 IN ULONG ReportLength
);
529 HidP_SetScaledUsageValue(
530 IN HIDP_REPORT_TYPE ReportType
,
532 IN USHORT LinkCollection OPTIONAL
,
535 IN PHIDP_PREPARSED_DATA PreparsedData
,
537 IN ULONG ReportLength
);
543 IN HIDP_REPORT_TYPE ReportType
,
545 IN USHORT LinkCollection
, /* Optional */
547 IN OUT PULONG UsageLength
,
548 IN PHIDP_PREPARSED_DATA PreparsedData
,
550 IN ULONG ReportLength
);
556 IN HIDP_REPORT_TYPE ReportType
,
558 IN USHORT LinkCollection
,
561 IN PHIDP_PREPARSED_DATA PreparsedData
,
563 IN ULONG ReportLength
);
568 HidP_SetUsageValueArray(
569 IN HIDP_REPORT_TYPE ReportType
,
571 IN USHORT LinkCollection OPTIONAL
,
574 IN USHORT UsageValueByteLength
,
575 IN PHIDP_PREPARSED_DATA PreparsedData
,
577 IN ULONG ReportLength
);
579 #if !defined(_HIDPI_NO_FUNCTION_MACROS_)
584 * IN HIDP_REPORT_TYPE ReportType,
585 * IN USAGE UsagePage,
586 * IN USHORT LinkCollection,
587 * IN PUSAGE UsageList,
588 * IN OUT PULONG UsageLength,
589 * IN PHIDP_PREPARSED_DATA PreparsedData,
590 * IN OUT PCHAR Report,
591 * IN ULONG ReportLength);
593 #define HidP_UnsetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
594 HidP_UnsetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
596 #endif /* _HIDPI_NO_FUNCTION_MACROS_ */
602 IN HIDP_REPORT_TYPE ReportType
,
604 IN USHORT LinkCollection
,
606 IN OUT PULONG UsageLength
,
607 IN PHIDP_PREPARSED_DATA PreparsedData
,
609 IN ULONG ReportLength
);
614 HidP_UsageAndPageListDifference(
615 IN PUSAGE_AND_PAGE PreviousUsageList
,
616 IN PUSAGE_AND_PAGE CurrentUsageList
,
617 OUT PUSAGE_AND_PAGE BreakUsageList
,
618 OUT PUSAGE_AND_PAGE MakeUsageList
,
619 IN ULONG UsageListLength
);
624 HidP_UsageListDifference(
625 IN PUSAGE PreviousUsageList
,
626 IN PUSAGE CurrentUsageList
,
627 OUT PUSAGE BreakUsageList
,
628 OUT PUSAGE MakeUsageList
,
629 IN ULONG UsageListLength
);
635 #endif /* __HIDPI_H */