2012-01-04 21:58:18 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: lib/drivers/hidparser/hidparser.c
|
|
|
|
* PURPOSE: HID Parser
|
|
|
|
* PROGRAMMERS:
|
|
|
|
* Michael Martin (michael.martin@reactos.org)
|
|
|
|
* Johannes Anderwald (johannes.anderwald@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define _HIDPI_
|
|
|
|
#define _HIDPI_NO_FUNCTION_MACROS_
|
|
|
|
#include <ntddk.h>
|
|
|
|
#include <hidpddi.h>
|
|
|
|
#include <hidpi.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
//
|
|
|
|
// function prototypes
|
|
|
|
//
|
|
|
|
typedef PVOID (NTAPI *PHIDPARSER_ALLOC_FUNCTION)(ULONG Size);
|
|
|
|
typedef VOID (NTAPI *PHIDPARSER_FREE_FUNCTION)(PVOID Item);
|
|
|
|
typedef VOID (NTAPI *PHIDPARSER_ZERO_FUNCTION)(PVOID Item, ULONG Size);
|
|
|
|
typedef VOID (NTAPI *PHIDPARSER_COPY_FUNCTION)(PVOID Target, PVOID Source, ULONG Size);
|
|
|
|
typedef VOID (NTAPI *PHIDPARSER_DEBUG_FUNCTION)(LPCSTR Src, ...);
|
|
|
|
|
|
|
|
//
|
|
|
|
// status code
|
|
|
|
//
|
|
|
|
typedef long HIDPARSER_STATUS;
|
|
|
|
|
|
|
|
//
|
|
|
|
// result codes
|
|
|
|
//
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
HIDPARSER_STATUS_SUCCESS = 0,
|
|
|
|
HIDPARSER_STATUS_INSUFFICIENT_RESOURCES = -1,
|
|
|
|
HIDPARSER_STATUS_NOT_IMPLEMENTED = -2,
|
|
|
|
HIDPARSER_STATUS_REPORT_NOT_FOUND = -3,
|
|
|
|
HIDPARSER_STATUS_COLLECTION_NOT_FOUND = -4,
|
|
|
|
HIDPARSER_STATUS_INVALID_REPORT_LENGTH = -5,
|
|
|
|
HIDPARSER_STATUS_INVALID_REPORT_TYPE = -6,
|
|
|
|
HIDPARSER_STATUS_BUFFER_TOO_SMALL = -7,
|
2012-01-20 21:19:37 +00:00
|
|
|
HIDPARSER_STATUS_USAGE_NOT_FOUND = -8,
|
|
|
|
HIDPARSER_STATUS_I8042_TRANS_UNKNOWN = -9
|
2012-01-04 21:58:18 +00:00
|
|
|
}HIDPARSER_STATUS_CODES;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// size of struct
|
|
|
|
//
|
|
|
|
unsigned long Size;
|
|
|
|
|
|
|
|
//
|
|
|
|
// allocation function
|
|
|
|
//
|
|
|
|
PHIDPARSER_ALLOC_FUNCTION Alloc;
|
|
|
|
|
|
|
|
//
|
|
|
|
// free function
|
|
|
|
//
|
|
|
|
PFREE_FUNCTION Free;
|
|
|
|
|
|
|
|
//
|
|
|
|
// zero function
|
|
|
|
//
|
|
|
|
PHIDPARSER_ZERO_FUNCTION Zero;
|
|
|
|
|
|
|
|
//
|
|
|
|
// copy function
|
|
|
|
//
|
|
|
|
PHIDPARSER_COPY_FUNCTION Copy;
|
|
|
|
|
|
|
|
//
|
|
|
|
// debug function
|
|
|
|
//
|
|
|
|
PHIDPARSER_DEBUG_FUNCTION Debug;
|
|
|
|
|
|
|
|
//
|
|
|
|
// parser context
|
|
|
|
//
|
|
|
|
void * ParserContext;
|
|
|
|
|
|
|
|
}HID_PARSER, *PHID_PARSER;
|
|
|
|
|
|
|
|
HIDPARSER_STATUS
|
|
|
|
HidParser_AllocateParser(
|
|
|
|
IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
|
|
|
|
IN PHIDPARSER_FREE_FUNCTION FreeFunction,
|
|
|
|
IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
|
|
|
|
IN PHIDPARSER_COPY_FUNCTION CopyFunction,
|
|
|
|
IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
|
|
|
|
OUT PHID_PARSER *OutParser);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
HidParser_InitParser(
|
|
|
|
IN PHIDPARSER_ALLOC_FUNCTION AllocFunction,
|
|
|
|
IN PHIDPARSER_FREE_FUNCTION FreeFunction,
|
|
|
|
IN PHIDPARSER_ZERO_FUNCTION ZeroFunction,
|
|
|
|
IN PHIDPARSER_COPY_FUNCTION CopyFunction,
|
|
|
|
IN PHIDPARSER_DEBUG_FUNCTION DebugFunction,
|
|
|
|
IN PVOID ParserContext,
|
|
|
|
OUT PHID_PARSER Parser);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetCollectionDescription(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
|
|
|
|
IN ULONG DescLength,
|
|
|
|
IN POOL_TYPE PoolType,
|
|
|
|
OUT PHIDP_DEVICE_DESC DeviceDescription);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HidParser_FreeCollectionDescription(
|
|
|
|
IN PHID_PARSER Parser,
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHIDP_DEVICE_DESC DeviceDescription);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetCaps(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
OUT PHIDP_CAPS Capabilities);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetSpecificValueCaps(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN USAGE Usage,
|
|
|
|
OUT PHIDP_VALUE_CAPS ValueCaps,
|
|
|
|
IN OUT PULONG ValueCapsLength);
|
|
|
|
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetButtonCaps(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
HIDP_REPORT_TYPE ReportType,
|
|
|
|
PHIDP_BUTTON_CAPS ButtonCaps,
|
|
|
|
PUSHORT ButtonCapsLength);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetSpecificButtonCaps(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN USAGE Usage,
|
|
|
|
OUT PHIDP_BUTTON_CAPS ButtonCaps,
|
|
|
|
IN OUT PULONG ButtonCapsLength);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetScaledUsageValue(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection OPTIONAL,
|
|
|
|
IN USAGE Usage,
|
|
|
|
OUT PLONG UsageValue,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
|
|
|
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetData(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
OUT PHIDP_DATA DataList,
|
|
|
|
IN OUT PULONG DataLength,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetExtendedAttributes(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USHORT DataIndex,
|
|
|
|
OUT PHIDP_EXTENDED_ATTRIBUTES Attributes,
|
|
|
|
IN OUT PULONG LengthAttributes);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetLinkCollectionNodes(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
2012-01-04 21:58:18 +00:00
|
|
|
OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
|
2012-01-30 19:29:26 +00:00
|
|
|
IN OUT PULONG LinkCollectionNodesLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetUsageValue(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN USAGE Usage,
|
|
|
|
OUT PULONG UsageValue,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_UsageListDifference(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PUSAGE PreviousUsageList,
|
|
|
|
IN PUSAGE CurrentUsageList,
|
|
|
|
OUT PUSAGE BreakUsageList,
|
|
|
|
OUT PUSAGE MakeUsageList,
|
|
|
|
IN ULONG UsageListLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
HidParser_MaxUsageListLength(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage OPTIONAL);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetUsages(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection OPTIONAL,
|
|
|
|
OUT USAGE *UsageList,
|
|
|
|
IN OUT ULONG *UsageLength,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetUsagesEx(
|
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
OUT PUSAGE_AND_PAGE ButtonList,
|
|
|
|
IN OUT ULONG *UsageLength,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SysPowerEvent (
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
2012-01-04 21:58:18 +00:00
|
|
|
IN PCHAR HidPacket,
|
|
|
|
IN USHORT HidPacketLength,
|
|
|
|
OUT PULONG OutputBuffer);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SysPowerCaps (
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
2012-01-04 21:58:18 +00:00
|
|
|
OUT PULONG OutputBuffer);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetUsageValueArray(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection OPTIONAL,
|
|
|
|
IN USAGE Usage,
|
|
|
|
OUT PCHAR UsageValue,
|
|
|
|
IN USHORT UsageValueByteLength,
|
|
|
|
IN PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_UsageAndPageListDifference(
|
|
|
|
IN PUSAGE_AND_PAGE PreviousUsageList,
|
|
|
|
IN PUSAGE_AND_PAGE CurrentUsageList,
|
|
|
|
OUT PUSAGE_AND_PAGE BreakUsageList,
|
|
|
|
OUT PUSAGE_AND_PAGE MakeUsageList,
|
|
|
|
IN ULONG UsageListLength);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_UnsetUsages(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN PUSAGE UsageList,
|
|
|
|
IN OUT PULONG UsageLength,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_TranslateUsagesToI8042ScanCodes(
|
|
|
|
IN PUSAGE ChangedUsageList,
|
|
|
|
IN ULONG UsageListLength,
|
|
|
|
IN HIDP_KEYBOARD_DIRECTION KeyAction,
|
|
|
|
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
|
|
|
|
IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
|
|
|
|
IN PVOID InsertCodesContext);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_TranslateUsageAndPagesToI8042ScanCodes(
|
2012-01-21 01:48:30 +00:00
|
|
|
IN PHID_PARSER Parser,
|
2012-01-04 21:58:18 +00:00
|
|
|
IN PUSAGE_AND_PAGE ChangedUsageList,
|
|
|
|
IN ULONG UsageListLength,
|
|
|
|
IN HIDP_KEYBOARD_DIRECTION KeyAction,
|
|
|
|
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
|
|
|
|
IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
|
|
|
|
IN PVOID InsertCodesContext);
|
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SetUsages(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN PUSAGE UsageList,
|
|
|
|
IN OUT PULONG UsageLength,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SetUsageValueArray(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection OPTIONAL,
|
|
|
|
IN USAGE Usage,
|
|
|
|
IN PCHAR UsageValue,
|
|
|
|
IN USHORT UsageValueByteLength,
|
|
|
|
OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SetUsageValue(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection,
|
|
|
|
IN USAGE Usage,
|
|
|
|
IN ULONG UsageValue,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SetScaledUsageValue(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN USAGE UsagePage,
|
|
|
|
IN USHORT LinkCollection OPTIONAL,
|
|
|
|
IN USAGE Usage,
|
|
|
|
IN LONG UsageValue,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_SetData(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN PHIDP_DATA DataList,
|
|
|
|
IN OUT PULONG DataLength,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
HidParser_MaxDataListLength(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType);
|
2012-01-04 21:58:18 +00:00
|
|
|
|
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_InitializeReportForID(
|
2012-01-30 19:29:26 +00:00
|
|
|
IN PHID_PARSER Parser,
|
|
|
|
IN HIDP_REPORT_TYPE ReportType,
|
|
|
|
IN UCHAR ReportID,
|
|
|
|
IN OUT PCHAR Report,
|
|
|
|
IN ULONG ReportLength);
|
2012-01-21 01:48:30 +00:00
|
|
|
|
|
|
|
HIDPARSER_STATUS
|
|
|
|
HidParser_TranslateUsage(
|
|
|
|
IN PHID_PARSER Parser,
|
2012-01-30 19:29:26 +00:00
|
|
|
IN ULONG CollectionNumber,
|
2012-01-21 01:48:30 +00:00
|
|
|
IN USAGE Usage,
|
|
|
|
IN HIDP_KEYBOARD_DIRECTION KeyAction,
|
|
|
|
IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
|
|
|
|
IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
|
|
|
|
IN PVOID InsertCodesContext);
|
|
|
|
|
2012-01-04 21:58:18 +00:00
|
|
|
HIDAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HidParser_GetValueCaps(
|
2012-01-30 19:29:26 +00:00
|
|
|
PHID_PARSER Parser,
|
|
|
|
HIDP_REPORT_TYPE ReportType,
|
|
|
|
PHIDP_VALUE_CAPS ValueCaps,
|
|
|
|
PULONG ValueCapsLength);
|