ReactOS  0.4.15-dev-1638-gc0caa5c
parser.h
Go to the documentation of this file.
1 #ifndef _HIDPARSER_H_
2 #define _HIDPARSER_H_
3 
4 #include <wdm.h>
5 #include <pshpack1.h>
6 #define _HIDPI_
7 #define _HIDPI_NO_FUNCTION_MACROS_
8 #include <hidpddi.h>
9 
10 #include "hidparser.h"
11 #include "hidp.h"
12 
13  /*
14  * Copyright 2007, Haiku, Inc. All Rights Reserved.
15  * Distributed under the terms of the MIT License.
16  */
17 
18 #define HID_REPORT_TYPE_ANY 0x07
19 
20 
21 #define ITEM_TYPE_MAIN 0x0
22 #define ITEM_TYPE_GLOBAL 0x1
23 #define ITEM_TYPE_LOCAL 0x2
24 #define ITEM_TYPE_LONG 0x3
25 
26 #define ITEM_TAG_MAIN_INPUT 0x8
27 #define ITEM_TAG_MAIN_OUTPUT 0x9
28 #define ITEM_TAG_MAIN_FEATURE 0xb
29 #define ITEM_TAG_MAIN_COLLECTION 0xa
30 #define ITEM_TAG_MAIN_END_COLLECTION 0xc
31 
32 #define ITEM_TAG_GLOBAL_USAGE_PAGE 0x0
33 #define ITEM_TAG_GLOBAL_LOGICAL_MINIMUM 0x1
34 #define ITEM_TAG_GLOBAL_LOGICAL_MAXIMUM 0x2
35 #define ITEM_TAG_GLOBAL_PHYSICAL_MINIMUM 0x3
36 #define ITEM_TAG_GLOBAL_PHYSICAL_MAXIMUM 0x4
37 #define ITEM_TAG_GLOBAL_UNIT_EXPONENT 0x5
38 #define ITEM_TAG_GLOBAL_UNIT 0x6
39 #define ITEM_TAG_GLOBAL_REPORT_SIZE 0x7
40 #define ITEM_TAG_GLOBAL_REPORT_ID 0x8
41 #define ITEM_TAG_GLOBAL_REPORT_COUNT 0x9
42 #define ITEM_TAG_GLOBAL_PUSH 0xa
43 #define ITEM_TAG_GLOBAL_POP 0xb
44 
45 #define ITEM_TAG_LOCAL_USAGE 0x0
46 #define ITEM_TAG_LOCAL_USAGE_MINIMUM 0x1
47 #define ITEM_TAG_LOCAL_USAGE_MAXIMUM 0x2
48 #define ITEM_TAG_LOCAL_DESIGNATOR_INDEX 0x3
49 #define ITEM_TAG_LOCAL_DESIGNATOR_MINIMUM 0x4
50 #define ITEM_TAG_LOCAL_DESIGNATOR_MAXIMUM 0x5
51 #define ITEM_TAG_LOCAL_STRING_INDEX 0x7
52 #define ITEM_TAG_LOCAL_STRING_MINIMUM 0x8
53 #define ITEM_TAG_LOCAL_STRING_MAXIMUM 0x9
54 #define ITEM_TAG_LOCAL_DELIMITER 0xa
55 
56 #define ITEM_TAG_LONG 0xf
57 
58 #define COLLECTION_PHYSICAL 0x00
59 #define COLLECTION_APPLICATION 0x01
60 #define COLLECTION_LOGICAL 0x02
61 #define COLLECTION_REPORT 0x03
62 #define COLLECTION_NAMED_ARRAY 0x04
63 #define COLLECTION_USAGE_SWITCH 0x05
64 #define COLLECTION_USAGE_MODIFIER 0x06
65 #define COLLECTION_ALL 0xff
66 
67 #define UNIT_SYSTEM 0x0
68 #define UNIT_LENGTH 0x1
69 #define UNIT_MASS 0x2
70 #define UNIT_TIME 0x3
71 #define UNIT_TEMPERATURE 0x4
72 #define UNIT_CURRENT 0x5
73 #define UNIT_LUMINOUS_INTENSITY 0x6
74 
75 #define USAGE_PAGE_SHIFT 16
76 #define USAGE_PAGE_MASK 0xffff
77 #define USAGE_ID_SHIFT 0
78 #define USAGE_ID_MASK 0xffff
79 
80 typedef struct
81 {
86 
87 typedef struct
88 {
90 
91  union
92  {
93  UCHAR UData8[4];
94  CHAR SData8[4];
95  USHORT UData16[2];
96  SHORT SData16[2];
99  }Data;
100 
102 
103 typedef struct
104 {
109 
111 
112 
113 #define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) USHORT b9,b8,b7,b6,b5,b4,b3,b2,b1
114 typedef struct
115 {
126 
128 
129 typedef struct __GLOBAL_ITEM_STATE_
130 {
141  struct __GLOBAL_ITEM_STATE__ * Next;
143 
144 
145 typedef struct usage_value
146 {
147  union
148  {
149  struct {
152  }s;
154  }u;
155 
158 
159 
160 typedef struct
161 {
165 
168 
171 
174 
177 
182 
184 
185 typedef struct
186 {
201 
202 struct _HID_REPORT;
203 
204 typedef struct __HID_COLLECTION__
205 {
212 
215  struct _HID_REPORT ** Reports;
216 
218 
220 
221 typedef struct _HID_REPORT
222 {
230 
231 typedef struct
232 {
233  //
234  // global item state
235  //
237 
238  //
239  // local item state
240  //
242 
243  //
244  // root collection
245  //
247 
248  //
249  // uses report ids
250  //
252 
253  //
254  // collection index
255  //
257 
259 
260 #define HID_REPORT_TYPE_INPUT 0x01
261 #define HID_REPORT_TYPE_OUTPUT 0x02
262 #define HID_REPORT_TYPE_FEATURE 0x04
263 
264 ULONG
266  IN PVOID CollectionContext,
267  IN UCHAR ReportType);
268 
269 NTSTATUS
271  IN PVOID CollectionContext,
272  OUT PUSHORT Usage,
274 
275 ULONG
277  IN PVOID CollectionContext,
278  IN UCHAR ReportType);
279 
280 ULONG
282  IN PVOID CollectionContext,
283  IN UCHAR ReportType);
284 
285 ULONG
287  IN PVOID CollectionContext,
288  IN UCHAR ReportType,
289  IN ULONG bData);
290 
291 ULONG
293  IN PVOID CollectionContext,
294  IN UCHAR ReportType,
296 
297 NTSTATUS
299  IN PVOID CollectionContext,
300  IN UCHAR ReportType,
302  IN USHORT Usage,
305 
306 
307 NTSTATUS
309  IN PVOID CollectionContext,
310  IN UCHAR ReportType,
312  OUT USAGE *UsageList,
314  IN PCHAR ReportDescriptor,
315  IN ULONG ReportDescriptorLength);
316 
317 NTSTATUS
319  IN PVOID CollectionContext,
320  IN UCHAR ReportType,
322  IN USAGE Usage,
323  OUT PLONG UsageValue,
324  IN PCHAR ReportDescriptor,
325  IN ULONG ReportDescriptorLength);
326 
327 NTSTATUS
329  IN PVOID CollectionContext,
330  IN UCHAR ReportType,
332  IN USAGE Usage,
333  OUT PULONG UsageValue,
334  IN PCHAR ReportDescriptor,
335  IN ULONG ReportDescriptorLength);
336 
337 /* parser.c */
338 
339 NTSTATUS
341  IN PVOID ParserContext,
342  IN ULONG CollectionIndex,
344  OUT PVOID *CollectionContext);
345 
346 ULONG
349 
350 NTSTATUS
352  PUCHAR Report,
353  ULONG ReportSize,
354  OUT PVOID *ParserContext);
355 
356 ULONG
358  IN PVOID ParserContext);
359 
360 ULONG
362  IN PVOID ParserContext,
363  IN ULONG CollectionNumber);
364 
365 
366 /* context.c */
367 
370  IN PVOID Context);
371 
372 ULONG
374  IN PVOID CollectionContext);
375 
376 NTSTATUS
378  IN PHID_COLLECTION RootCollection,
379  IN PVOID Context,
381 
384  IN PVOID Context,
385  IN UCHAR ReportType);
386 
387 #endif /* _HIDPARSER_H_ */
signed char * PCHAR
Definition: retypes.h:7
UCHAR PhysicalID
Definition: parser.h:209
struct _HID_REPORT * PHID_REPORT
NTSTATUS HidParser_GetSpecificValueCapsWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USHORT UsagePage, IN USHORT Usage, OUT PHIDP_VALUE_CAPS ValueCaps, IN OUT PUSHORT ValueCapsLength)
Definition: api.c:254
#define IN
Definition: typedefs.h:39
UCHAR StringIndexSet
Definition: parser.h:179
USHORT IsVolatile
Definition: parser.h:123
struct _HID_REPORT HID_REPORT
struct __GLOBAL_ITEM_STATE__ * Next
Definition: parser.h:141
USHORT UsageId
Definition: parser.h:150
USHORT NoPreferred
Definition: parser.h:121
UCHAR ReportID
Definition: parser.h:224
ULONG CollectionIndex
Definition: parser.h:256
ITEM_PREFIX Prefix
Definition: parser.h:105
struct HID_PARSER_CONTEXT * PHID_PARSER_CONTEXT
UCHAR UsageMaximumSet
Definition: parser.h:170
ULONG UsageStackAllocated
Definition: parser.h:164
ULONG DesignatorMinimum
Definition: parser.h:175
ULONG ReportCount
Definition: parser.h:210
HID_REPORT_ITEM Items[1]
Definition: parser.h:228
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
ULONG LogicalMinimum
Definition: parser.h:132
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ WDFCOLLECTION Collection
Definition: wdfregistry.h:367
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
char CHAR
Definition: xmlstorage.h:175
struct __GLOBAL_ITEM_STATE_ * PGLOBAL_ITEM_STATE
USAGE_VALUE UsageMinimum
Definition: parser.h:166
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE _Inout_ ULONG * UsageLength
Definition: hidpi.h:425
ULONG DesignatorIndex
Definition: parser.h:172
NTSTATUS HidParser_BuildContext(IN PVOID ParserContext, IN ULONG CollectionIndex, IN ULONG ContextSize, OUT PVOID *CollectionContext)
Definition: parser.c:1303
ULONG UsageStackUsed
Definition: parser.h:163
ULONG HidParser_GetReportItemCountFromReportType(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:132
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1444
ULONG UsageMinimum
Definition: parser.h:196
ULONG DesignatorMaximum
Definition: parser.h:176
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS ValueCaps
Definition: hidpi.h:396
USHORT NullState
Definition: parser.h:122
ULONG LogicialMaximum
Definition: parser.h:133
struct MAIN_ITEM_DATA * PMAIN_ITEM_DATA
ITEM_PREFIX Prefix
Definition: parser.h:89
ULONG Extended
Definition: parser.h:153
USHORT NonLinear
Definition: parser.h:120
UCHAR Size
Definition: parser.h:82
ULONG PhysicalMaximum
Definition: parser.h:135
USHORT UsagePage
Definition: parser.h:151
UCHAR Tag
Definition: parser.h:84
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
ULONG HidParser_GetTotalCollectionCount(IN PVOID CollectionContext)
Definition: context.c:330
r reserved
Definition: btrfs.c:2940
UCHAR Relative
Definition: parser.h:193
PHID_COLLECTION RootCollection
Definition: parser.h:246
struct SHORT_ITEM * PSHORT_ITEM
ULONG HidParser_GetContextSize(IN PVOID ParserContext, IN ULONG CollectionNumber)
Definition: parser.c:1351
UCHAR StringMaximum
Definition: parser.h:181
struct usage_value * PUSAGE_VALUE
_Must_inspect_result_ _In_ USAGE UsagePage
Definition: hidpi.h:382
struct ITEM_PREFIX * PITEM_PREFIX
NTSTATUS HidParser_GetUsageValueWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PULONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:550
ULONG UsageMaximum
Definition: parser.h:197
struct usage_value USAGE_VALUE
PHID_COLLECTION HidParser_GetCollectionFromContext(IN PVOID Context)
Definition: context.c:290
LONG SData32
Definition: parser.h:98
struct __HID_COLLECTION__ HID_COLLECTION
struct __HID_COLLECTION__ ** Nodes
Definition: parser.h:213
USHORT BitsBytes
Definition: parser.h:124
ULONG HidParser_GetMaxUsageListLengthWithReportAndPage(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage OPTIONAL)
Definition: api.c:210
UCHAR BitCount
Definition: parser.h:190
ULONG Offsets[1]
Definition: parser.h:217
ULONG HidParser_CalculateContextSize(IN PHID_COLLECTION Collection)
Definition: context.c:65
NTSTATUS HidParser_BuildCollectionContext(IN PHID_COLLECTION RootCollection, IN PVOID Context, IN ULONG ContextSize)
Definition: context.c:185
UCHAR HasData
Definition: parser.h:191
struct usage_value::@4116::@4117 s
NTSTATUS HidParser_GetCollectionUsagePage(IN PVOID CollectionContext, OUT PUSHORT Usage, OUT PUSHORT UsagePage)
Definition: api.c:65
UCHAR UsageMinimumSet
Definition: parser.h:169
ULONG PhysicalMinimum
Definition: parser.h:134
USHORT USAGE
Definition: hidusage.h:30
ULONG Maximum
Definition: parser.h:195
UCHAR DesignatorIndexSet
Definition: parser.h:173
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR UseReportIDs
Definition: parser.h:251
UCHAR Array
Definition: parser.h:192
struct HID_REPORT_ITEM * PHID_REPORT_ITEM
NTSTATUS HidParser_GetUsagesWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, OUT USAGE *UsageList, IN OUT PULONG UsageLength, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:343
NTSTATUS HidParser_GetScaledUsageValueWithReport(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PLONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:646
USHORT Relative
Definition: parser.h:118
PHID_REPORT HidParser_GetReportInCollection(IN PVOID Context, IN UCHAR ReportType)
Definition: context.c:277
ULONG Minimum
Definition: parser.h:194
struct __HID_COLLECTION__ * PHID_COLLECTION
UCHAR LongItemTag
Definition: parser.h:107
LOCAL_ITEM_STATE LocalItemState
Definition: parser.h:241
USAGE_VALUE UsageMaximum
Definition: parser.h:167
ULONG HidParser_UsesReportId(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:524
GLOBAL_ITEM_STATE GlobalItemState
Definition: parser.h:236
ULONG ReportSize
Definition: parser.h:225
USHORT Wrap
Definition: parser.h:119
ULONG ItemCount
Definition: parser.h:226
struct LONG_ITEM * PLONG_ITEM
struct __HID_COLLECTION__ * Root
Definition: parser.h:214
ULONG Data
Definition: parser.h:198
UCHAR IsExtended
Definition: parser.h:156
USHORT DataConstant
Definition: parser.h:116
UCHAR Type
Definition: parser.h:83
UCHAR StringIndex
Definition: parser.h:178
unsigned short USHORT
Definition: pedump.c:61
ULONG ByteOffset
Definition: parser.h:187
union usage_value::@4116 u
USHORT ArrayVariable
Definition: parser.h:117
struct __GLOBAL_ITEM_STATE_ GLOBAL_ITEM_STATE
unsigned int * PULONG
Definition: retypes.h:1
UCHAR Shift
Definition: parser.h:188
ULONG ItemAllocated
Definition: parser.h:227
PUSAGE_VALUE UsageStack
Definition: parser.h:162
UCHAR StringMinimum
Definition: parser.h:180
ULONG HidParser_NumberOfTopCollections(IN PVOID ParserContext)
Definition: parser.c:1279
#define OUT
Definition: typedefs.h:40
ULONG UData32
Definition: parser.h:97
unsigned int ULONG
Definition: retypes.h:1
UCHAR Type
Definition: parser.h:223
ULONG HidParser_GetReportItemTypeCountFromReportType(IN PVOID CollectionContext, IN UCHAR ReportType, IN ULONG bData)
Definition: api.c:158
ULONG HidParser_GetReportLength(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:93
struct LOCAL_ITEM_STATE * PLOCAL_ITEM_STATE
ULONG Mask
Definition: parser.h:189
struct _HID_REPORT ** Reports
Definition: parser.h:215
signed int * PLONG
Definition: retypes.h:5
UCHAR Valid
Definition: parser.h:199
NTSTATUS HidParser_ParseReportDescriptor(PUCHAR Report, ULONG ReportSize, OUT PVOID *ParserContext)
unsigned short * PUSHORT
Definition: retypes.h:2
UCHAR DataSize
Definition: parser.h:106
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS _Inout_ PUSHORT ValueCapsLength
Definition: hidpi.h:396
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68