[USB-BRINGUP]
[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
83 //
84 // parser context
85 //
86 void * ParserContext;
87
88 }HID_PARSER, *PHID_PARSER;
89
90 HIDPARSER_STATUS
91 HidParser_AllocateParser(
92 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
93 IN PHIDPARSER_FREE_FUNCTION FreeFunction,
94 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
95 IN PHIDPARSER_COPY_FUNCTION CopyFunction,
96 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
97 OUT PHID_PARSER *OutParser);
98
99 VOID
100 HidParser_InitParser(
101 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
102 IN PHIDPARSER_FREE_FUNCTION FreeFunction,
103 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
104 IN PHIDPARSER_COPY_FUNCTION CopyFunction,
105 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
106 IN PVOID ParserContext,
107 OUT PHID_PARSER Parser);
108
109 NTSTATUS
110 NTAPI
111 HidParser_GetCollectionDescription(
112 IN PHID_PARSER Parser,
113 IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
114 IN ULONG DescLength,
115 IN POOL_TYPE PoolType,
116 OUT PHIDP_DEVICE_DESC DeviceDescription);
117
118 VOID
119 NTAPI
120 HidParser_FreeCollectionDescription(
121 IN PHID_PARSER Parser,
122 IN PHIDP_DEVICE_DESC DeviceDescription);
123
124 HIDAPI
125 NTSTATUS
126 NTAPI
127 HidParser_GetCaps(
128 IN PHID_PARSER Parser,
129 OUT PHIDP_CAPS Capabilities);
130
131 HIDAPI
132 NTSTATUS
133 NTAPI
134 HidParser_GetSpecificValueCaps(
135 IN PHID_PARSER Parser,
136 IN HIDP_REPORT_TYPE ReportType,
137 IN USAGE UsagePage,
138 IN USHORT LinkCollection,
139 IN USAGE Usage,
140 OUT PHIDP_VALUE_CAPS ValueCaps,
141 IN OUT PULONG ValueCapsLength);
142
143
144 HIDAPI
145 NTSTATUS
146 NTAPI
147 HidParser_GetButtonCaps(
148 IN PHID_PARSER Parser,
149 HIDP_REPORT_TYPE ReportType,
150 PHIDP_BUTTON_CAPS ButtonCaps,
151 PUSHORT ButtonCapsLength);
152
153 HIDAPI
154 NTSTATUS
155 NTAPI
156 HidParser_GetSpecificButtonCaps(
157 IN PHID_PARSER Parser,
158 IN HIDP_REPORT_TYPE ReportType,
159 IN USAGE UsagePage,
160 IN USHORT LinkCollection,
161 IN USAGE Usage,
162 OUT PHIDP_BUTTON_CAPS ButtonCaps,
163 IN OUT PULONG ButtonCapsLength);
164
165 HIDAPI
166 NTSTATUS
167 NTAPI
168 HidParser_GetScaledUsageValue(
169 IN PHID_PARSER Parser,
170 IN HIDP_REPORT_TYPE ReportType,
171 IN USAGE UsagePage,
172 IN USHORT LinkCollection OPTIONAL,
173 IN USAGE Usage,
174 OUT PLONG UsageValue,
175 IN PCHAR Report,
176 IN ULONG ReportLength);
177
178
179 HIDAPI
180 NTSTATUS
181 NTAPI
182 HidParser_GetData(
183 IN HIDP_REPORT_TYPE ReportType,
184 OUT PHIDP_DATA DataList,
185 IN OUT PULONG DataLength,
186 IN PHIDP_PREPARSED_DATA PreparsedData,
187 IN PCHAR Report,
188 IN ULONG ReportLength);
189
190 HIDAPI
191 NTSTATUS
192 NTAPI
193 HidParser_GetExtendedAttributes(
194 IN HIDP_REPORT_TYPE ReportType,
195 IN USHORT DataIndex,
196 IN PHIDP_PREPARSED_DATA PreparsedData,
197 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
198 IN OUT PULONG LengthAttributes);
199
200 HIDAPI
201 NTSTATUS
202 NTAPI
203 HidParser_GetLinkCollectionNodes(
204 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
205 IN OUT PULONG LinkCollectionNodesLength,
206 IN PHIDP_PREPARSED_DATA PreparsedData);
207
208 HIDAPI
209 NTSTATUS
210 NTAPI
211 HidParser_GetUsageValue(
212 IN HIDP_REPORT_TYPE ReportType,
213 IN USAGE UsagePage,
214 IN USHORT LinkCollection,
215 IN USAGE Usage,
216 OUT PULONG UsageValue,
217 IN PHIDP_PREPARSED_DATA PreparsedData,
218 IN PCHAR Report,
219 IN ULONG ReportLength);
220
221 HIDAPI
222 NTSTATUS
223 NTAPI
224 HidParser_UsageListDifference(
225 IN PUSAGE PreviousUsageList,
226 IN PUSAGE CurrentUsageList,
227 OUT PUSAGE BreakUsageList,
228 OUT PUSAGE MakeUsageList,
229 IN ULONG UsageListLength);
230
231
232 HIDAPI
233 ULONG
234 NTAPI
235 HidParser_MaxUsageListLength(
236 IN PHID_PARSER Parser,
237 IN HIDP_REPORT_TYPE ReportType,
238 IN USAGE UsagePage OPTIONAL);
239
240 HIDAPI
241 NTSTATUS
242 NTAPI
243 HidParser_GetUsages(
244 IN PHID_PARSER Parser,
245 IN HIDP_REPORT_TYPE ReportType,
246 IN USAGE UsagePage,
247 IN USHORT LinkCollection OPTIONAL,
248 OUT USAGE *UsageList,
249 IN OUT ULONG *UsageLength,
250 IN PCHAR Report,
251 IN ULONG ReportLength);
252
253 HIDAPI
254 NTSTATUS
255 NTAPI
256 HidParser_GetUsagesEx(
257 IN PHID_PARSER Parser,
258 IN HIDP_REPORT_TYPE ReportType,
259 IN USHORT LinkCollection,
260 OUT PUSAGE_AND_PAGE ButtonList,
261 IN OUT ULONG *UsageLength,
262 IN PCHAR Report,
263 IN ULONG ReportLength);
264
265
266 NTSTATUS
267 NTAPI
268 HidParser_SysPowerEvent (
269 IN PCHAR HidPacket,
270 IN USHORT HidPacketLength,
271 IN PHIDP_PREPARSED_DATA Ppd,
272 OUT PULONG OutputBuffer);
273
274 NTSTATUS
275 NTAPI
276 HidParser_SysPowerCaps (
277 IN PHIDP_PREPARSED_DATA Ppd,
278 OUT PULONG OutputBuffer);
279
280 HIDAPI
281 NTSTATUS
282 NTAPI
283 HidParser_GetUsageValueArray(
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 PHIDP_PREPARSED_DATA PreparsedData,
291 IN PCHAR Report,
292 IN ULONG ReportLength);
293
294
295 HIDAPI
296 NTSTATUS
297 NTAPI
298 HidParser_UsageAndPageListDifference(
299 IN PUSAGE_AND_PAGE PreviousUsageList,
300 IN PUSAGE_AND_PAGE CurrentUsageList,
301 OUT PUSAGE_AND_PAGE BreakUsageList,
302 OUT PUSAGE_AND_PAGE MakeUsageList,
303 IN ULONG UsageListLength);
304
305 HIDAPI
306 NTSTATUS
307 NTAPI
308 HidParser_UnsetUsages(
309 IN HIDP_REPORT_TYPE ReportType,
310 IN USAGE UsagePage,
311 IN USHORT LinkCollection,
312 IN PUSAGE UsageList,
313 IN OUT PULONG UsageLength,
314 IN PHIDP_PREPARSED_DATA PreparsedData,
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 HIDP_REPORT_TYPE ReportType,
346 IN USAGE UsagePage,
347 IN USHORT LinkCollection,
348 IN PUSAGE UsageList,
349 IN OUT PULONG UsageLength,
350 IN PHIDP_PREPARSED_DATA PreparsedData,
351 IN OUT PCHAR Report,
352 IN ULONG ReportLength);
353
354 HIDAPI
355 NTSTATUS
356 NTAPI
357 HidParser_SetUsageValueArray(
358 IN HIDP_REPORT_TYPE ReportType,
359 IN USAGE UsagePage,
360 IN USHORT LinkCollection OPTIONAL,
361 IN USAGE Usage,
362 IN PCHAR UsageValue,
363 IN USHORT UsageValueByteLength,
364 IN PHIDP_PREPARSED_DATA PreparsedData,
365 OUT PCHAR Report,
366 IN ULONG ReportLength);
367
368 HIDAPI
369 NTSTATUS
370 NTAPI
371 HidParser_SetUsageValue(
372 IN HIDP_REPORT_TYPE ReportType,
373 IN USAGE UsagePage,
374 IN USHORT LinkCollection,
375 IN USAGE Usage,
376 IN ULONG UsageValue,
377 IN PHIDP_PREPARSED_DATA PreparsedData,
378 IN OUT PCHAR Report,
379 IN ULONG ReportLength);
380
381 HIDAPI
382 NTSTATUS
383 NTAPI
384 HidParser_SetScaledUsageValue(
385 IN HIDP_REPORT_TYPE ReportType,
386 IN USAGE UsagePage,
387 IN USHORT LinkCollection OPTIONAL,
388 IN USAGE Usage,
389 IN LONG UsageValue,
390 IN PHIDP_PREPARSED_DATA PreparsedData,
391 IN OUT PCHAR Report,
392 IN ULONG ReportLength);
393
394 HIDAPI
395 NTSTATUS
396 NTAPI
397 HidParser_SetData(
398 IN HIDP_REPORT_TYPE ReportType,
399 IN PHIDP_DATA DataList,
400 IN OUT PULONG DataLength,
401 IN PHIDP_PREPARSED_DATA PreparsedData,
402 IN OUT PCHAR Report,
403 IN ULONG ReportLength);
404
405 HIDAPI
406 ULONG
407 NTAPI
408 HidParser_MaxDataListLength(
409 IN HIDP_REPORT_TYPE ReportType,
410 IN PHIDP_PREPARSED_DATA PreparsedData);
411
412 HIDAPI
413 NTSTATUS
414 NTAPI
415 HidParser_InitializeReportForID(
416 IN HIDP_REPORT_TYPE ReportType,
417 IN UCHAR ReportID,
418 IN PHIDP_PREPARSED_DATA PreparsedData,
419 IN OUT PCHAR Report,
420 IN ULONG ReportLength);
421
422
423 HIDPARSER_STATUS
424 HidParser_TranslateUsage(
425 IN PHID_PARSER Parser,
426 IN USAGE Usage,
427 IN HIDP_KEYBOARD_DIRECTION KeyAction,
428 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
429 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
430 IN PVOID InsertCodesContext);
431
432 HIDAPI
433 NTSTATUS
434 NTAPI
435 HidParser_GetValueCaps(
436 HIDP_REPORT_TYPE ReportType,
437 PHIDP_VALUE_CAPS ValueCaps,
438 PULONG ValueCapsLength,
439 PHIDP_PREPARSED_DATA PreparsedData);