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
40 #define HIDAPI DECLSPEC_EXPORT
42 #define HIDAPI DECLSPEC_IMPORT
45 typedef PUCHAR PHIDP_REPORT_DESCRIPTOR
;
46 typedef struct _HIDP_PREPARSED_DATA
* PHIDP_PREPARSED_DATA
;
48 typedef struct _HIDP_UNKNOWN_TOKEN
{
52 } HIDP_UNKNOWN_TOKEN
, *PHIDP_UNKNOWN_TOKEN
;
54 typedef enum _HIDP_KEYBOARD_DIRECTION
{
57 } HIDP_KEYBOARD_DIRECTION
;
59 typedef struct _HIDP_KEYBOARD_MODIFIER_STATE
{
60 _ANONYMOUS_UNION
union {
61 _ANONYMOUS_STRUCT
struct {
62 ULONG LeftControl
: 1;
66 ULONG RightControl
: 1;
77 } HIDP_KEYBOARD_MODIFIER_STATE
, *PHIDP_KEYBOARD_MODIFIER_STATE
;
79 typedef BOOLEAN (DDKAPI
*PHIDP_INSERT_SCANCODES
)(
81 IN PCHAR NewScanCodes
,
84 typedef struct _USAGE_AND_PAGE
{
87 } USAGE_AND_PAGE
, *PUSAGE_AND_PAGE
;
92 HidP_TranslateUsageAndPagesToI8042ScanCodes(
93 IN PUSAGE_AND_PAGE ChangedUsageList
,
94 IN ULONG UsageListLength
,
95 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
96 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
97 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
98 IN PVOID InsertCodesContext
);
103 HidP_TranslateUsagesToI8042ScanCodes(
104 IN PUSAGE 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
);
111 typedef struct _HIDP_BUTTON_CAPS
{
116 USHORT LinkCollection
;
120 BOOLEAN IsStringRange
;
121 BOOLEAN IsDesignatorRange
;
124 _ANONYMOUS_UNION
union {
126 USAGE UsageMin
, UsageMax
;
127 USHORT StringMin
, StringMax
;
128 USHORT DesignatorMin
, DesignatorMax
;
129 USHORT DataIndexMin
, DataIndexMax
;
132 USAGE Usage
, Reserved1
;
133 USHORT StringIndex
, Reserved2
;
134 USHORT DesignatorIndex
, Reserved3
;
135 USHORT DataIndex
, Reserved4
;
138 } HIDP_BUTTON_CAPS
, *PHIDP_BUTTON_CAPS
;
140 typedef struct _HIDP_CAPS
{
143 USHORT InputReportByteLength
;
144 USHORT OutputReportByteLength
;
145 USHORT FeatureReportByteLength
;
147 USHORT NumberLinkCollectionNodes
;
148 USHORT NumberInputButtonCaps
;
149 USHORT NumberInputValueCaps
;
150 USHORT NumberInputDataIndices
;
151 USHORT NumberOutputButtonCaps
;
152 USHORT NumberOutputValueCaps
;
153 USHORT NumberOutputDataIndices
;
154 USHORT NumberFeatureButtonCaps
;
155 USHORT NumberFeatureValueCaps
;
156 USHORT NumberFeatureDataIndices
;
157 } HIDP_CAPS
, *PHIDP_CAPS
;
159 typedef struct _HIDP_DATA
{
162 _ANONYMOUS_UNION
union {
166 } HIDP_DATA
, *PHIDP_DATA
;
168 typedef struct _HIDP_EXTENDED_ATTRIBUTES
{
169 UCHAR NumGlobalUnknowns
;
171 PHIDP_UNKNOWN_TOKEN GlobalUnknowns
;
173 } HIDP_EXTENDED_ATTRIBUTES
, *PHIDP_EXTENDED_ATTRIBUTES
;
175 #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
176 #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
178 typedef struct _HIDP_LINK_COLLECTION_NODE
{
182 USHORT NumberOfChildren
;
185 ULONG CollectionType
: 8;
189 } HIDP_LINK_COLLECTION_NODE
, *PHIDP_LINK_COLLECTION_NODE
;
191 typedef struct _HIDP_VALUE_CAPS
{
196 USHORT LinkCollection
;
200 BOOLEAN IsStringRange
;
201 BOOLEAN IsDesignatorRange
;
210 LONG LogicalMin
, LogicalMax
;
211 LONG PhysicalMin
, PhysicalMax
;
212 _ANONYMOUS_UNION
union {
214 USAGE UsageMin
, UsageMax
;
215 USHORT StringMin
, StringMax
;
216 USHORT DesignatorMin
, DesignatorMax
;
217 USHORT DataIndexMin
, DataIndexMax
;
220 USAGE Usage
, Reserved1
;
221 USHORT StringIndex
, Reserved2
;
222 USHORT DesignatorIndex
, Reserved3
;
223 USHORT DataIndex
, Reserved4
;
226 } HIDP_VALUE_CAPS
, *PHIDP_VALUE_CAPS
;
228 typedef enum _HIDP_REPORT_TYPE
{
234 #define FACILITY_HID_ERROR_CODE 0x11
236 #define HIDP_ERROR_CODES(SEV, CODE) \
237 ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
239 #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0, 0))
240 #define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8, 1))
241 #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC, 1))
242 #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC, 2))
243 #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC, 3))
244 #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC, 4))
245 #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 5))
246 #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC, 6))
247 #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC, 7))
248 #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC, 8))
249 #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC, 9))
250 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC, 0xA))
251 #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xB))
252 #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xC))
253 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC, 0xD))
254 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 0xE))
255 #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC, 0xF))
256 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC, 0x10))
257 #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC, 0x20))
258 #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
264 * HidP_GetButtonCaps(
265 * IN HIDP_REPORT_TYPE ReportType,
266 * OUT PHIDP_BUTTON_CAPS ButtonCaps,
267 * IN OUT PULONG ButtonCapsLength,
268 * IN PHIDP_PREPARSED_DATA PreparsedData);
270 #define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
271 HidP_GetSpecificButtonCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
276 * IN HIDP_REPORT_TYPE ReportType,
277 * IN USAGE UsagePage,
278 * IN USHORT LinkCollection,
279 * OUT USAGE *UsageList,
280 * IN OUT ULONG *UsageLength,
281 * IN PHIDP_PREPARSED_DATA PreparsedData,
283 * IN ULONG ReportLength);
285 #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
286 HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
288 #define HidP_GetButtonListLength(RTy, UPa, Ppd) \
289 HidP_GetUsageListLength(Rty, UPa, Ppd)
295 * IN HIDP_REPORT_TYPE ReportType,
296 * IN USHORT LinkCollection,
297 * OUT PUSAGE_AND_PAGE ButtonList,
298 * IN OUT ULONG *UsageLength,
299 * IN PHIDP_PREPARSED_DATA PreparsedData,
301 * IN ULONG ReportLength);
303 #define HidP_GetButtonsEx(RT, LC, BL, UL, PD, R, RL) \
304 HidP_GetUsagesEx(RT, LC, BL, UL, PD, R, RL)
310 IN PHIDP_PREPARSED_DATA PreparsedData
,
311 OUT PHIDP_CAPS Capabilities
);
317 IN HIDP_REPORT_TYPE ReportType
,
318 OUT PHIDP_DATA DataList
,
319 IN OUT PULONG DataLength
,
320 IN PHIDP_PREPARSED_DATA PreparsedData
,
322 IN ULONG ReportLength
);
327 HidP_GetExtendedAttributes(
328 IN HIDP_REPORT_TYPE ReportType
,
330 IN PHIDP_PREPARSED_DATA PreparsedData
,
331 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
332 IN OUT PULONG LengthAttributes
);
337 HidP_GetLinkCollectionNodes(
338 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
339 IN OUT PULONG LinkCollectionNodesLength
,
340 IN PHIDP_PREPARSED_DATA PreparsedData
);
345 HidP_GetScaledUsageValue(
346 IN HIDP_REPORT_TYPE ReportType
,
348 IN USHORT LinkCollection OPTIONAL
,
350 OUT PLONG UsageValue
,
351 IN PHIDP_PREPARSED_DATA PreparsedData
,
353 IN ULONG ReportLength
);
358 HidP_GetSpecificButtonCaps(
359 IN HIDP_REPORT_TYPE ReportType
,
361 IN USHORT LinkCollection
,
363 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
364 IN OUT PULONG ButtonCapsLength
,
365 IN PHIDP_PREPARSED_DATA PreparsedData
);
370 HidP_GetSpecificValueCaps(
371 IN HIDP_REPORT_TYPE ReportType
,
373 IN USHORT LinkCollection
,
375 OUT PHIDP_VALUE_CAPS ValueCaps
,
376 IN OUT PULONG ValueCapsLength
,
377 IN PHIDP_PREPARSED_DATA PreparsedData
);
383 IN HIDP_REPORT_TYPE ReportType
,
385 IN USHORT LinkCollection OPTIONAL
,
386 OUT USAGE
*UsageList
,
387 IN OUT ULONG
*UsageLength
,
388 IN PHIDP_PREPARSED_DATA PreparsedData
,
390 IN ULONG ReportLength
);
396 IN HIDP_REPORT_TYPE ReportType
,
397 IN USHORT LinkCollection
,
398 OUT PUSAGE_AND_PAGE ButtonList
,
399 IN OUT ULONG
*UsageLength
,
400 IN PHIDP_PREPARSED_DATA PreparsedData
,
402 IN ULONG ReportLength
);
408 IN HIDP_REPORT_TYPE ReportType
,
410 IN USHORT LinkCollection
,
412 OUT PULONG UsageValue
,
413 IN PHIDP_PREPARSED_DATA PreparsedData
,
415 IN ULONG ReportLength
);
420 HidP_GetUsageValueArray(
421 IN HIDP_REPORT_TYPE ReportType
,
423 IN USHORT LinkCollection OPTIONAL
,
425 OUT PCHAR UsageValue
,
426 IN USHORT UsageValueByteLength
,
427 IN PHIDP_PREPARSED_DATA PreparsedData
,
429 IN ULONG ReportLength
);
434 * IN HIDP_REPORT_TYPE ReportType,
435 * OUT PHIDP_VALUE_CAPS ValueCaps,
436 * IN OUT PULONG ValueCapsLength,
437 * IN PHIDP_PREPARSED_DATA PreparsedData);
439 #define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
440 HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
445 HidP_InitializeReportForID(
446 IN HIDP_REPORT_TYPE ReportType
,
448 IN PHIDP_PREPARSED_DATA PreparsedData
,
450 IN ULONG ReportLength
);
454 * HidP_IsSameUsageAndPage(
456 * USAGE_AND_PAGE u2);
458 #define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
463 HidP_MaxDataListLength(
464 IN HIDP_REPORT_TYPE ReportType
,
465 IN PHIDP_PREPARSED_DATA PreparsedData
);
470 HidP_MaxUsageListLength(
471 IN HIDP_REPORT_TYPE ReportType
,
472 IN USAGE UsagePage OPTIONAL
,
473 IN PHIDP_PREPARSED_DATA PreparsedData
);
478 * IN HIDP_REPORT_TYPE ReportType,
479 * IN USAGE UsagePage,
480 * IN USHORT LinkCollection,
481 * IN PUSAGE UsageList,
482 * IN OUT PULONG UsageLength,
483 * IN PHIDP_PREPARSED_DATA PreparsedData,
484 * IN OUT PCHAR Report,
485 * IN ULONG ReportLength);
487 #define HidP_SetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
488 HidP_SetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
494 IN HIDP_REPORT_TYPE ReportType
,
495 IN PHIDP_DATA DataList
,
496 IN OUT PULONG DataLength
,
497 IN PHIDP_PREPARSED_DATA PreparsedData
,
499 IN ULONG ReportLength
);
504 HidP_SetScaledUsageValue(
505 IN HIDP_REPORT_TYPE ReportType
,
507 IN USHORT LinkCollection OPTIONAL
,
510 IN PHIDP_PREPARSED_DATA PreparsedData
,
512 IN ULONG ReportLength
);
518 IN HIDP_REPORT_TYPE ReportType
,
520 IN USHORT LinkCollection
, /* Optional */
522 IN OUT PULONG UsageLength
,
523 IN PHIDP_PREPARSED_DATA PreparsedData
,
525 IN ULONG ReportLength
);
531 IN HIDP_REPORT_TYPE ReportType
,
533 IN USHORT LinkCollection
,
536 IN PHIDP_PREPARSED_DATA PreparsedData
,
538 IN ULONG ReportLength
);
543 HidP_SetUsageValueArray(
544 IN HIDP_REPORT_TYPE ReportType
,
546 IN USHORT LinkCollection OPTIONAL
,
549 IN USHORT UsageValueByteLength
,
550 IN PHIDP_PREPARSED_DATA PreparsedData
,
552 IN ULONG ReportLength
);
557 * IN HIDP_REPORT_TYPE ReportType,
558 * IN USAGE UsagePage,
559 * IN USHORT LinkCollection,
560 * IN PUSAGE UsageList,
561 * IN OUT PULONG UsageLength,
562 * IN PHIDP_PREPARSED_DATA PreparsedData,
563 * IN OUT PCHAR Report,
564 * IN ULONG ReportLength);
566 #define HidP_UnsetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
567 HidP_UnsetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
573 IN HIDP_REPORT_TYPE ReportType
,
575 IN USHORT LinkCollection
,
577 IN OUT PULONG UsageLength
,
578 IN PHIDP_PREPARSED_DATA PreparsedData
,
580 IN ULONG ReportLength
);
585 HidP_UsageAndPageListDifference(
586 IN PUSAGE_AND_PAGE PreviousUsageList
,
587 IN PUSAGE_AND_PAGE CurrentUsageList
,
588 OUT PUSAGE_AND_PAGE BreakUsageList
,
589 OUT PUSAGE_AND_PAGE MakeUsageList
,
590 IN ULONG UsageListLength
);
595 HidP_UsageListDifference(
596 IN PUSAGE PreviousUsageList
,
597 IN PUSAGE CurrentUsageList
,
598 OUT PUSAGE BreakUsageList
,
599 OUT PUSAGE MakeUsageList
,
600 IN ULONG UsageListLength
);
608 #endif /* __HIDPI_H */