ReactOS  0.4.14-dev-115-g4576127
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 
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 typedef struct
87 {
89 
90  union
91  {
92  UCHAR UData8[4];
93  CHAR SData8[4];
94  USHORT UData16[2];
95  SHORT SData16[2];
98  }Data;
99 
101 
102 typedef struct
103 {
108 
110 
111 
112 #define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) USHORT b9,b8,b7,b6,b5,b4,b3,b2,b1
113 typedef struct
114 {
125 
127 
128 typedef struct __GLOBAL_ITEM_STATE_
129 {
140  struct __GLOBAL_ITEM_STATE__ * Next;
142 
143 
144 typedef struct usage_value
145 {
146  union
147  {
148  struct {
151  }s;
153  }u;
154 
157 
158 
159 typedef struct
160 {
164 
167 
170 
173 
176 
181 
183 
184 typedef struct
185 {
200 
201 struct _HID_REPORT;
202 
203 typedef struct __HID_COLLECTION__
204 {
211 
214  struct _HID_REPORT ** Reports;
215 
217 
219 
220 typedef struct _HID_REPORT
221 {
229 
230 typedef struct
231 {
232  //
233  // global item state
234  //
236 
237  //
238  // local item state
239  //
241 
242  //
243  // root collection
244  //
246 
247  //
248  // uses report ids
249  //
251 
252  //
253  // collection index
254  //
256 
258 
259 #define HID_REPORT_TYPE_INPUT 0x01
260 #define HID_REPORT_TYPE_OUTPUT 0x02
261 #define HID_REPORT_TYPE_FEATURE 0x04
262 
263 ULONG
265  IN PVOID CollectionContext,
266  IN UCHAR ReportType);
267 
270  IN PVOID CollectionContext,
271  OUT PUSHORT Usage,
273 
274 ULONG
276  IN PVOID CollectionContext,
277  IN UCHAR ReportType);
278 
279 UCHAR
281  IN PHID_PARSER Parser);
282 
283 ULONG
285  IN PVOID CollectionContext,
286  IN UCHAR ReportType);
287 
288 ULONG
290  IN PVOID CollectionContext,
291  IN UCHAR ReportType,
292  IN ULONG bData);
293 
294 ULONG
296  IN PVOID CollectionContext,
297  IN UCHAR ReportType,
299 
302  IN PHID_PARSER Parser,
303  IN PVOID CollectionContext,
304  IN UCHAR ReportType,
306  IN USHORT Usage,
309 
310 
313  IN PHID_PARSER Parser,
314  IN PVOID CollectionContext,
315  IN UCHAR ReportType,
317  OUT USAGE *UsageList,
319  IN PCHAR ReportDescriptor,
320  IN ULONG ReportDescriptorLength);
321 
324  IN PHID_PARSER Parser,
325  IN PVOID CollectionContext,
326  IN UCHAR ReportType,
328  IN USAGE Usage,
329  OUT PLONG UsageValue,
330  IN PCHAR ReportDescriptor,
331  IN ULONG ReportDescriptorLength);
332 
335  IN PHID_PARSER Parser,
336  IN PVOID CollectionContext,
337  IN UCHAR ReportType,
339  IN USAGE Usage,
340  OUT PULONG UsageValue,
341  IN PCHAR ReportDescriptor,
342  IN ULONG ReportDescriptorLength);
343 
344 /* parser.c */
345 
348  IN PHID_PARSER Parser,
349  IN PVOID ParserContext,
350  IN ULONG CollectionIndex,
352  OUT PVOID *CollectionContext);
353 
354 ULONG
356  IN PHID_COLLECTION Collection);
357 
360  PHID_PARSER Parser,
361  PUCHAR Report,
362  ULONG ReportSize,
363  OUT PVOID *ParserContext);
364 
365 ULONG
367  IN PVOID ParserContext);
368 
369 ULONG
371  IN PHID_PARSER Parser,
372  IN PVOID ParserContext,
373  IN ULONG CollectionNumber);
374 
375 
376 /* context.c */
377 
380  IN PVOID Context);
381 
382 ULONG
384  IN PVOID CollectionContext);
385 
388  IN PHID_PARSER Parser,
389  IN PHID_COLLECTION RootCollection,
390  IN PVOID Context,
392 
395  IN PVOID Context,
396  IN UCHAR ReportType);
397 
398 #endif /* _HIDPARSER_H_ */
signed char * PCHAR
Definition: retypes.h:7
UCHAR PhysicalID
Definition: parser.h:208
struct _HID_REPORT * PHID_REPORT
#define IN
Definition: typedefs.h:38
UCHAR StringIndexSet
Definition: parser.h:178
USHORT IsVolatile
Definition: parser.h:122
struct _HID_REPORT HID_REPORT
struct __GLOBAL_ITEM_STATE__ * Next
Definition: parser.h:140
USHORT UsageId
Definition: parser.h:149
USHORT NoPreferred
Definition: parser.h:120
UCHAR ReportID
Definition: parser.h:223
ULONG CollectionIndex
Definition: parser.h:255
ITEM_PREFIX Prefix
Definition: parser.h:104
struct HID_PARSER_CONTEXT * PHID_PARSER_CONTEXT
UCHAR UsageMaximumSet
Definition: parser.h:169
UCHAR HidParser_IsReportIDUsed(IN PHID_PARSER Parser)
ULONG UsageStackAllocated
Definition: parser.h:163
ULONG DesignatorMinimum
Definition: parser.h:174
ULONG ReportCount
Definition: parser.h:209
HID_REPORT_ITEM Items[1]
Definition: parser.h:227
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
ULONG LogicalMinimum
Definition: parser.h:131
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
struct __GLOBAL_ITEM_STATE_ * PGLOBAL_ITEM_STATE
USAGE_VALUE UsageMinimum
Definition: parser.h:165
_Must_inspect_result_ _In_ USHORT _Inout_updates_to_ UsageLength PUSAGE_AND_PAGE _Inout_ ULONG * UsageLength
Definition: hidpi.h:425
ULONG DesignatorIndex
Definition: parser.h:171
ULONG UsageStackUsed
Definition: parser.h:162
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:195
ULONG DesignatorMaximum
Definition: parser.h:175
HIDPARSER_STATUS HidParser_BuildContext(IN PHID_PARSER Parser, IN PVOID ParserContext, IN ULONG CollectionIndex, IN ULONG ContextSize, OUT PVOID *CollectionContext)
Definition: parser.c:1315
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE _Out_ PHIDP_VALUE_CAPS ValueCaps
Definition: hidpi.h:396
USHORT NullState
Definition: parser.h:121
ULONG LogicialMaximum
Definition: parser.h:132
struct MAIN_ITEM_DATA * PMAIN_ITEM_DATA
ITEM_PREFIX Prefix
Definition: parser.h:88
ULONG Extended
Definition: parser.h:152
USHORT NonLinear
Definition: parser.h:119
UCHAR Size
Definition: parser.h:81
ULONG PhysicalMaximum
Definition: parser.h:134
HIDPARSER_STATUS HidParser_GetSpecificValueCapsWithReport(IN PHID_PARSER Parser, IN PVOID CollectionContext, IN UCHAR ReportType, IN USHORT UsagePage, IN USHORT Usage, OUT PHIDP_VALUE_CAPS ValueCaps, IN OUT PUSHORT ValueCapsLength)
Definition: api.c:271
USHORT UsagePage
Definition: parser.h:150
UCHAR Tag
Definition: parser.h:83
long LONG
Definition: pedump.c:60
ULONG HidParser_GetContextSize(IN PHID_PARSER Parser, IN PVOID ParserContext, IN ULONG CollectionNumber)
Definition: parser.c:1364
short SHORT
Definition: pedump.c:59
ULONG HidParser_GetTotalCollectionCount(IN PVOID CollectionContext)
Definition: context.c:332
r reserved
Definition: btrfs.c:2893
UCHAR Relative
Definition: parser.h:192
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
HIDPARSER_STATUS HidParser_GetUsagesWithReport(IN PHID_PARSER Parser, 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:361
PHID_COLLECTION RootCollection
Definition: parser.h:245
struct SHORT_ITEM * PSHORT_ITEM
UCHAR StringMaximum
Definition: parser.h:180
struct usage_value * PUSAGE_VALUE
_Must_inspect_result_ _In_ USAGE UsagePage
Definition: hidpi.h:382
struct ITEM_PREFIX * PITEM_PREFIX
ULONG UsageMaximum
Definition: parser.h:196
struct usage_value USAGE_VALUE
PHID_COLLECTION HidParser_GetCollectionFromContext(IN PVOID Context)
Definition: context.c:292
LONG SData32
Definition: parser.h:97
struct __HID_COLLECTION__ HID_COLLECTION
struct __HID_COLLECTION__ ** Nodes
Definition: parser.h:212
USHORT BitsBytes
Definition: parser.h:123
ULONG HidParser_GetMaxUsageListLengthWithReportAndPage(IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage OPTIONAL)
Definition: api.c:227
UCHAR BitCount
Definition: parser.h:189
ULONG Offsets[1]
Definition: parser.h:216
ULONG HidParser_CalculateContextSize(IN PHID_COLLECTION Collection)
Definition: context.c:65
HIDPARSER_STATUS HidParser_ParseReportDescriptor(PHID_PARSER Parser, PUCHAR Report, ULONG ReportSize, OUT PVOID *ParserContext)
UCHAR HasData
Definition: parser.h:190
UCHAR UsageMinimumSet
Definition: parser.h:168
ULONG PhysicalMinimum
Definition: parser.h:133
USHORT USAGE
Definition: hidusage.h:30
ULONG Maximum
Definition: parser.h:194
UCHAR DesignatorIndexSet
Definition: parser.h:172
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR UseReportIDs
Definition: parser.h:250
UCHAR Array
Definition: parser.h:191
HIDPARSER_STATUS HidParser_GetCollectionUsagePage(IN PVOID CollectionContext, OUT PUSHORT Usage, OUT PUSHORT UsagePage)
Definition: api.c:65
struct HID_REPORT_ITEM * PHID_REPORT_ITEM
USHORT Relative
Definition: parser.h:117
PHID_REPORT HidParser_GetReportInCollection(IN PVOID Context, IN UCHAR ReportType)
Definition: context.c:279
ULONG Minimum
Definition: parser.h:193
struct __HID_COLLECTION__ * PHID_COLLECTION
UCHAR LongItemTag
Definition: parser.h:106
LOCAL_ITEM_STATE LocalItemState
Definition: parser.h:240
USAGE_VALUE UsageMaximum
Definition: parser.h:166
ULONG HidParser_UsesReportId(IN PVOID CollectionContext, IN UCHAR ReportType)
Definition: api.c:543
GLOBAL_ITEM_STATE GlobalItemState
Definition: parser.h:235
ULONG ReportSize
Definition: parser.h:224
USHORT Wrap
Definition: parser.h:118
ULONG ItemCount
Definition: parser.h:225
struct LONG_ITEM * PLONG_ITEM
struct __HID_COLLECTION__ * Root
Definition: parser.h:213
ULONG Data
Definition: parser.h:197
UCHAR IsExtended
Definition: parser.h:155
USHORT DataConstant
Definition: parser.h:115
long HIDPARSER_STATUS
Definition: hidparser.h:25
UCHAR Type
Definition: parser.h:82
UCHAR StringIndex
Definition: parser.h:177
unsigned short USHORT
Definition: pedump.c:61
ULONG ByteOffset
Definition: parser.h:186
USHORT ArrayVariable
Definition: parser.h:116
struct __GLOBAL_ITEM_STATE_ GLOBAL_ITEM_STATE
unsigned int * PULONG
Definition: retypes.h:1
UCHAR Shift
Definition: parser.h:187
union usage_value::@3926 u
ULONG ItemAllocated
Definition: parser.h:226
PUSAGE_VALUE UsageStack
Definition: parser.h:161
UCHAR StringMinimum
Definition: parser.h:179
ULONG HidParser_NumberOfTopCollections(IN PVOID ParserContext)
Definition: parser.c:1291
struct usage_value::@3926::@3927 s
#define OUT
Definition: typedefs.h:39
ULONG UData32
Definition: parser.h:96
unsigned int ULONG
Definition: retypes.h:1
HIDPARSER_STATUS HidParser_GetScaledUsageValueWithReport(IN PHID_PARSER Parser, IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PLONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:666
UCHAR Type
Definition: parser.h:222
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:188
HIDPARSER_STATUS HidParser_GetUsageValueWithReport(IN PHID_PARSER Parser, IN PVOID CollectionContext, IN UCHAR ReportType, IN USAGE UsagePage, IN USAGE Usage, OUT PULONG UsageValue, IN PCHAR ReportDescriptor, IN ULONG ReportDescriptorLength)
Definition: api.c:569
struct _HID_REPORT ** Reports
Definition: parser.h:214
signed int * PLONG
Definition: retypes.h:5
UCHAR Valid
Definition: parser.h:198
HIDPARSER_STATUS HidParser_BuildCollectionContext(IN PHID_PARSER Parser, IN PHID_COLLECTION RootCollection, IN PVOID Context, IN ULONG ContextSize)
Definition: context.c:186
unsigned short * PUSHORT
Definition: retypes.h:2
UCHAR DataSize
Definition: parser.h:105
_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