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_CODES
;
58 // allocation function
60 PHIDPARSER_ALLOC_FUNCTION Alloc
;
70 PHIDPARSER_ZERO_FUNCTION Zero
;
75 PHIDPARSER_COPY_FUNCTION Copy
;
80 PHIDPARSER_DEBUG_FUNCTION Debug
;
87 }HID_PARSER
, *PHID_PARSER
;
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
);
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
);
110 HidParser_GetCollectionDescription(
111 IN PHID_PARSER Parser
,
112 IN PHIDP_REPORT_DESCRIPTOR ReportDesc
,
114 IN POOL_TYPE PoolType
,
115 OUT PHIDP_DEVICE_DESC DeviceDescription
);
119 HidParser_FreeCollectionDescription(
120 IN PHID_PARSER Parser
,
121 IN PHIDP_DEVICE_DESC DeviceDescription
);
127 IN PHID_PARSER Parser
,
128 OUT PHIDP_CAPS Capabilities
);
133 HidParser_GetSpecificValueCaps(
134 IN PHID_PARSER Parser
,
135 IN HIDP_REPORT_TYPE ReportType
,
137 IN USHORT LinkCollection
,
139 OUT PHIDP_VALUE_CAPS ValueCaps
,
140 IN OUT PULONG ValueCapsLength
);
146 HidParser_GetButtonCaps(
147 IN PHID_PARSER Parser
,
148 HIDP_REPORT_TYPE ReportType
,
149 PHIDP_BUTTON_CAPS ButtonCaps
,
150 PUSHORT ButtonCapsLength
);
155 HidParser_GetSpecificButtonCaps(
156 IN PHID_PARSER Parser
,
157 IN HIDP_REPORT_TYPE ReportType
,
159 IN USHORT LinkCollection
,
161 OUT PHIDP_BUTTON_CAPS ButtonCaps
,
162 IN OUT PULONG ButtonCapsLength
);
167 HidParser_GetScaledUsageValue(
168 IN PHID_PARSER Parser
,
169 IN HIDP_REPORT_TYPE ReportType
,
171 IN USHORT LinkCollection OPTIONAL
,
173 OUT PLONG UsageValue
,
175 IN ULONG ReportLength
);
182 IN HIDP_REPORT_TYPE ReportType
,
183 OUT PHIDP_DATA DataList
,
184 IN OUT PULONG DataLength
,
185 IN PHIDP_PREPARSED_DATA PreparsedData
,
187 IN ULONG ReportLength
);
192 HidParser_GetExtendedAttributes(
193 IN HIDP_REPORT_TYPE ReportType
,
195 IN PHIDP_PREPARSED_DATA PreparsedData
,
196 OUT PHIDP_EXTENDED_ATTRIBUTES Attributes
,
197 IN OUT PULONG LengthAttributes
);
202 HidParser_GetLinkCollectionNodes(
203 OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes
,
204 IN OUT PULONG LinkCollectionNodesLength
,
205 IN PHIDP_PREPARSED_DATA PreparsedData
);
210 HidParser_GetUsageValue(
211 IN HIDP_REPORT_TYPE ReportType
,
213 IN USHORT LinkCollection
,
215 OUT PULONG UsageValue
,
216 IN PHIDP_PREPARSED_DATA PreparsedData
,
218 IN ULONG ReportLength
);
223 HidParser_UsageListDifference(
224 IN PUSAGE PreviousUsageList
,
225 IN PUSAGE CurrentUsageList
,
226 OUT PUSAGE BreakUsageList
,
227 OUT PUSAGE MakeUsageList
,
228 IN ULONG UsageListLength
);
234 HidParser_MaxUsageListLength(
235 IN PHID_PARSER Parser
,
236 IN HIDP_REPORT_TYPE ReportType
,
237 IN USAGE UsagePage OPTIONAL
);
243 IN PHID_PARSER Parser
,
244 IN HIDP_REPORT_TYPE ReportType
,
246 IN USHORT LinkCollection OPTIONAL
,
247 OUT USAGE
*UsageList
,
248 IN OUT ULONG
*UsageLength
,
250 IN ULONG ReportLength
);
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
,
262 IN ULONG ReportLength
);
267 HidParser_SysPowerEvent (
269 IN USHORT HidPacketLength
,
270 IN PHIDP_PREPARSED_DATA Ppd
,
271 OUT PULONG OutputBuffer
);
275 HidParser_SysPowerCaps (
276 IN PHIDP_PREPARSED_DATA Ppd
,
277 OUT PULONG OutputBuffer
);
282 HidParser_GetUsageValueArray(
283 IN HIDP_REPORT_TYPE ReportType
,
285 IN USHORT LinkCollection OPTIONAL
,
287 OUT PCHAR UsageValue
,
288 IN USHORT UsageValueByteLength
,
289 IN PHIDP_PREPARSED_DATA PreparsedData
,
291 IN ULONG ReportLength
);
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
);
307 HidParser_UnsetUsages(
308 IN HIDP_REPORT_TYPE ReportType
,
310 IN USHORT LinkCollection
,
312 IN OUT PULONG UsageLength
,
313 IN PHIDP_PREPARSED_DATA PreparsedData
,
315 IN ULONG ReportLength
);
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
);
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
);
343 IN HIDP_REPORT_TYPE ReportType
,
345 IN USHORT LinkCollection
,
347 IN OUT PULONG UsageLength
,
348 IN PHIDP_PREPARSED_DATA PreparsedData
,
350 IN ULONG ReportLength
);
355 HidParser_SetUsageValueArray(
356 IN HIDP_REPORT_TYPE ReportType
,
358 IN USHORT LinkCollection OPTIONAL
,
361 IN USHORT UsageValueByteLength
,
362 IN PHIDP_PREPARSED_DATA PreparsedData
,
364 IN ULONG ReportLength
);
369 HidParser_SetUsageValue(
370 IN HIDP_REPORT_TYPE ReportType
,
372 IN USHORT LinkCollection
,
375 IN PHIDP_PREPARSED_DATA PreparsedData
,
377 IN ULONG ReportLength
);
382 HidParser_SetScaledUsageValue(
383 IN HIDP_REPORT_TYPE ReportType
,
385 IN USHORT LinkCollection OPTIONAL
,
388 IN PHIDP_PREPARSED_DATA PreparsedData
,
390 IN ULONG ReportLength
);
396 IN HIDP_REPORT_TYPE ReportType
,
397 IN PHIDP_DATA DataList
,
398 IN OUT PULONG DataLength
,
399 IN PHIDP_PREPARSED_DATA PreparsedData
,
401 IN ULONG ReportLength
);
406 HidParser_MaxDataListLength(
407 IN HIDP_REPORT_TYPE ReportType
,
408 IN PHIDP_PREPARSED_DATA PreparsedData
);
413 HidParser_InitializeReportForID(
414 IN HIDP_REPORT_TYPE ReportType
,
416 IN PHIDP_PREPARSED_DATA PreparsedData
,
418 IN ULONG ReportLength
);
423 HidParser_GetValueCaps(
424 HIDP_REPORT_TYPE ReportType
,
425 PHIDP_VALUE_CAPS ValueCaps
,
426 PULONG ValueCapsLength
,
427 PHIDP_PREPARSED_DATA PreparsedData
);