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 #define _HIDPI_NO_FUNCTION_MACROS_
21 // function prototypes
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
, ...);
32 typedef long HIDPARSER_STATUS
;
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
;
59 // allocation function
61 PHIDPARSER_ALLOC_FUNCTION Alloc
;
71 PHIDPARSER_ZERO_FUNCTION Zero
;
76 PHIDPARSER_COPY_FUNCTION Copy
;
81 PHIDPARSER_DEBUG_FUNCTION Debug
;
88 }HID_PARSER
, *PHID_PARSER
;
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
);
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
);
111 HidParser_GetCollectionDescription(
112 IN PHID_PARSER Parser
,
113 IN PHIDP_REPORT_DESCRIPTOR ReportDesc
,
115 IN POOL_TYPE PoolType
,
116 OUT PHIDP_DEVICE_DESC DeviceDescription
);
120 HidParser_FreeCollectionDescription(
121 IN PHID_PARSER Parser
,
122 IN PHIDP_DEVICE_DESC DeviceDescription
);
128 IN PHID_PARSER Parser
,
129 OUT PHIDP_CAPS Capabilities
);
134 HidParser_GetSpecificValueCaps(
135 IN PHID_PARSER Parser
,
136 IN HIDP_REPORT_TYPE ReportType
,
138 IN USHORT LinkCollection
,
140 OUT PHIDP_VALUE_CAPS ValueCaps
,
141 IN OUT PULONG ValueCapsLength
);
147 HidParser_GetButtonCaps(
148 IN PHID_PARSER Parser
,
149 HIDP_REPORT_TYPE ReportType
,
150 PHIDP_BUTTON_CAPS ButtonCaps
,
151 PUSHORT ButtonCapsLength
);
156 HidParser_GetSpecificButtonCaps(
157 IN PHID_PARSER Parser
,
158 IN HIDP_REPORT_TYPE ReportType
,
160 IN USHORT LinkCollection
,
162 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
163 IN OUT PULONG ButtonCapsLength
);
168 HidParser_GetScaledUsageValue(
169 IN PHID_PARSER Parser
,
170 IN HIDP_REPORT_TYPE ReportType
,
172 IN USHORT LinkCollection OPTIONAL
,
174 OUT PLONG UsageValue
,
176 IN ULONG ReportLength
);
183 IN HIDP_REPORT_TYPE ReportType
,
184 OUT PHIDP_DATA DataList
,
185 IN OUT PULONG DataLength
,
186 IN PHIDP_PREPARSED_DATA PreparsedData
,
188 IN ULONG ReportLength
);
193 HidParser_GetExtendedAttributes(
194 IN HIDP_REPORT_TYPE ReportType
,
196 IN PHIDP_PREPARSED_DATA PreparsedData
,
197 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
198 IN OUT PULONG LengthAttributes
);
203 HidParser_GetLinkCollectionNodes(
204 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
205 IN OUT PULONG LinkCollectionNodesLength
,
206 IN PHIDP_PREPARSED_DATA PreparsedData
);
211 HidParser_GetUsageValue(
212 IN HIDP_REPORT_TYPE ReportType
,
214 IN USHORT LinkCollection
,
216 OUT PULONG UsageValue
,
217 IN PHIDP_PREPARSED_DATA PreparsedData
,
219 IN ULONG ReportLength
);
224 HidParser_UsageListDifference(
225 IN PUSAGE PreviousUsageList
,
226 IN PUSAGE CurrentUsageList
,
227 OUT PUSAGE BreakUsageList
,
228 OUT PUSAGE MakeUsageList
,
229 IN ULONG UsageListLength
);
235 HidParser_MaxUsageListLength(
236 IN PHID_PARSER Parser
,
237 IN HIDP_REPORT_TYPE ReportType
,
238 IN USAGE UsagePage OPTIONAL
);
244 IN PHID_PARSER Parser
,
245 IN HIDP_REPORT_TYPE ReportType
,
247 IN USHORT LinkCollection OPTIONAL
,
248 OUT USAGE
*UsageList
,
249 IN OUT ULONG
*UsageLength
,
251 IN ULONG ReportLength
);
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
,
263 IN ULONG ReportLength
);
268 HidParser_SysPowerEvent (
270 IN USHORT HidPacketLength
,
271 IN PHIDP_PREPARSED_DATA Ppd
,
272 OUT PULONG OutputBuffer
);
276 HidParser_SysPowerCaps (
277 IN PHIDP_PREPARSED_DATA Ppd
,
278 OUT PULONG OutputBuffer
);
283 HidParser_GetUsageValueArray(
284 IN HIDP_REPORT_TYPE ReportType
,
286 IN USHORT LinkCollection OPTIONAL
,
288 OUT PCHAR UsageValue
,
289 IN USHORT UsageValueByteLength
,
290 IN PHIDP_PREPARSED_DATA PreparsedData
,
292 IN ULONG ReportLength
);
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
);
308 HidParser_UnsetUsages(
309 IN HIDP_REPORT_TYPE ReportType
,
311 IN USHORT LinkCollection
,
313 IN OUT PULONG UsageLength
,
314 IN PHIDP_PREPARSED_DATA PreparsedData
,
316 IN ULONG ReportLength
);
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
);
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
);
344 IN HIDP_REPORT_TYPE ReportType
,
346 IN USHORT LinkCollection
,
348 IN OUT PULONG UsageLength
,
349 IN PHIDP_PREPARSED_DATA PreparsedData
,
351 IN ULONG ReportLength
);
356 HidParser_SetUsageValueArray(
357 IN HIDP_REPORT_TYPE ReportType
,
359 IN USHORT LinkCollection OPTIONAL
,
362 IN USHORT UsageValueByteLength
,
363 IN PHIDP_PREPARSED_DATA PreparsedData
,
365 IN ULONG ReportLength
);
370 HidParser_SetUsageValue(
371 IN HIDP_REPORT_TYPE ReportType
,
373 IN USHORT LinkCollection
,
376 IN PHIDP_PREPARSED_DATA PreparsedData
,
378 IN ULONG ReportLength
);
383 HidParser_SetScaledUsageValue(
384 IN HIDP_REPORT_TYPE ReportType
,
386 IN USHORT LinkCollection OPTIONAL
,
389 IN PHIDP_PREPARSED_DATA PreparsedData
,
391 IN ULONG ReportLength
);
397 IN HIDP_REPORT_TYPE ReportType
,
398 IN PHIDP_DATA DataList
,
399 IN OUT PULONG DataLength
,
400 IN PHIDP_PREPARSED_DATA PreparsedData
,
402 IN ULONG ReportLength
);
407 HidParser_MaxDataListLength(
408 IN HIDP_REPORT_TYPE ReportType
,
409 IN PHIDP_PREPARSED_DATA PreparsedData
);
414 HidParser_InitializeReportForID(
415 IN HIDP_REPORT_TYPE ReportType
,
417 IN PHIDP_PREPARSED_DATA PreparsedData
,
419 IN ULONG ReportLength
);
424 HidParser_GetValueCaps(
425 HIDP_REPORT_TYPE ReportType
,
426 PHIDP_VALUE_CAPS ValueCaps
,
427 PULONG ValueCapsLength
,
428 PHIDP_PREPARSED_DATA PreparsedData
);