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