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
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
14 // function prototypes
16 typedef PVOID (NTAPI
*PHIDPARSER_ALLOC_FUNCTION
)(ULONG Size
);
17 typedef VOID (NTAPI
*PHIDPARSER_FREE_FUNCTION
)(PVOID Item
);
18 typedef VOID (NTAPI
*PHIDPARSER_ZERO_FUNCTION
)(PVOID Item
, ULONG Size
);
19 typedef VOID (NTAPI
*PHIDPARSER_COPY_FUNCTION
)(PVOID Target
, PVOID Source
, ULONG Size
);
20 typedef VOID (__cdecl
*PHIDPARSER_DEBUG_FUNCTION
)(LPCSTR Src
, ...);
25 typedef long HIDPARSER_STATUS
;
32 HIDPARSER_STATUS_SUCCESS
= 0,
33 HIDPARSER_STATUS_INSUFFICIENT_RESOURCES
= -1,
34 HIDPARSER_STATUS_NOT_IMPLEMENTED
= -2,
35 HIDPARSER_STATUS_REPORT_NOT_FOUND
= -3,
36 HIDPARSER_STATUS_COLLECTION_NOT_FOUND
= -4,
37 HIDPARSER_STATUS_INVALID_REPORT_LENGTH
= -5,
38 HIDPARSER_STATUS_INVALID_REPORT_TYPE
= -6,
39 HIDPARSER_STATUS_BUFFER_TOO_SMALL
= -7,
40 HIDPARSER_STATUS_USAGE_NOT_FOUND
= -8,
41 HIDPARSER_STATUS_I8042_TRANS_UNKNOWN
= -9,
42 HIDPARSER_STATUS_BAD_LOG_PHY_VALUES
= -10
43 }HIDPARSER_STATUS_CODES
;
53 // allocation function
55 PHIDPARSER_ALLOC_FUNCTION Alloc
;
60 PHIDPARSER_FREE_FUNCTION Free
;
65 PHIDPARSER_ZERO_FUNCTION Zero
;
70 PHIDPARSER_COPY_FUNCTION Copy
;
75 PHIDPARSER_DEBUG_FUNCTION Debug
;
76 }HID_PARSER
, *PHID_PARSER
;
80 IN PHIDPARSER_ALLOC_FUNCTION AllocFunction
,
81 IN PHIDPARSER_FREE_FUNCTION FreeFunction
,
82 IN PHIDPARSER_ZERO_FUNCTION ZeroFunction
,
83 IN PHIDPARSER_COPY_FUNCTION CopyFunction
,
84 IN PHIDPARSER_DEBUG_FUNCTION DebugFunction
,
85 OUT PHID_PARSER Parser
);
89 HidParser_GetCollectionDescription(
90 IN PHID_PARSER Parser
,
91 IN PHIDP_REPORT_DESCRIPTOR ReportDesc
,
93 IN POOL_TYPE PoolType
,
94 OUT PHIDP_DEVICE_DESC DeviceDescription
);
98 HidParser_FreeCollectionDescription(
99 IN PHID_PARSER Parser
,
100 IN PHIDP_DEVICE_DESC DeviceDescription
);
106 IN PHID_PARSER Parser
,
107 IN PVOID CollectionContext
,
108 OUT PHIDP_CAPS Capabilities
);
113 HidParser_GetSpecificValueCaps(
114 IN PHID_PARSER Parser
,
115 IN PVOID CollectionContext
,
116 IN HIDP_REPORT_TYPE ReportType
,
118 IN USHORT LinkCollection
,
120 OUT PHIDP_VALUE_CAPS ValueCaps
,
121 IN OUT PUSHORT ValueCapsLength
);
127 HidParser_GetButtonCaps(
128 IN PHID_PARSER Parser
,
129 IN PVOID CollectionContext
,
130 HIDP_REPORT_TYPE ReportType
,
131 PHIDP_BUTTON_CAPS ButtonCaps
,
132 PUSHORT ButtonCapsLength
);
137 HidParser_GetSpecificButtonCaps(
138 IN PHID_PARSER Parser
,
139 IN PVOID CollectionContext
,
140 IN HIDP_REPORT_TYPE ReportType
,
142 IN USHORT LinkCollection
,
144 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
145 IN OUT PULONG ButtonCapsLength
);
150 HidParser_GetScaledUsageValue(
151 IN PHID_PARSER Parser
,
152 IN PVOID CollectionContext
,
153 IN HIDP_REPORT_TYPE ReportType
,
155 IN USHORT LinkCollection OPTIONAL
,
157 OUT PLONG UsageValue
,
159 IN ULONG ReportLength
);
166 IN PHID_PARSER Parser
,
167 IN PVOID CollectionContext
,
168 IN HIDP_REPORT_TYPE ReportType
,
169 OUT PHIDP_DATA DataList
,
170 IN OUT PULONG DataLength
,
172 IN ULONG ReportLength
);
177 HidParser_GetExtendedAttributes(
178 IN PHID_PARSER Parser
,
179 IN PVOID CollectionContext
,
180 IN HIDP_REPORT_TYPE ReportType
,
182 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
183 IN OUT PULONG LengthAttributes
);
188 HidParser_GetLinkCollectionNodes(
189 IN PHID_PARSER Parser
,
190 IN PVOID CollectionContext
,
191 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
192 IN OUT PULONG LinkCollectionNodesLength
);
198 HidParser_GetUsageValue(
199 IN PHID_PARSER Parser
,
200 IN PVOID CollectionContext
,
201 IN HIDP_REPORT_TYPE ReportType
,
203 IN USHORT LinkCollection
,
205 OUT PULONG UsageValue
,
207 IN ULONG ReportLength
);
212 HidParser_UsageListDifference(
213 IN PUSAGE PreviousUsageList
,
214 IN PUSAGE CurrentUsageList
,
215 OUT PUSAGE BreakUsageList
,
216 OUT PUSAGE MakeUsageList
,
217 IN ULONG UsageListLength
);
223 HidParser_MaxUsageListLength(
224 IN PHID_PARSER Parser
,
225 IN PVOID CollectionContext
,
226 IN HIDP_REPORT_TYPE ReportType
,
227 IN USAGE UsagePage OPTIONAL
);
233 IN PHID_PARSER Parser
,
234 IN PVOID CollectionContext
,
235 IN HIDP_REPORT_TYPE ReportType
,
237 IN USHORT LinkCollection OPTIONAL
,
238 OUT USAGE
*UsageList
,
239 IN OUT ULONG
*UsageLength
,
241 IN ULONG ReportLength
);
246 HidParser_GetUsagesEx(
247 IN PHID_PARSER Parser
,
248 IN PVOID CollectionContext
,
249 IN HIDP_REPORT_TYPE ReportType
,
250 IN USHORT LinkCollection
,
251 OUT PUSAGE_AND_PAGE ButtonList
,
252 IN OUT ULONG
*UsageLength
,
254 IN ULONG ReportLength
);
259 HidParser_SysPowerEvent (
260 IN PHID_PARSER Parser
,
261 IN PVOID CollectionContext
,
263 IN USHORT HidPacketLength
,
264 OUT PULONG OutputBuffer
);
268 HidParser_SysPowerCaps (
269 IN PHID_PARSER Parser
,
270 IN PVOID CollectionContext
,
271 OUT PULONG OutputBuffer
);
276 HidParser_GetUsageValueArray(
277 IN PHID_PARSER Parser
,
278 IN PVOID CollectionContext
,
279 IN HIDP_REPORT_TYPE ReportType
,
281 IN USHORT LinkCollection OPTIONAL
,
283 OUT PCHAR UsageValue
,
284 IN USHORT UsageValueByteLength
,
286 IN ULONG ReportLength
);
292 HidParser_UsageAndPageListDifference(
293 IN PUSAGE_AND_PAGE PreviousUsageList
,
294 IN PUSAGE_AND_PAGE CurrentUsageList
,
295 OUT PUSAGE_AND_PAGE BreakUsageList
,
296 OUT PUSAGE_AND_PAGE MakeUsageList
,
297 IN ULONG UsageListLength
);
302 HidParser_UnsetUsages(
303 IN PHID_PARSER Parser
,
304 IN PVOID CollectionContext
,
305 IN HIDP_REPORT_TYPE ReportType
,
307 IN USHORT LinkCollection
,
309 IN OUT PULONG UsageLength
,
311 IN ULONG ReportLength
);
316 HidParser_TranslateUsagesToI8042ScanCodes(
317 IN PUSAGE ChangedUsageList
,
318 IN ULONG UsageListLength
,
319 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
320 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
321 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
322 IN PVOID InsertCodesContext
);
327 HidParser_TranslateUsageAndPagesToI8042ScanCodes(
328 IN PHID_PARSER Parser
,
329 IN PUSAGE_AND_PAGE ChangedUsageList
,
330 IN ULONG UsageListLength
,
331 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
332 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
333 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
334 IN PVOID InsertCodesContext
);
340 IN PHID_PARSER Parser
,
341 IN PVOID CollectionContext
,
342 IN HIDP_REPORT_TYPE ReportType
,
344 IN USHORT LinkCollection
,
346 IN OUT PULONG UsageLength
,
348 IN ULONG ReportLength
);
353 HidParser_SetUsageValueArray(
354 IN PHID_PARSER Parser
,
355 IN PVOID CollectionContext
,
356 IN HIDP_REPORT_TYPE ReportType
,
358 IN USHORT LinkCollection OPTIONAL
,
361 IN USHORT UsageValueByteLength
,
363 IN ULONG ReportLength
);
368 HidParser_SetUsageValue(
369 IN PHID_PARSER Parser
,
370 IN PVOID CollectionContext
,
371 IN HIDP_REPORT_TYPE ReportType
,
373 IN USHORT LinkCollection
,
377 IN ULONG ReportLength
);
382 HidParser_SetScaledUsageValue(
383 IN PHID_PARSER Parser
,
384 IN PVOID CollectionContext
,
385 IN HIDP_REPORT_TYPE ReportType
,
387 IN USHORT LinkCollection OPTIONAL
,
391 IN ULONG ReportLength
);
397 IN PHID_PARSER Parser
,
398 IN PVOID CollectionContext
,
399 IN HIDP_REPORT_TYPE ReportType
,
400 IN PHIDP_DATA DataList
,
401 IN OUT PULONG DataLength
,
403 IN ULONG ReportLength
);
408 HidParser_MaxDataListLength(
409 IN PHID_PARSER Parser
,
410 IN PVOID CollectionContext
,
411 IN HIDP_REPORT_TYPE ReportType
);
416 HidParser_InitializeReportForID(
417 IN PHID_PARSER Parser
,
418 IN PVOID CollectionContext
,
419 IN HIDP_REPORT_TYPE ReportType
,
422 IN ULONG ReportLength
);
425 HidParser_TranslateKbdUsage(
426 IN PHID_PARSER Parser
,
428 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
429 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
430 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
431 IN PVOID InsertCodesContext
);
434 HidParser_TranslateCustUsage(
435 IN PHID_PARSER Parser
,
437 IN HIDP_KEYBOARD_DIRECTION KeyAction
,
438 IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState
,
439 IN PHIDP_INSERT_SCANCODES InsertCodesProcedure
,
440 IN PVOID InsertCodesContext
);
445 HidParser_GetValueCaps(
447 IN PVOID CollectionContext
,
448 HIDP_REPORT_TYPE ReportType
,
449 PHIDP_VALUE_CAPS ValueCaps
,
450 PULONG ValueCapsLength
);