104ceeeb3b6fa97efd1e42f933b1c20ea2890496
[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 PUSAGE_AND_PAGE ChangedUsageList,
334 IN ULONG UsageListLength,
335 IN HIDP_KEYBOARD_DIRECTION KeyAction,
336 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
337 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
338 IN PVOID InsertCodesContext);
339
340 HIDAPI
341 NTSTATUS
342 NTAPI
343 HidParser_SetUsages(
344 IN HIDP_REPORT_TYPE ReportType,
345 IN USAGE UsagePage,
346 IN USHORT LinkCollection,
347 IN PUSAGE UsageList,
348 IN OUT PULONG UsageLength,
349 IN PHIDP_PREPARSED_DATA PreparsedData,
350 IN OUT PCHAR Report,
351 IN ULONG ReportLength);
352
353 HIDAPI
354 NTSTATUS
355 NTAPI
356 HidParser_SetUsageValueArray(
357 IN HIDP_REPORT_TYPE ReportType,
358 IN USAGE UsagePage,
359 IN USHORT LinkCollection OPTIONAL,
360 IN USAGE Usage,
361 IN PCHAR UsageValue,
362 IN USHORT UsageValueByteLength,
363 IN PHIDP_PREPARSED_DATA PreparsedData,
364 OUT PCHAR Report,
365 IN ULONG ReportLength);
366
367 HIDAPI
368 NTSTATUS
369 NTAPI
370 HidParser_SetUsageValue(
371 IN HIDP_REPORT_TYPE ReportType,
372 IN USAGE UsagePage,
373 IN USHORT LinkCollection,
374 IN USAGE Usage,
375 IN ULONG UsageValue,
376 IN PHIDP_PREPARSED_DATA PreparsedData,
377 IN OUT PCHAR Report,
378 IN ULONG ReportLength);
379
380 HIDAPI
381 NTSTATUS
382 NTAPI
383 HidParser_SetScaledUsageValue(
384 IN HIDP_REPORT_TYPE ReportType,
385 IN USAGE UsagePage,
386 IN USHORT LinkCollection OPTIONAL,
387 IN USAGE Usage,
388 IN LONG UsageValue,
389 IN PHIDP_PREPARSED_DATA PreparsedData,
390 IN OUT PCHAR Report,
391 IN ULONG ReportLength);
392
393 HIDAPI
394 NTSTATUS
395 NTAPI
396 HidParser_SetData(
397 IN HIDP_REPORT_TYPE ReportType,
398 IN PHIDP_DATA DataList,
399 IN OUT PULONG DataLength,
400 IN PHIDP_PREPARSED_DATA PreparsedData,
401 IN OUT PCHAR Report,
402 IN ULONG ReportLength);
403
404 HIDAPI
405 ULONG
406 NTAPI
407 HidParser_MaxDataListLength(
408 IN HIDP_REPORT_TYPE ReportType,
409 IN PHIDP_PREPARSED_DATA PreparsedData);
410
411 HIDAPI
412 NTSTATUS
413 NTAPI
414 HidParser_InitializeReportForID(
415 IN HIDP_REPORT_TYPE ReportType,
416 IN UCHAR ReportID,
417 IN PHIDP_PREPARSED_DATA PreparsedData,
418 IN OUT PCHAR Report,
419 IN ULONG ReportLength);
420
421 HIDAPI
422 NTSTATUS
423 NTAPI
424 HidParser_GetValueCaps(
425 HIDP_REPORT_TYPE ReportType,
426 PHIDP_VALUE_CAPS ValueCaps,
427 PULONG ValueCapsLength,
428 PHIDP_PREPARSED_DATA PreparsedData);