ReactOS  0.4.15-dev-3440-g915569a
parser.h
Go to the documentation of this file.
1 #ifndef _HIDPARSER_H_
2 #define _HIDPARSER_H_
3 
4 #include <wdm.h>
5 #define _HIDPI_
6 #define _HIDPI_NO_FUNCTION_MACROS_
7 #include <hidpddi.h>
8 
9 #include "hidparser.h"
10 #include "hidp.h"
11 
12  /*
13  * Copyright 2007, Haiku, Inc. All Rights Reserved.
14  * Distributed under the terms of the MIT License.
15  */
16 
17 #define HID_REPORT_TYPE_ANY 0x07
18 
19 
20 #define ITEM_TYPE_MAIN 0x0
21 #define ITEM_TYPE_GLOBAL 0x1
22 #define ITEM_TYPE_LOCAL 0x2
23 #define ITEM_TYPE_LONG 0x3
24 
25 #define ITEM_TAG_MAIN_INPUT 0x8
26 #define ITEM_TAG_MAIN_OUTPUT 0x9
27 #define ITEM_TAG_MAIN_FEATURE 0xb
28 #define ITEM_TAG_MAIN_COLLECTION 0xa
29 #define ITEM_TAG_MAIN_END_COLLECTION 0xc
30 
31 #define ITEM_TAG_GLOBAL_USAGE_PAGE 0x0
32 #define ITEM_TAG_GLOBAL_LOGICAL_MINIMUM 0x1
33 #define ITEM_TAG_GLOBAL_LOGICAL_MAXIMUM 0x2
34 #define ITEM_TAG_GLOBAL_PHYSICAL_MINIMUM 0x3
35 #define ITEM_TAG_GLOBAL_PHYSICAL_MAXIMUM 0x4
36 #define ITEM_TAG_GLOBAL_UNIT_EXPONENT 0x5
37 #define ITEM_TAG_GLOBAL_UNIT 0x6
38 #define ITEM_TAG_GLOBAL_REPORT_SIZE 0x7
39 #define ITEM_TAG_GLOBAL_REPORT_ID 0x8
40 #define ITEM_TAG_GLOBAL_REPORT_COUNT 0x9
41 #define ITEM_TAG_GLOBAL_PUSH 0xa
42 #define ITEM_TAG_GLOBAL_POP 0xb
43 
44 #define ITEM_TAG_LOCAL_USAGE 0x0
45 #define ITEM_TAG_LOCAL_USAGE_MINIMUM 0x1
46 #define ITEM_TAG_LOCAL_USAGE_MAXIMUM 0x2
47 #define ITEM_TAG_LOCAL_DESIGNATOR_INDEX 0x3
48 #define ITEM_TAG_LOCAL_DESIGNATOR_MINIMUM 0x4
49 #define ITEM_TAG_LOCAL_DESIGNATOR_MAXIMUM 0x5
50 #define ITEM_TAG_LOCAL_STRING_INDEX 0x7
51 #define ITEM_TAG_LOCAL_STRING_MINIMUM 0x8
52 #define ITEM_TAG_LOCAL_STRING_MAXIMUM 0x9
53 #define ITEM_TAG_LOCAL_DELIMITER 0xa
54 
55 #define ITEM_TAG_LONG 0xf
56 
57 #define COLLECTION_PHYSICAL 0x00
58 #define COLLECTION_APPLICATION 0x01
59 #define COLLECTION_LOGICAL 0x02
60 #define COLLECTION_REPORT 0x03
61 #define COLLECTION_NAMED_ARRAY 0x04
62 #define COLLECTION_USAGE_SWITCH 0x05
63 #define COLLECTION_USAGE_MODIFIER 0x06
64 #define COLLECTION_ALL 0xff
65 
66 #define UNIT_SYSTEM 0x0
67 #define UNIT_LENGTH 0x1
68 #define UNIT_MASS 0x2
69 #define UNIT_TIME 0x3
70 #define UNIT_TEMPERATURE 0x4
71 #define UNIT_CURRENT 0x5
72 #define UNIT_LUMINOUS_INTENSITY 0x6
73 
74 #define USAGE_PAGE_SHIFT 16
75 #define USAGE_PAGE_MASK 0xffff
76 #define USAGE_ID_SHIFT 0
77 #define USAGE_ID_MASK 0xffff
78 
79 typedef struct
80 {
85 
86 #include <pshpack1.h>
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 #include <poppack.h>
103 
104 typedef struct
105 {
110 
112 
113 
114 #define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) USHORT b9,b8,b7,b6,b5,b4,b3,b2,b1
115 typedef struct
116 {
127 
129 
130 typedef struct __GLOBAL_ITEM_STATE_
131 {
142  struct __GLOBAL_ITEM_STATE__ * Next;
144 
145 
146 typedef struct usage_value
147 {
148  union
149  {
150  struct {
153  }s;
155  }u;
156 
159 
160 
161 typedef struct
162 {
166 
169 
172 
175 
178 
183 
185 
186 typedef struct
187 {
202 
203 struct _HID_REPORT;
204 
205 typedef struct __HID_COLLECTION__
206 {
213 
216  struct _HID_REPORT ** Reports;
217 
219 
221 
222 typedef struct _HID_REPORT
223 {
231 
232 typedef struct
233 {
234  //
235  // global item state
236  //
238 
239  //
240  // local item state
241  //
243 
244  //
245  // root collection
246  //
248 
249  //
250  // uses report ids
251  //
253 
254  //
255  // collection index
256  //
258 
260 
261 #define HID_REPORT_TYPE_INPUT 0x01
262 #define HID_REPORT_TYPE_OUTPUT 0x02
263 #define HID_REPORT_TYPE_FEATURE 0x04
264 
265 ULONG
267  IN PVOID CollectionContext,
268  IN UCHAR ReportType);
269 
270 NTSTATUS
272  IN PVOID CollectionContext,
273  OUT PUSHORT Usage,
275 
276 ULONG
278  IN PVOID CollectionContext,
279  IN UCHAR ReportType);
280 
281 ULONG
283  IN PVOID CollectionContext,
284  IN UCHAR ReportType);
285 
286 ULONG
288  IN PVOID CollectionContext,
289  IN UCHAR ReportType,
290  IN ULONG bData);
291 
292 ULONG
294  IN PVOID CollectionContext,
295  IN UCHAR ReportType,
297 
298 NTSTATUS
300  IN PVOID CollectionContext,
301  IN UCHAR ReportType,
303  IN USHORT Usage,
306 
307 
308 NTSTATUS
310  IN PVOID CollectionContext,
311  IN UCHAR ReportType,
313  OUT USAGE *UsageList,
315  IN PCHAR ReportDescriptor,
316  IN ULONG ReportDescriptorLength);
317 
318 NTSTATUS
320  IN PVOID CollectionContext,
321  IN UCHAR ReportType,
323  IN USAGE Usage,
324  OUT PLONG UsageValue,
325  IN PCHAR ReportDescriptor,
326  IN ULONG ReportDescriptorLength);
327 
328 NTSTATUS
330  IN PVOID CollectionContext,
331  IN UCHAR ReportType,
333  IN USAGE Usage,
334  OUT PULONG UsageValue,
335  IN PCHAR ReportDescriptor,
336  IN ULONG ReportDescriptorLength);
337 
338 /* parser.c */
339 
340 NTSTATUS
342  IN PVOID ParserContext,
343  IN ULONG CollectionIndex,
345  OUT PVOID *CollectionContext);
346 
347 ULONG
350 
351 NTSTATUS
353  PUCHAR Report,
354  ULONG ReportSize,
355  OUT PVOID *ParserContext);
356 
357 ULONG
359  IN PVOID ParserContext);
360 
361 ULONG
363  IN PVOID ParserContext,
364  IN ULONG CollectionNumber);
365 
366 
367 /* context.c */
368 
371  IN PVOID Context);
372 
373 ULONG
375  IN PVOID CollectionContext);
376 
377 NTSTATUS
379  IN PHID_COLLECTION RootCollection,
380  IN PVOID Context,
382 
385  IN PVOID Context,
386  IN UCHAR ReportType);
387 
388 #endif /* _HIDPARSER_H_ */
signed char * PCHAR
Definition: retypes.h:7
UCHAR PhysicalID
Definition: parser.h:210
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
union usage_value::@4072 u
#define IN
Definition: typedefs.h:39
UCHAR StringIndexSet
Definition: parser.h:180
USHORT IsVolatile
Definition: parser.h:124
struct _HID_REPORT HID_REPORT
struct __GLOBAL_ITEM_STATE__ * Next
Definition: parser.h:142
USHORT UsageId
Definition: parser.h:151
USHORT NoPreferred
Definition: parser.h:122
UCHAR ReportID
Definition: parser.h:225
ULONG CollectionIndex
Definition: parser.h:257
ITEM_PREFIX Prefix
Definition: parser.h:106
struct HID_PARSER_CONTEXT * PHID_PARSER_CONTEXT
UCHAR UsageMaximumSet
Definition: parser.h:171
ULONG UsageStackAllocated
Definition: parser.h:165
ULONG DesignatorMinimum
Definition: parser.h:176
ULONG ReportCount
Definition: parser.h:211
HID_REPORT_ITEM Items[1]
Definition: parser.h:229
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
ULONG LogicalMinimum
Definition: parser.h:133
_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:167
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
struct usage_value::@4072::@4073 s
ULONG DesignatorIndex
Definition: parser.h:173
NTSTATUS HidParser_BuildContext(IN PVOID ParserContext, IN ULONG CollectionIndex, IN ULONG ContextSize, OUT PVOID *CollectionContext)
Definition: parser.c:1303
ULONG UsageStackUsed
Definition: parser.h:164
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:1443
ULONG UsageMinimum
Definition: parser.h:197
ULONG DesignatorMaximum
Definition: parser.h:177
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS ValueCaps
Definition: hidpi.h:396
USHORT NullState
Definition: parser.h:123
ULONG LogicialMaximum
Definition: parser.h:134
struct MAIN_ITEM_DATA * PMAIN_ITEM_DATA
ITEM_PREFIX Prefix
Definition: parser.h:89
ULONG Extended
Definition: parser.h:154
USHORT NonLinear
Definition: parser.h:121
UCHAR Size
Definition: parser.h:81
ULONG PhysicalMaximum
Definition: parser.h:136
USHORT UsagePage
Definition: parser.h:152
UCHAR Tag
Definition: parser.h:83
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:194
PHID_COLLECTION RootCollection
Definition: parser.h:247
struct SHORT_ITEM * PSHORT_ITEM
ULONG HidParser_GetContextSize(IN PVOID ParserContext, IN ULONG CollectionNumber)
Definition: parser.c:1351
UCHAR StringMaximum
Definition: parser.h:182
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:198
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:214
USHORT BitsBytes
Definition: parser.h:125
ULONG HidParser_GetMaxUsageListLengthWithReportAndPage(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage OPTIONAL)
Definition: api.c:210
UCHAR BitCount
Definition: parser.h:191
ULONG Offsets[1]
Definition: parser.h:218
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:192
NTSTATUS HidParser_GetCollectionUsagePage(IN PVOID CollectionContext, OUT PUSHORT Usage, OUT PUSHORT UsagePage)
Definition: api.c:65
UCHAR UsageMinimumSet
Definition: parser.h:170
ULONG PhysicalMinimum
Definition: parser.h:135
USHORT USAGE
Definition: hidusage.h:30
ULONG Maximum
Definition: parser.h:196
UCHAR DesignatorIndexSet
Definition: parser.h:174
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR UseReportIDs
Definition: parser.h:252
UCHAR Array
Definition: parser.h:193
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:119
PHID_REPORT HidParser_GetReportInCollection(IN PVOID Context, IN UCHAR ReportType)
Definition: context.c:277
ULONG Minimum
Definition: parser.h:195
struct __HID_COLLECTION__ * PHID_COLLECTION
UCHAR LongItemTag
Definition: parser.h:108
LOCAL_ITEM_STATE LocalItemState
Definition: parser.h:242
USAGE_VALUE UsageMaximum
Definition: parser.h:168
ULONG HidParser_UsesReportId(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:524
GLOBAL_ITEM_STATE GlobalItemState
Definition: parser.h:237
ULONG ReportSize
Definition: parser.h:226
USHORT Wrap
Definition: parser.h:120
ULONG ItemCount
Definition: parser.h:227
struct LONG_ITEM * PLONG_ITEM
struct __HID_COLLECTION__ * Root
Definition: parser.h:215
ULONG Data
Definition: parser.h:199
UCHAR IsExtended
Definition: parser.h:157
USHORT DataConstant
Definition: parser.h:117
UCHAR Type
Definition: parser.h:82
UCHAR StringIndex
Definition: parser.h:179
unsigned short USHORT
Definition: pedump.c:61
ULONG ByteOffset
Definition: parser.h:188
USHORT ArrayVariable
Definition: parser.h:118
struct __GLOBAL_ITEM_STATE_ GLOBAL_ITEM_STATE
unsigned int * PULONG
Definition: retypes.h:1
UCHAR Shift
Definition: parser.h:189
ULONG ItemAllocated
Definition: parser.h:228
PUSAGE_VALUE UsageStack
Definition: parser.h:163
UCHAR StringMinimum
Definition: parser.h:181
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:224
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:190
struct _HID_REPORT ** Reports
Definition: parser.h:216
signed int * PLONG
Definition: retypes.h:5
UCHAR Valid
Definition: parser.h:200
NTSTATUS HidParser_ParseReportDescriptor(PUCHAR Report, ULONG ReportSize, OUT PVOID *ParserContext)
unsigned short * PUSHORT
Definition: retypes.h:2
UCHAR DataSize
Definition: parser.h:107
_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