[HIDPARSER]
[reactos.git] / lib / drivers / hidparser / hidparser.h
1 /*
2 * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/drivers/hidparser/hidparser.c
5 * PURPOSE: HID Parser
6 * PROGRAMMERS:
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
9 */
10
11 #pragma once
12
13 #define _HIDPI_
14 #define _HIDPI_NO_FUNCTION_MACROS_
15 #include <ntddk.h>
16 #include <hidpddi.h>
17 #include <hidpi.h>
18 #include <debug.h>
19
20 //
21 // function prototypes
22 //
23 typedef PVOID (NTAPI *PHIDPARSER_ALLOC_FUNCTION)(ULONG Size);
24 typedef VOID (NTAPI *PHIDPARSER_FREE_FUNCTION)(PVOID Item);
25 typedef VOID (NTAPI *PHIDPARSER_ZERO_FUNCTION)(PVOID Item, ULONG Size);
26 typedef VOID (NTAPI *PHIDPARSER_COPY_FUNCTION)(PVOID Target, PVOID Source, ULONG Size);
27 typedef VOID (NTAPI *PHIDPARSER_DEBUG_FUNCTION)(LPCSTR Src, ...);
28
29 //
30 // status code
31 //
32 typedef long HIDPARSER_STATUS;
33
34 //
35 // result codes
36 //
37 typedef enum
38 {
39 HIDPARSER_STATUS_SUCCESS = 0,
40 HIDPARSER_STATUS_INSUFFICIENT_RESOURCES = -1,
41 HIDPARSER_STATUS_NOT_IMPLEMENTED = -2,
42 HIDPARSER_STATUS_REPORT_NOT_FOUND = -3,
43 HIDPARSER_STATUS_COLLECTION_NOT_FOUND = -4,
44 HIDPARSER_STATUS_INVALID_REPORT_LENGTH = -5,
45 HIDPARSER_STATUS_INVALID_REPORT_TYPE = -6,
46 HIDPARSER_STATUS_BUFFER_TOO_SMALL = -7,
47 HIDPARSER_STATUS_USAGE_NOT_FOUND = -8,
48 HIDPARSER_STATUS_I8042_TRANS_UNKNOWN = -9
49 }HIDPARSER_STATUS_CODES;
50
51 typedef struct
52 {
53 //
54 // size of struct
55 //
56 unsigned long Size;
57
58 //
59 // allocation function
60 //
61 PHIDPARSER_ALLOC_FUNCTION Alloc;
62
63 //
64 // free function
65 //
66 PFREE_FUNCTION Free;
67
68 //
69 // zero function
70 //
71 PHIDPARSER_ZERO_FUNCTION Zero;
72
73 //
74 // copy function
75 //
76 PHIDPARSER_COPY_FUNCTION Copy;
77
78 //
79 // debug function
80 //
81 PHIDPARSER_DEBUG_FUNCTION Debug;
82 }HID_PARSER, *PHID_PARSER;
83
84 VOID
85 HidParser_InitParser(
86 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
87 IN PHIDPARSER_FREE_FUNCTION FreeFunction,
88 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
89 IN PHIDPARSER_COPY_FUNCTION CopyFunction,
90 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
91 OUT PHID_PARSER Parser);
92
93 NTSTATUS
94 NTAPI
95 HidParser_GetCollectionDescription(
96 IN PHID_PARSER Parser,
97 IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
98 IN ULONG DescLength,
99 IN POOL_TYPE PoolType,
100 OUT PHIDP_DEVICE_DESC DeviceDescription);
101
102 VOID
103 NTAPI
104 HidParser_FreeCollectionDescription(
105 IN PHID_PARSER Parser,
106 IN PHIDP_DEVICE_DESC DeviceDescription);
107
108 HIDAPI
109 NTSTATUS
110 NTAPI
111 HidParser_GetCaps(
112 IN PHID_PARSER Parser,
113 IN PVOID CollectionContext,
114 OUT PHIDP_CAPS Capabilities);
115
116 HIDAPI
117 NTSTATUS
118 NTAPI
119 HidParser_GetSpecificValueCaps(
120 IN PHID_PARSER Parser,
121 IN PVOID CollectionContext,
122 IN HIDP_REPORT_TYPE ReportType,
123 IN USAGE UsagePage,
124 IN USHORT LinkCollection,
125 IN USAGE Usage,
126 OUT PHIDP_VALUE_CAPS ValueCaps,
127 IN OUT PULONG ValueCapsLength);
128
129
130 HIDAPI
131 NTSTATUS
132 NTAPI
133 HidParser_GetButtonCaps(
134 IN PHID_PARSER Parser,
135 IN PVOID CollectionContext,
136 HIDP_REPORT_TYPE ReportType,
137 PHIDP_BUTTON_CAPS ButtonCaps,
138 PUSHORT ButtonCapsLength);
139
140 HIDAPI
141 NTSTATUS
142 NTAPI
143 HidParser_GetSpecificButtonCaps(
144 IN PHID_PARSER Parser,
145 IN PVOID CollectionContext,
146 IN HIDP_REPORT_TYPE ReportType,
147 IN USAGE UsagePage,
148 IN USHORT LinkCollection,
149 IN USAGE Usage,
150 OUT PHIDP_BUTTON_CAPS ButtonCaps,
151 IN OUT PULONG ButtonCapsLength);
152
153 HIDAPI
154 NTSTATUS
155 NTAPI
156 HidParser_GetScaledUsageValue(
157 IN PHID_PARSER Parser,
158 IN PVOID CollectionContext,
159 IN HIDP_REPORT_TYPE ReportType,
160 IN USAGE UsagePage,
161 IN USHORT LinkCollection OPTIONAL,
162 IN USAGE Usage,
163 OUT PLONG UsageValue,
164 IN PCHAR Report,
165 IN ULONG ReportLength);
166
167
168 HIDAPI
169 NTSTATUS
170 NTAPI
171 HidParser_GetData(
172 IN PHID_PARSER Parser,
173 IN PVOID CollectionContext,
174 IN HIDP_REPORT_TYPE ReportType,
175 OUT PHIDP_DATA DataList,
176 IN OUT PULONG DataLength,
177 IN PCHAR Report,
178 IN ULONG ReportLength);
179
180 HIDAPI
181 NTSTATUS
182 NTAPI
183 HidParser_GetExtendedAttributes(
184 IN PHID_PARSER Parser,
185 IN PVOID CollectionContext,
186 IN HIDP_REPORT_TYPE ReportType,
187 IN USHORT DataIndex,
188 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
189 IN OUT PULONG LengthAttributes);
190
191 HIDAPI
192 NTSTATUS
193 NTAPI
194 HidParser_GetLinkCollectionNodes(
195 IN PHID_PARSER Parser,
196 IN PVOID CollectionContext,
197 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
198 IN OUT PULONG LinkCollectionNodesLength);
199
200 HIDAPI
201 NTSTATUS
202 NTAPI
203 HidParser_GetUsageValue(
204 IN PHID_PARSER Parser,
205 IN PVOID CollectionContext,
206 IN HIDP_REPORT_TYPE ReportType,
207 IN USAGE UsagePage,
208 IN USHORT LinkCollection,
209 IN USAGE Usage,
210 OUT PULONG UsageValue,
211 IN PCHAR Report,
212 IN ULONG ReportLength);
213
214 HIDAPI
215 NTSTATUS
216 NTAPI
217 HidParser_UsageListDifference(
218 IN PUSAGE PreviousUsageList,
219 IN PUSAGE CurrentUsageList,
220 OUT PUSAGE BreakUsageList,
221 OUT PUSAGE MakeUsageList,
222 IN ULONG UsageListLength);
223
224
225 HIDAPI
226 ULONG
227 NTAPI
228 HidParser_MaxUsageListLength(
229 IN PHID_PARSER Parser,
230 IN PVOID CollectionContext,
231 IN HIDP_REPORT_TYPE ReportType,
232 IN USAGE UsagePage OPTIONAL);
233
234 HIDAPI
235 NTSTATUS
236 NTAPI
237 HidParser_GetUsages(
238 IN PHID_PARSER Parser,
239 IN PVOID CollectionContext,
240 IN HIDP_REPORT_TYPE ReportType,
241 IN USAGE UsagePage,
242 IN USHORT LinkCollection OPTIONAL,
243 OUT USAGE *UsageList,
244 IN OUT ULONG *UsageLength,
245 IN PCHAR Report,
246 IN ULONG ReportLength);
247
248 HIDAPI
249 NTSTATUS
250 NTAPI
251 HidParser_GetUsagesEx(
252 IN PHID_PARSER Parser,
253 IN PVOID CollectionContext,
254 IN HIDP_REPORT_TYPE ReportType,
255 IN USHORT LinkCollection,
256 OUT PUSAGE_AND_PAGE ButtonList,
257 IN OUT ULONG *UsageLength,
258 IN PCHAR Report,
259 IN ULONG ReportLength);
260
261
262 NTSTATUS
263 NTAPI
264 HidParser_SysPowerEvent (
265 IN PHID_PARSER Parser,
266 IN PVOID CollectionContext,
267 IN PCHAR HidPacket,
268 IN USHORT HidPacketLength,
269 OUT PULONG OutputBuffer);
270
271 NTSTATUS
272 NTAPI
273 HidParser_SysPowerCaps (
274 IN PHID_PARSER Parser,
275 IN PVOID CollectionContext,
276 OUT PULONG OutputBuffer);
277
278 HIDAPI
279 NTSTATUS
280 NTAPI
281 HidParser_GetUsageValueArray(
282 IN PHID_PARSER Parser,
283 IN PVOID CollectionContext,
284 IN HIDP_REPORT_TYPE ReportType,
285 IN USAGE UsagePage,
286 IN USHORT LinkCollection OPTIONAL,
287 IN USAGE Usage,
288 OUT PCHAR UsageValue,
289 IN USHORT UsageValueByteLength,
290 IN PCHAR Report,
291 IN ULONG ReportLength);
292
293
294 HIDAPI
295 NTSTATUS
296 NTAPI
297 HidParser_UsageAndPageListDifference(
298 IN PUSAGE_AND_PAGE PreviousUsageList,
299 IN PUSAGE_AND_PAGE CurrentUsageList,
300 OUT PUSAGE_AND_PAGE BreakUsageList,
301 OUT PUSAGE_AND_PAGE MakeUsageList,
302 IN ULONG UsageListLength);
303
304 HIDAPI
305 NTSTATUS
306 NTAPI
307 HidParser_UnsetUsages(
308 IN PHID_PARSER Parser,
309 IN PVOID CollectionContext,
310 IN HIDP_REPORT_TYPE ReportType,
311 IN USAGE UsagePage,
312 IN USHORT LinkCollection,
313 IN PUSAGE UsageList,
314 IN OUT PULONG UsageLength,
315 IN OUT PCHAR Report,
316 IN ULONG ReportLength);
317
318 HIDAPI
319 NTSTATUS
320 NTAPI
321 HidParser_TranslateUsagesToI8042ScanCodes(
322 IN PUSAGE ChangedUsageList,
323 IN ULONG UsageListLength,
324 IN HIDP_KEYBOARD_DIRECTION KeyAction,
325 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
326 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
327 IN PVOID InsertCodesContext);
328
329 HIDAPI
330 NTSTATUS
331 NTAPI
332 HidParser_TranslateUsageAndPagesToI8042ScanCodes(
333 IN PHID_PARSER Parser,
334 IN PUSAGE_AND_PAGE ChangedUsageList,
335 IN ULONG UsageListLength,
336 IN HIDP_KEYBOARD_DIRECTION KeyAction,
337 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
338 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
339 IN PVOID InsertCodesContext);
340
341 HIDAPI
342 NTSTATUS
343 NTAPI
344 HidParser_SetUsages(
345 IN PHID_PARSER Parser,
346 IN PVOID CollectionContext,
347 IN HIDP_REPORT_TYPE ReportType,
348 IN USAGE UsagePage,
349 IN USHORT LinkCollection,
350 IN PUSAGE UsageList,
351 IN OUT PULONG UsageLength,
352 IN OUT PCHAR Report,
353 IN ULONG ReportLength);
354
355 HIDAPI
356 NTSTATUS
357 NTAPI
358 HidParser_SetUsageValueArray(
359 IN PHID_PARSER Parser,
360 IN PVOID CollectionContext,
361 IN HIDP_REPORT_TYPE ReportType,
362 IN USAGE UsagePage,
363 IN USHORT LinkCollection OPTIONAL,
364 IN USAGE Usage,
365 IN PCHAR UsageValue,
366 IN USHORT UsageValueByteLength,
367 OUT PCHAR Report,
368 IN ULONG ReportLength);
369
370 HIDAPI
371 NTSTATUS
372 NTAPI
373 HidParser_SetUsageValue(
374 IN PHID_PARSER Parser,
375 IN PVOID CollectionContext,
376 IN HIDP_REPORT_TYPE ReportType,
377 IN USAGE UsagePage,
378 IN USHORT LinkCollection,
379 IN USAGE Usage,
380 IN ULONG UsageValue,
381 IN OUT PCHAR Report,
382 IN ULONG ReportLength);
383
384 HIDAPI
385 NTSTATUS
386 NTAPI
387 HidParser_SetScaledUsageValue(
388 IN PHID_PARSER Parser,
389 IN PVOID CollectionContext,
390 IN HIDP_REPORT_TYPE ReportType,
391 IN USAGE UsagePage,
392 IN USHORT LinkCollection OPTIONAL,
393 IN USAGE Usage,
394 IN LONG UsageValue,
395 IN OUT PCHAR Report,
396 IN ULONG ReportLength);
397
398 HIDAPI
399 NTSTATUS
400 NTAPI
401 HidParser_SetData(
402 IN PHID_PARSER Parser,
403 IN PVOID CollectionContext,
404 IN HIDP_REPORT_TYPE ReportType,
405 IN PHIDP_DATA DataList,
406 IN OUT PULONG DataLength,
407 IN OUT PCHAR Report,
408 IN ULONG ReportLength);
409
410 HIDAPI
411 ULONG
412 NTAPI
413 HidParser_MaxDataListLength(
414 IN PHID_PARSER Parser,
415 IN PVOID CollectionContext,
416 IN HIDP_REPORT_TYPE ReportType);
417
418 HIDAPI
419 NTSTATUS
420 NTAPI
421 HidParser_InitializeReportForID(
422 IN PHID_PARSER Parser,
423 IN PVOID CollectionContext,
424 IN HIDP_REPORT_TYPE ReportType,
425 IN UCHAR ReportID,
426 IN OUT PCHAR Report,
427 IN ULONG ReportLength);
428
429 HIDPARSER_STATUS
430 HidParser_TranslateUsage(
431 IN PHID_PARSER Parser,
432 IN USAGE Usage,
433 IN HIDP_KEYBOARD_DIRECTION KeyAction,
434 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
435 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
436 IN PVOID InsertCodesContext);
437
438 HIDAPI
439 NTSTATUS
440 NTAPI
441 HidParser_GetValueCaps(
442 PHID_PARSER Parser,
443 IN PVOID CollectionContext,
444 HIDP_REPORT_TYPE ReportType,
445 PHIDP_VALUE_CAPS ValueCaps,
446 PULONG ValueCapsLength);