[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_CODES;
49
50 typedef struct
51 {
52 //
53 // size of struct
54 //
55 unsigned long Size;
56
57 //
58 // allocation function
59 //
60 PHIDPARSER_ALLOC_FUNCTION Alloc;
61
62 //
63 // free function
64 //
65 PFREE_FUNCTION Free;
66
67 //
68 // zero function
69 //
70 PHIDPARSER_ZERO_FUNCTION Zero;
71
72 //
73 // copy function
74 //
75 PHIDPARSER_COPY_FUNCTION Copy;
76
77 //
78 // debug function
79 //
80 PHIDPARSER_DEBUG_FUNCTION Debug;
81
82 //
83 // parser context
84 //
85 void * ParserContext;
86
87 }HID_PARSER, *PHID_PARSER;
88
89 HIDPARSER_STATUS
90 HidParser_AllocateParser(
91 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
92 IN PHIDPARSER_FREE_FUNCTION FreeFunction,
93 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
94 IN PHIDPARSER_COPY_FUNCTION CopyFunction,
95 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
96 OUT PHID_PARSER *OutParser);
97
98 VOID
99 HidParser_InitParser(
100 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
101 IN PHIDPARSER_FREE_FUNCTION FreeFunction,
102 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
103 IN PHIDPARSER_COPY_FUNCTION CopyFunction,
104 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
105 IN PVOID ParserContext,
106 OUT PHID_PARSER Parser);
107
108 NTSTATUS
109 NTAPI
110 HidParser_GetCollectionDescription(
111 IN PHID_PARSER Parser,
112 IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
113 IN ULONG DescLength,
114 IN POOL_TYPE PoolType,
115 OUT PHIDP_DEVICE_DESC DeviceDescription);
116
117 VOID
118 NTAPI
119 HidParser_FreeCollectionDescription(
120 IN PHID_PARSER Parser,
121 IN PHIDP_DEVICE_DESC DeviceDescription);
122
123 HIDAPI
124 NTSTATUS
125 NTAPI
126 HidParser_GetCaps(
127 IN PHID_PARSER Parser,
128 OUT PHIDP_CAPS Capabilities);
129
130 HIDAPI
131 NTSTATUS
132 NTAPI
133 HidParser_GetSpecificValueCaps(
134 IN PHID_PARSER Parser,
135 IN HIDP_REPORT_TYPE ReportType,
136 IN USAGE UsagePage,
137 IN USHORT LinkCollection,
138 IN USAGE Usage,
139 OUT PHIDP_VALUE_CAPS ValueCaps,
140 IN OUT PULONG ValueCapsLength);
141
142
143 HIDAPI
144 NTSTATUS
145 NTAPI
146 HidParser_GetButtonCaps(
147 IN PHID_PARSER Parser,
148 HIDP_REPORT_TYPE ReportType,
149 PHIDP_BUTTON_CAPS ButtonCaps,
150 PUSHORT ButtonCapsLength);
151
152 HIDAPI
153 NTSTATUS
154 NTAPI
155 HidParser_GetSpecificButtonCaps(
156 IN PHID_PARSER Parser,
157 IN HIDP_REPORT_TYPE ReportType,
158 IN USAGE UsagePage,
159 IN USHORT LinkCollection,
160 IN USAGE Usage,
161 OUT PHIDP_BUTTON_CAPS ButtonCaps,
162 IN OUT PULONG ButtonCapsLength);
163
164 HIDAPI
165 NTSTATUS
166 NTAPI
167 HidParser_GetScaledUsageValue(
168 IN PHID_PARSER Parser,
169 IN HIDP_REPORT_TYPE ReportType,
170 IN USAGE UsagePage,
171 IN USHORT LinkCollection OPTIONAL,
172 IN USAGE Usage,
173 OUT PLONG UsageValue,
174 IN PCHAR Report,
175 IN ULONG ReportLength);
176
177
178 HIDAPI
179 NTSTATUS
180 NTAPI
181 HidParser_GetData(
182 IN HIDP_REPORT_TYPE ReportType,
183 OUT PHIDP_DATA DataList,
184 IN OUT PULONG DataLength,
185 IN PHIDP_PREPARSED_DATA PreparsedData,
186 IN PCHAR Report,
187 IN ULONG ReportLength);
188
189 HIDAPI
190 NTSTATUS
191 NTAPI
192 HidParser_GetExtendedAttributes(
193 IN HIDP_REPORT_TYPE ReportType,
194 IN USHORT DataIndex,
195 IN PHIDP_PREPARSED_DATA PreparsedData,
196 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
197 IN OUT PULONG LengthAttributes);
198
199 HIDAPI
200 NTSTATUS
201 NTAPI
202 HidParser_GetLinkCollectionNodes(
203 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
204 IN OUT PULONG LinkCollectionNodesLength,
205 IN PHIDP_PREPARSED_DATA PreparsedData);
206
207 HIDAPI
208 NTSTATUS
209 NTAPI
210 HidParser_GetUsageValue(
211 IN HIDP_REPORT_TYPE ReportType,
212 IN USAGE UsagePage,
213 IN USHORT LinkCollection,
214 IN USAGE Usage,
215 OUT PULONG UsageValue,
216 IN PHIDP_PREPARSED_DATA PreparsedData,
217 IN PCHAR Report,
218 IN ULONG ReportLength);
219
220 HIDAPI
221 NTSTATUS
222 NTAPI
223 HidParser_UsageListDifference(
224 IN PUSAGE PreviousUsageList,
225 IN PUSAGE CurrentUsageList,
226 OUT PUSAGE BreakUsageList,
227 OUT PUSAGE MakeUsageList,
228 IN ULONG UsageListLength);
229
230
231 HIDAPI
232 ULONG
233 NTAPI
234 HidParser_MaxUsageListLength(
235 IN PHID_PARSER Parser,
236 IN HIDP_REPORT_TYPE ReportType,
237 IN USAGE UsagePage OPTIONAL);
238
239 HIDAPI
240 NTSTATUS
241 NTAPI
242 HidParser_GetUsages(
243 IN PHID_PARSER Parser,
244 IN HIDP_REPORT_TYPE ReportType,
245 IN USAGE UsagePage,
246 IN USHORT LinkCollection OPTIONAL,
247 OUT USAGE *UsageList,
248 IN OUT ULONG *UsageLength,
249 IN PCHAR Report,
250 IN ULONG ReportLength);
251
252 HIDAPI
253 NTSTATUS
254 NTAPI
255 HidParser_GetUsagesEx(
256 IN PHID_PARSER Parser,
257 IN HIDP_REPORT_TYPE ReportType,
258 IN USHORT LinkCollection,
259 OUT PUSAGE_AND_PAGE ButtonList,
260 IN OUT ULONG *UsageLength,
261 IN PCHAR Report,
262 IN ULONG ReportLength);
263
264
265 NTSTATUS
266 NTAPI
267 HidParser_SysPowerEvent (
268 IN PCHAR HidPacket,
269 IN USHORT HidPacketLength,
270 IN PHIDP_PREPARSED_DATA Ppd,
271 OUT PULONG OutputBuffer);
272
273 NTSTATUS
274 NTAPI
275 HidParser_SysPowerCaps (
276 IN PHIDP_PREPARSED_DATA Ppd,
277 OUT PULONG OutputBuffer);
278
279 HIDAPI
280 NTSTATUS
281 NTAPI
282 HidParser_GetUsageValueArray(
283 IN HIDP_REPORT_TYPE ReportType,
284 IN USAGE UsagePage,
285 IN USHORT LinkCollection OPTIONAL,
286 IN USAGE Usage,
287 OUT PCHAR UsageValue,
288 IN USHORT UsageValueByteLength,
289 IN PHIDP_PREPARSED_DATA PreparsedData,
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 HIDP_REPORT_TYPE ReportType,
309 IN USAGE UsagePage,
310 IN USHORT LinkCollection,
311 IN PUSAGE UsageList,
312 IN OUT PULONG UsageLength,
313 IN PHIDP_PREPARSED_DATA PreparsedData,
314 IN OUT PCHAR Report,
315 IN ULONG ReportLength);
316
317 HIDAPI
318 NTSTATUS
319 NTAPI
320 HidParser_TranslateUsagesToI8042ScanCodes(
321 IN PUSAGE ChangedUsageList,
322 IN ULONG UsageListLength,
323 IN HIDP_KEYBOARD_DIRECTION KeyAction,
324 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
325 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
326 IN PVOID InsertCodesContext);
327
328 HIDAPI
329 NTSTATUS
330 NTAPI
331 HidParser_TranslateUsageAndPagesToI8042ScanCodes(
332 IN PUSAGE_AND_PAGE ChangedUsageList,
333 IN ULONG UsageListLength,
334 IN HIDP_KEYBOARD_DIRECTION KeyAction,
335 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
336 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
337 IN PVOID InsertCodesContext);
338
339 HIDAPI
340 NTSTATUS
341 NTAPI
342 HidParser_SetUsages(
343 IN HIDP_REPORT_TYPE ReportType,
344 IN USAGE UsagePage,
345 IN USHORT LinkCollection,
346 IN PUSAGE UsageList,
347 IN OUT PULONG UsageLength,
348 IN PHIDP_PREPARSED_DATA PreparsedData,
349 IN OUT PCHAR Report,
350 IN ULONG ReportLength);
351
352 HIDAPI
353 NTSTATUS
354 NTAPI
355 HidParser_SetUsageValueArray(
356 IN HIDP_REPORT_TYPE ReportType,
357 IN USAGE UsagePage,
358 IN USHORT LinkCollection OPTIONAL,
359 IN USAGE Usage,
360 IN PCHAR UsageValue,
361 IN USHORT UsageValueByteLength,
362 IN PHIDP_PREPARSED_DATA PreparsedData,
363 OUT PCHAR Report,
364 IN ULONG ReportLength);
365
366 HIDAPI
367 NTSTATUS
368 NTAPI
369 HidParser_SetUsageValue(
370 IN HIDP_REPORT_TYPE ReportType,
371 IN USAGE UsagePage,
372 IN USHORT LinkCollection,
373 IN USAGE Usage,
374 IN ULONG UsageValue,
375 IN PHIDP_PREPARSED_DATA PreparsedData,
376 IN OUT PCHAR Report,
377 IN ULONG ReportLength);
378
379 HIDAPI
380 NTSTATUS
381 NTAPI
382 HidParser_SetScaledUsageValue(
383 IN HIDP_REPORT_TYPE ReportType,
384 IN USAGE UsagePage,
385 IN USHORT LinkCollection OPTIONAL,
386 IN USAGE Usage,
387 IN LONG UsageValue,
388 IN PHIDP_PREPARSED_DATA PreparsedData,
389 IN OUT PCHAR Report,
390 IN ULONG ReportLength);
391
392 HIDAPI
393 NTSTATUS
394 NTAPI
395 HidParser_SetData(
396 IN HIDP_REPORT_TYPE ReportType,
397 IN PHIDP_DATA DataList,
398 IN OUT PULONG DataLength,
399 IN PHIDP_PREPARSED_DATA PreparsedData,
400 IN OUT PCHAR Report,
401 IN ULONG ReportLength);
402
403 HIDAPI
404 ULONG
405 NTAPI
406 HidParser_MaxDataListLength(
407 IN HIDP_REPORT_TYPE ReportType,
408 IN PHIDP_PREPARSED_DATA PreparsedData);
409
410 HIDAPI
411 NTSTATUS
412 NTAPI
413 HidParser_InitializeReportForID(
414 IN HIDP_REPORT_TYPE ReportType,
415 IN UCHAR ReportID,
416 IN PHIDP_PREPARSED_DATA PreparsedData,
417 IN OUT PCHAR Report,
418 IN ULONG ReportLength);
419
420 HIDAPI
421 NTSTATUS
422 NTAPI
423 HidParser_GetValueCaps(
424 HIDP_REPORT_TYPE ReportType,
425 PHIDP_VALUE_CAPS ValueCaps,
426 PULONG ValueCapsLength,
427 PHIDP_PREPARSED_DATA PreparsedData);