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
;
90 HidP_TranslateUsageAndPagesToI8042ScanCodes(
91 /*IN*/ PUSAGE_AND_PAGE ChangedUsageList
,
92 /*IN*/ ULONG UsageListLength
,
93 /*IN*/ HIDP_KEYBOARD_DIRECTION KeyAction
,
94 /*IN OUT*/ PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
95 /*IN*/ PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
96 /*IN*/ PVOID InsertCodesContext
);
101 HidP_TranslateUsagesToI8042ScanCodes(
102 /*IN*/ PUSAGE ChangedUsageList
,
103 /*IN*/ ULONG UsageListLength
,
104 /*IN*/ HIDP_KEYBOARD_DIRECTION KeyAction
,
105 /*IN OUT*/ PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
106 /*IN*/ PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
107 /*IN*/ PVOID InsertCodesContext
);
109 typedef struct _HIDP_BUTTON_CAPS
{
114 USHORT LinkCollection
;
118 BOOLEAN IsStringRange
;
119 BOOLEAN IsDesignatorRange
;
122 _ANONYMOUS_UNION
union {
124 USAGE UsageMin
, UsageMax
;
125 USHORT StringMin
, StringMax
;
126 USHORT DesignatorMin
, DesignatorMax
;
127 USHORT DataIndexMin
, DataIndexMax
;
130 USAGE Usage
, Reserved1
;
131 USHORT StringIndex
, Reserved2
;
132 USHORT DesignatorIndex
, Reserved3
;
133 USHORT DataIndex
, Reserved4
;
136 } HIDP_BUTTON_CAPS
, *PHIDP_BUTTON_CAPS
;
138 typedef struct _HIDP_CAPS
{
141 USHORT InputReportByteLength
;
142 USHORT OutputReportByteLength
;
143 USHORT FeatureReportByteLength
;
145 USHORT NumberLinkCollectionNodes
;
146 USHORT NumberInputButtonCaps
;
147 USHORT NumberInputValueCaps
;
148 USHORT NumberInputDataIndices
;
149 USHORT NumberOutputButtonCaps
;
150 USHORT NumberOutputValueCaps
;
151 USHORT NumberOutputDataIndices
;
152 USHORT NumberFeatureButtonCaps
;
153 USHORT NumberFeatureValueCaps
;
154 USHORT NumberFeatureDataIndices
;
155 } HIDP_CAPS
, *PHIDP_CAPS
;
157 typedef struct _HIDP_DATA
{
160 _ANONYMOUS_UNION
union {
164 } HIDP_DATA
, *PHIDP_DATA
;
166 typedef struct _HIDP_EXTENDED_ATTRIBUTES
{
167 UCHAR NumGlobalUnknowns
;
169 PHIDP_UNKNOWN_TOKEN GlobalUnknowns
;
171 } HIDP_EXTENDED_ATTRIBUTES
, *PHIDP_EXTENDED_ATTRIBUTES
;
173 #define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)
174 #define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)
176 typedef struct _HIDP_LINK_COLLECTION_NODE
{
180 USHORT NumberOfChildren
;
183 ULONG CollectionType
: 8;
187 } HIDP_LINK_COLLECTION_NODE
, *PHIDP_LINK_COLLECTION_NODE
;
189 typedef struct _HIDP_VALUE_CAPS
{
194 USHORT LinkCollection
;
198 BOOLEAN IsStringRange
;
199 BOOLEAN IsDesignatorRange
;
208 LONG LogicalMin
, LogicalMax
;
209 LONG PhysicalMin
, PhysicalMax
;
210 _ANONYMOUS_UNION
union {
212 USAGE UsageMin
, UsageMax
;
213 USHORT StringMin
, StringMax
;
214 USHORT DesignatorMin
, DesignatorMax
;
215 USHORT DataIndexMin
, DataIndexMax
;
218 USAGE Usage
, Reserved1
;
219 USHORT StringIndex
, Reserved2
;
220 USHORT DesignatorIndex
, Reserved3
;
221 USHORT DataIndex
, Reserved4
;
224 } HIDP_VALUE_CAPS
, *PHIDP_VALUE_CAPS
;
226 typedef enum _HIDP_REPORT_TYPE
{
232 #define FACILITY_HID_ERROR_CODE 0x11
234 #define HIDP_ERROR_CODES(SEV, CODE) \
235 ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))
237 #define HIDP_STATUS_SUCCESS (HIDP_ERROR_CODES(0x0, 0))
238 #define HIDP_STATUS_NULL (HIDP_ERROR_CODES(0x8, 1))
239 #define HIDP_STATUS_INVALID_PREPARSED_DATA (HIDP_ERROR_CODES(0xC, 1))
240 #define HIDP_STATUS_INVALID_REPORT_TYPE (HIDP_ERROR_CODES(0xC, 2))
241 #define HIDP_STATUS_INVALID_REPORT_LENGTH (HIDP_ERROR_CODES(0xC, 3))
242 #define HIDP_STATUS_USAGE_NOT_FOUND (HIDP_ERROR_CODES(0xC, 4))
243 #define HIDP_STATUS_VALUE_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 5))
244 #define HIDP_STATUS_BAD_LOG_PHY_VALUES (HIDP_ERROR_CODES(0xC, 6))
245 #define HIDP_STATUS_BUFFER_TOO_SMALL (HIDP_ERROR_CODES(0xC, 7))
246 #define HIDP_STATUS_INTERNAL_ERROR (HIDP_ERROR_CODES(0xC, 8))
247 #define HIDP_STATUS_I8042_TRANS_UNKNOWN (HIDP_ERROR_CODES(0xC, 9))
248 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID (HIDP_ERROR_CODES(0xC, 0xA))
249 #define HIDP_STATUS_NOT_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xB))
250 #define HIDP_STATUS_IS_VALUE_ARRAY (HIDP_ERROR_CODES(0xC, 0xC))
251 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND (HIDP_ERROR_CODES(0xC, 0xD))
252 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE (HIDP_ERROR_CODES(0xC, 0xE))
253 #define HIDP_STATUS_BUTTON_NOT_PRESSED (HIDP_ERROR_CODES(0xC, 0xF))
254 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST (HIDP_ERROR_CODES(0xC, 0x10))
255 #define HIDP_STATUS_NOT_IMPLEMENTED (HIDP_ERROR_CODES(0xC, 0x20))
256 #define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN
262 * HidP_GetButtonCaps(
263 * IN HIDP_REPORT_TYPE ReportType,
264 * OUT PHIDP_BUTTON_CAPS ButtonCaps,
265 * IN OUT PULONG ButtonCapsLength,
266 * IN PHIDP_PREPARSED_DATA PreparsedData);
268 #define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \
269 HidP_GetSpecificButtonCaps(_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
274 * IN HIDP_REPORT_TYPE ReportType,
275 * IN USAGE UsagePage,
276 * IN USHORT LinkCollection,
277 * OUT USAGE *UsageList,
278 * IN OUT ULONG *UsageLength,
279 * IN PHIDP_PREPARSED_DATA PreparsedData,
281 * IN ULONG ReportLength);
283 #define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \
284 HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)
286 #define HidP_GetButtonListLength(RTy, UPa, Ppd) \
287 HidP_GetUsageListLength(Rty, UPa, Ppd)
293 * IN HIDP_REPORT_TYPE ReportType,
294 * IN USHORT LinkCollection,
295 * OUT PUSAGE_AND_PAGE ButtonList,
296 * IN OUT ULONG *UsageLength,
297 * IN PHIDP_PREPARSED_DATA PreparsedData,
299 * IN ULONG ReportLength);
301 #define HidP_GetButtonsEx(RT, LC, BL, UL, PD, R, RL) \
302 HidP_GetUsagesEx(RT, LC, BL, UL, PD, R, RL)
308 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
309 /*OUT*/ PHIDP_CAPS Capabilities
);
315 /*IN*/ HIDP_REPORT_TYPE ReportType
,
316 /*OUT*/ PHIDP_DATA DataList
,
317 /*IN OUT*/ PULONG DataLength
,
318 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
320 /*IN*/ ULONG ReportLength
);
325 HidP_GetExtendedAttributes(
326 /*IN*/ HIDP_REPORT_TYPE ReportType
,
327 /*IN*/ USHORT DataIndex
,
328 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
329 /*OUT*/ PHIDP_EXTENDED_ATTRIBUTES Attributes
,
330 /*IN OUT*/ PULONG LengthAttributes
);
335 HidP_GetLinkCollectionNodes(
336 /*OUT*/ PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
337 /*IN OUT*/ PULONG LinkCollectionNodesLength
,
338 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
);
343 HidP_GetScaledUsageValue(
344 /*IN*/ HIDP_REPORT_TYPE ReportType
,
345 /*IN*/ USAGE UsagePage
,
346 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
348 /*OUT*/ PLONG UsageValue
,
349 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
351 /*IN*/ ULONG ReportLength
);
356 HidP_GetSpecificButtonCaps(
357 /*IN*/ HIDP_REPORT_TYPE ReportType
,
358 /*IN*/ USAGE UsagePage
,
359 /*IN*/ USHORT LinkCollection
,
361 /*OUT*/ PHIDP_BUTTON_CAPS ButtonCaps
,
362 /*IN OUT*/ PULONG ButtonCapsLength
,
363 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
);
368 HidP_GetSpecificValueCaps(
369 /*IN*/ HIDP_REPORT_TYPE ReportType
,
370 /*IN*/ USAGE UsagePage
,
371 /*IN*/ USHORT LinkCollection
,
373 /*OUT*/ PHIDP_VALUE_CAPS ValueCaps
,
374 /*IN OUT*/ PULONG ValueCapsLength
,
375 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
);
381 /*IN*/ HIDP_REPORT_TYPE ReportType
,
382 /*IN*/ USAGE UsagePage
,
383 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
384 /*OUT*/ USAGE
*UsageList
,
385 /*IN OUT*/ ULONG
*UsageLength
,
386 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
388 /*IN*/ ULONG ReportLength
);
394 /*IN*/ HIDP_REPORT_TYPE ReportType
,
395 /*IN*/ USHORT LinkCollection
,
396 /*OUT*/ PUSAGE_AND_PAGE ButtonList
,
397 /*IN OUT*/ ULONG
*UsageLength
,
398 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
400 /*IN*/ ULONG ReportLength
);
406 /*IN*/ HIDP_REPORT_TYPE ReportType
,
407 /*IN*/ USAGE UsagePage
,
408 /*IN*/ USHORT LinkCollection
,
410 /*OUT*/ PULONG UsageValue
,
411 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
413 /*IN*/ ULONG ReportLength
);
418 HidP_GetUsageValueArray(
419 /*IN*/ HIDP_REPORT_TYPE ReportType
,
420 /*IN*/ USAGE UsagePage
,
421 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
423 /*OUT*/ PCHAR UsageValue
,
424 /*IN*/ USHORT UsageValueByteLength
,
425 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
427 /*IN*/ ULONG ReportLength
);
432 * IN HIDP_REPORT_TYPE ReportType,
433 * OUT PHIDP_VALUE_CAPS ValueCaps,
434 * IN OUT PULONG ValueCapsLength,
435 * IN PHIDP_PREPARSED_DATA PreparsedData);
437 #define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \
438 HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)
443 HidP_InitializeReportForID(
444 /*IN*/ HIDP_REPORT_TYPE ReportType
,
445 /*IN*/ UCHAR ReportID
,
446 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
447 /*IN OUT*/ PCHAR Report
,
448 /*IN*/ ULONG ReportLength
);
452 * HidP_IsSameUsageAndPage(
454 * USAGE_AND_PAGE u2);
456 #define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))
461 HidP_MaxDataListLength(
462 /*IN*/ HIDP_REPORT_TYPE ReportType
,
463 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
);
468 HidP_MaxUsageListLength(
469 /*IN*/ HIDP_REPORT_TYPE ReportType
,
470 /*IN*/ USAGE UsagePage
/*OPTIONAL*/,
471 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
);
476 * IN HIDP_REPORT_TYPE ReportType,
477 * IN USAGE UsagePage,
478 * IN USHORT LinkCollection,
479 * IN PUSAGE UsageList,
480 * IN OUT PULONG UsageLength,
481 * IN PHIDP_PREPARSED_DATA PreparsedData,
482 * IN OUT PCHAR Report,
483 * IN ULONG ReportLength);
485 #define HidP_SetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
486 HidP_SetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
492 /*IN*/ HIDP_REPORT_TYPE ReportType
,
493 /*IN*/ PHIDP_DATA DataList
,
494 /*IN OUT*/ PULONG DataLength
,
495 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
496 /*IN OUT*/ PCHAR Report
,
497 /*IN*/ ULONG ReportLength
);
502 HidP_SetScaledUsageValue(
503 /*IN*/ HIDP_REPORT_TYPE ReportType
,
504 /*IN*/ USAGE UsagePage
,
505 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
507 /*IN*/ LONG UsageValue
,
508 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
509 /*IN OUT*/ PCHAR Report
,
510 /*IN*/ ULONG ReportLength
);
516 /*IN*/ HIDP_REPORT_TYPE ReportType
,
517 /*IN*/ USAGE UsagePage
,
518 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
519 /*IN*/ PUSAGE UsageList
,
520 /*IN OUT*/ PULONG UsageLength
,
521 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
522 /*IN OUT*/ PCHAR Report
,
523 /*IN*/ ULONG ReportLength
);
529 /*IN*/ HIDP_REPORT_TYPE ReportType
,
530 /*IN*/ USAGE UsagePage
,
531 /*IN*/ USHORT LinkCollection
,
533 /*IN*/ ULONG UsageValue
,
534 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
535 /*IN OUT*/ PCHAR Report
,
536 /*IN*/ ULONG ReportLength
);
541 HidP_SetUsageValueArray(
542 /*IN*/ HIDP_REPORT_TYPE ReportType
,
543 /*IN*/ USAGE UsagePage
,
544 /*IN*/ USHORT LinkCollection
/*OPTIONAL*/,
546 /*IN*/ PCHAR UsageValue
,
547 /*IN*/ USHORT UsageValueByteLength
,
548 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
549 /*OUT*/ PCHAR Report
,
550 /*IN*/ ULONG ReportLength
);
555 * IN HIDP_REPORT_TYPE ReportType,
556 * IN USAGE UsagePage,
557 * IN USHORT LinkCollection,
558 * IN PUSAGE UsageList,
559 * IN OUT PULONG UsageLength,
560 * IN PHIDP_PREPARSED_DATA PreparsedData,
561 * IN OUT PCHAR Report,
562 * IN ULONG ReportLength);
564 #define HidP_UnsetButtons(RT, UP, LC, UL1, UL2, PD, R, RL) \
565 HidP_UnsetUsages(RT, UP, LC, UL1, UL2, PD, R, RL)
571 /*IN*/ HIDP_REPORT_TYPE ReportType
,
572 /*IN*/ USAGE UsagePage
,
573 /*IN*/ USHORT LinkCollection
,
574 /*IN*/ PUSAGE UsageList
,
575 /*IN OUT*/ PULONG UsageLength
,
576 /*IN*/ PHIDP_PREPARSED_DATA PreparsedData
,
577 /*IN OUT*/ PCHAR Report
,
578 /*IN*/ ULONG ReportLength
);
583 HidP_UsageAndPageListDifference(
584 /*IN*/ PUSAGE_AND_PAGE PreviousUsageList
,
585 /*IN*/ PUSAGE_AND_PAGE CurrentUsageList
,
586 /*OUT*/ PUSAGE_AND_PAGE BreakUsageList
,
587 /*OUT*/ PUSAGE_AND_PAGE MakeUsageList
,
588 /*IN*/ ULONG UsageListLength
);
593 HidP_UsageListDifference(
594 /*IN*/ PUSAGE PreviousUsageList
,
595 /*IN*/ PUSAGE CurrentUsageList
,
596 /*OUT*/ PUSAGE BreakUsageList
,
597 /*OUT*/ PUSAGE MakeUsageList
,
598 /*IN*/ ULONG UsageListLength
);
604 #endif /* __HIDPI_H */