From 2978d4b61b206eee4dc6c2e46dca92e4bcce3e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 27 Apr 2019 11:19:46 +0200 Subject: [PATCH] [HIDPARSE/HIDPARSER] Move HidP_* functions from hidparse.sys to hidparser library Interface between both is not anymore the HidParser_* functions, but the HidP_* functions and the AllocFunction/FreeFunction/DebugFunctions/ ZeroFunction/CopyFunction. --- drivers/hid/hidparse/CMakeLists.txt | 2 +- drivers/hid/hidparse/hidparse.c | 588 +--------------------- drivers/hid/hidparse/hidparse.h | 1 - sdk/lib/drivers/hidparser/CMakeLists.txt | 11 +- sdk/lib/drivers/hidparser/hidp.c | 596 +++++++++++++++++++++++ sdk/lib/drivers/hidparser/hidp.h | 6 + sdk/lib/drivers/hidparser/hidparser.h | 2 +- 7 files changed, 612 insertions(+), 594 deletions(-) create mode 100644 sdk/lib/drivers/hidparser/hidp.c create mode 100644 sdk/lib/drivers/hidparser/hidp.h diff --git a/drivers/hid/hidparse/CMakeLists.txt b/drivers/hid/hidparse/CMakeLists.txt index 57cabdbb3ca..af02183db0c 100644 --- a/drivers/hid/hidparse/CMakeLists.txt +++ b/drivers/hid/hidparse/CMakeLists.txt @@ -10,5 +10,5 @@ include_directories( add_library(hidparse MODULE hidparse.c hidparse.rc ${CMAKE_CURRENT_BINARY_DIR}/hidparse.def) set_module_type(hidparse kernelmodedriver) add_importlibs(hidparse ntoskrnl) -target_link_libraries(hidparse hidparser) +target_link_libraries(hidparse hidparser_km) add_cd_file(TARGET hidparse DESTINATION reactos/system32/drivers NO_CAB FOR all) diff --git a/drivers/hid/hidparse/hidparse.c b/drivers/hid/hidparse/hidparse.c index bc8e8566054..cdfbb1ed835 100644 --- a/drivers/hid/hidparse/hidparse.c +++ b/drivers/hid/hidparse/hidparse.c @@ -9,6 +9,7 @@ */ #include "hidparse.h" +#include "hidp.h" #define NDEBUG #include @@ -86,593 +87,6 @@ DebugFunction( #endif } -VOID -NTAPI -HidP_FreeCollectionDescription( - IN PHIDP_DEVICE_DESC DeviceDescription) -{ - HID_PARSER Parser; - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // free collection - // - HidParser_FreeCollectionDescription(&Parser, DeviceDescription); -} - - -HIDAPI -NTSTATUS -NTAPI -HidP_GetCaps( - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PHIDP_CAPS Capabilities) -{ - HID_PARSER Parser; - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get caps - // - return HidParser_GetCaps(&Parser, PreparsedData, Capabilities); -} - -NTSTATUS -TranslateStatusForUpperLayer( - IN HIDPARSER_STATUS Status) -{ - // - // now we are handling only this values, for others just return - // status as it is. - // - switch (Status) - { - case HIDPARSER_STATUS_INSUFFICIENT_RESOURCES: - return STATUS_INSUFFICIENT_RESOURCES; - case HIDPARSER_STATUS_INVALID_REPORT_TYPE: - return HIDP_STATUS_INVALID_REPORT_TYPE; - case HIDPARSER_STATUS_BUFFER_TOO_SMALL: - return STATUS_BUFFER_TOO_SMALL; - case HIDPARSER_STATUS_COLLECTION_NOT_FOUND: - return STATUS_NO_DATA_DETECTED; - default: - return Status; - } -} - -NTSTATUS -NTAPI -HidP_GetCollectionDescription( - IN PHIDP_REPORT_DESCRIPTOR ReportDesc, - IN ULONG DescLength, - IN POOL_TYPE PoolType, - OUT PHIDP_DEVICE_DESC DeviceDescription) -{ - HID_PARSER Parser; - NTSTATUS Status; - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get description; - // - Status = HidParser_GetCollectionDescription(&Parser, ReportDesc, DescLength, PoolType, DeviceDescription); - return TranslateStatusForUpperLayer(Status); -} - -HIDAPI -ULONG -NTAPI -HidP_MaxUsageListLength( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage OPTIONAL, - IN PHIDP_PREPARSED_DATA PreparsedData) -{ - HID_PARSER Parser; - - // - // sanity check - // - ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - - // - // get usage length - // - return HidParser_MaxUsageListLength(&Parser, PreparsedData, ReportType, UsagePage); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetSpecificValueCaps( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - OUT PHIDP_VALUE_CAPS ValueCaps, - IN OUT PUSHORT ValueCapsLength, - IN PHIDP_PREPARSED_DATA PreparsedData) -{ - HID_PARSER Parser; - - // - // sanity check - // - ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get value caps - // - return HidParser_GetSpecificValueCaps(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, ValueCaps, ValueCapsLength); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - OUT PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - HID_PARSER Parser; - - // - // sanity check - // - ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get usages - // - return HidParser_GetUsages(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, UsageList, UsageLength, Report, ReportLength); -} - - -#undef HidP_GetButtonCaps - -HIDAPI -NTSTATUS -NTAPI -HidP_UsageListDifference( - IN PUSAGE PreviousUsageList, - IN PUSAGE CurrentUsageList, - OUT PUSAGE BreakUsageList, - OUT PUSAGE MakeUsageList, - IN ULONG UsageListLength) -{ - return HidParser_UsageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetUsagesEx( - IN HIDP_REPORT_TYPE ReportType, - IN USHORT LinkCollection, - OUT PUSAGE_AND_PAGE ButtonList, - IN OUT ULONG *UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - return HidP_GetUsages(ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, &ButtonList->Usage, UsageLength, PreparsedData, Report, ReportLength); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_UsageAndPageListDifference( - IN PUSAGE_AND_PAGE PreviousUsageList, - IN PUSAGE_AND_PAGE CurrentUsageList, - OUT PUSAGE_AND_PAGE BreakUsageList, - OUT PUSAGE_AND_PAGE MakeUsageList, - IN ULONG UsageListLength) -{ - return HidParser_UsageAndPageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetScaledUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - OUT PLONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - HID_PARSER Parser; - - // - // sanity check - // - ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get scaled usage value - // - return HidParser_GetScaledUsageValue(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - OUT PULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - HID_PARSER Parser; - - // - // sanity check - // - ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // get scaled usage value - // - return HidParser_GetUsageValue(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); -} - - -HIDAPI -NTSTATUS -NTAPI -HidP_TranslateUsageAndPagesToI8042ScanCodes( - 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) -{ - HID_PARSER Parser; - - // - // init parser - // - HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); - - // - // translate usage pages - // - return HidParser_TranslateUsageAndPagesToI8042ScanCodes(&Parser, ChangedUsageList, UsageListLength, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetButtonCaps( - HIDP_REPORT_TYPE ReportType, - PHIDP_BUTTON_CAPS ButtonCaps, - PUSHORT ButtonCapsLength, - PHIDP_PREPARSED_DATA PreparsedData) -{ - return HidP_GetSpecificButtonCaps(ReportType, HID_USAGE_PAGE_UNDEFINED, 0, 0, ButtonCaps, ButtonCapsLength, PreparsedData); -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetSpecificButtonCaps( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - OUT PHIDP_BUTTON_CAPS ButtonCaps, - IN OUT PUSHORT ButtonCapsLength, - IN PHIDP_PREPARSED_DATA PreparsedData) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetData( - IN HIDP_REPORT_TYPE ReportType, - OUT PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetExtendedAttributes( - IN HIDP_REPORT_TYPE ReportType, - IN USHORT DataIndex, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, - IN OUT PULONG LengthAttributes) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetLinkCollectionNodes( - OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, - IN OUT PULONG LinkCollectionNodesLength, - IN PHIDP_PREPARSED_DATA PreparsedData) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -NTAPI -HidP_SysPowerEvent( - IN PCHAR HidPacket, - IN USHORT HidPacketLength, - IN PHIDP_PREPARSED_DATA Ppd, - OUT PULONG OutputBuffer) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -NTAPI -HidP_SysPowerCaps( - IN PHIDP_PREPARSED_DATA Ppd, - OUT PULONG OutputBuffer) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_GetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - OUT PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - - -HIDAPI -NTSTATUS -NTAPI -HidP_UnsetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_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) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_SetUsages( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN PUSAGE UsageList, - IN OUT PULONG UsageLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_SetUsageValueArray( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN PCHAR UsageValue, - IN USHORT UsageValueByteLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_SetUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection, - IN USAGE Usage, - IN ULONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_SetScaledUsageValue( - IN HIDP_REPORT_TYPE ReportType, - IN USAGE UsagePage, - IN USHORT LinkCollection OPTIONAL, - IN USAGE Usage, - IN LONG UsageValue, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_SetData( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_DATA DataList, - IN OUT PULONG DataLength, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -ULONG -NTAPI -HidP_MaxDataListLength( - IN HIDP_REPORT_TYPE ReportType, - IN PHIDP_PREPARSED_DATA PreparsedData) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -HIDAPI -NTSTATUS -NTAPI -HidP_InitializeReportForID( - IN HIDP_REPORT_TYPE ReportType, - IN UCHAR ReportID, - IN PHIDP_PREPARSED_DATA PreparsedData, - IN OUT PCHAR Report, - IN ULONG ReportLength) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - -#undef HidP_GetValueCaps - -HIDAPI -NTSTATUS -NTAPI -HidP_GetValueCaps( - HIDP_REPORT_TYPE ReportType, - PHIDP_VALUE_CAPS ValueCaps, - PUSHORT ValueCapsLength, - PHIDP_PREPARSED_DATA PreparsedData) -{ - UNIMPLEMENTED; - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; -} - NTSTATUS NTAPI DriverEntry( diff --git a/drivers/hid/hidparse/hidparse.h b/drivers/hid/hidparse/hidparse.h index c3602a33000..3ee1ba54e15 100644 --- a/drivers/hid/hidparse/hidparse.h +++ b/drivers/hid/hidparse/hidparse.h @@ -5,7 +5,6 @@ #include #include #include -#include "hidparser.h" #include #define HIDPARSE_TAG 'PdiH' diff --git a/sdk/lib/drivers/hidparser/CMakeLists.txt b/sdk/lib/drivers/hidparser/CMakeLists.txt index 1becfe528dc..ba03f996e52 100644 --- a/sdk/lib/drivers/hidparser/CMakeLists.txt +++ b/sdk/lib/drivers/hidparser/CMakeLists.txt @@ -6,8 +6,11 @@ list(APPEND SOURCE hidparser.c parser.c api.c - parser.h) + parser.h + hidp.c + hidp.h) -add_library(hidparser ${SOURCE}) -add_dependencies(hidparser bugcodes xdk) -add_pch(hidparser parser.h SOURCE) +add_library(hidparser_km ${SOURCE}) +add_importlibs(hidparser_km ntoskrnl) +add_dependencies(hidparser_km bugcodes xdk) +add_pch(hidparser_km parser.h SOURCE) diff --git a/sdk/lib/drivers/hidparser/hidp.c b/sdk/lib/drivers/hidparser/hidp.c new file mode 100644 index 00000000000..b179b1f1408 --- /dev/null +++ b/sdk/lib/drivers/hidparser/hidp.c @@ -0,0 +1,596 @@ +#define _HIDPI_ +#define _HIDPI_NO_FUNCTION_MACROS_ +#include +#include + +#include "hidparser.h" +#include "hidp.h" + +#define UNIMPLEMENTED DebugFunction("%s is UNIMPLEMENTED\n", __FUNCTION__) + +VOID +NTAPI +HidP_FreeCollectionDescription( + IN PHIDP_DEVICE_DESC DeviceDescription) +{ + HID_PARSER Parser; + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // free collection + // + HidParser_FreeCollectionDescription(&Parser, DeviceDescription); +} + + +HIDAPI +NTSTATUS +NTAPI +HidP_GetCaps( + IN PHIDP_PREPARSED_DATA PreparsedData, + OUT PHIDP_CAPS Capabilities) +{ + HID_PARSER Parser; + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get caps + // + return HidParser_GetCaps(&Parser, PreparsedData, Capabilities); +} + +NTSTATUS +TranslateStatusForUpperLayer( + IN HIDPARSER_STATUS Status) +{ + // + // now we are handling only this values, for others just return + // status as it is. + // + switch (Status) + { + case HIDPARSER_STATUS_INSUFFICIENT_RESOURCES: + return STATUS_INSUFFICIENT_RESOURCES; + case HIDPARSER_STATUS_INVALID_REPORT_TYPE: + return HIDP_STATUS_INVALID_REPORT_TYPE; + case HIDPARSER_STATUS_BUFFER_TOO_SMALL: + return STATUS_BUFFER_TOO_SMALL; + case HIDPARSER_STATUS_COLLECTION_NOT_FOUND: + return STATUS_NO_DATA_DETECTED; + default: + return Status; + } +} + +NTSTATUS +NTAPI +HidP_GetCollectionDescription( + IN PHIDP_REPORT_DESCRIPTOR ReportDesc, + IN ULONG DescLength, + IN POOL_TYPE PoolType, + OUT PHIDP_DEVICE_DESC DeviceDescription) +{ + HID_PARSER Parser; + NTSTATUS Status; + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get description; + // + Status = HidParser_GetCollectionDescription(&Parser, ReportDesc, DescLength, PoolType, DeviceDescription); + return TranslateStatusForUpperLayer(Status); +} + +HIDAPI +ULONG +NTAPI +HidP_MaxUsageListLength( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage OPTIONAL, + IN PHIDP_PREPARSED_DATA PreparsedData) +{ + HID_PARSER Parser; + + // + // sanity check + // + ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + + // + // get usage length + // + return HidParser_MaxUsageListLength(&Parser, PreparsedData, ReportType, UsagePage); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetSpecificValueCaps( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + OUT PHIDP_VALUE_CAPS ValueCaps, + IN OUT PUSHORT ValueCapsLength, + IN PHIDP_PREPARSED_DATA PreparsedData) +{ + HID_PARSER Parser; + + // + // sanity check + // + ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get value caps + // + return HidParser_GetSpecificValueCaps(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, ValueCaps, ValueCapsLength); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetUsages( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + OUT PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + HID_PARSER Parser; + + // + // sanity check + // + ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get usages + // + return HidParser_GetUsages(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, UsageList, UsageLength, Report, ReportLength); +} + + +#undef HidP_GetButtonCaps + +HIDAPI +NTSTATUS +NTAPI +HidP_UsageListDifference( + IN PUSAGE PreviousUsageList, + IN PUSAGE CurrentUsageList, + OUT PUSAGE BreakUsageList, + OUT PUSAGE MakeUsageList, + IN ULONG UsageListLength) +{ + return HidParser_UsageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetUsagesEx( + IN HIDP_REPORT_TYPE ReportType, + IN USHORT LinkCollection, + OUT PUSAGE_AND_PAGE ButtonList, + IN OUT ULONG *UsageLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + return HidP_GetUsages(ReportType, HID_USAGE_PAGE_UNDEFINED, LinkCollection, &ButtonList->Usage, UsageLength, PreparsedData, Report, ReportLength); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_UsageAndPageListDifference( + IN PUSAGE_AND_PAGE PreviousUsageList, + IN PUSAGE_AND_PAGE CurrentUsageList, + OUT PUSAGE_AND_PAGE BreakUsageList, + OUT PUSAGE_AND_PAGE MakeUsageList, + IN ULONG UsageListLength) +{ + return HidParser_UsageAndPageListDifference(PreviousUsageList, CurrentUsageList, BreakUsageList, MakeUsageList, UsageListLength); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetScaledUsageValue( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + OUT PLONG UsageValue, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + HID_PARSER Parser; + + // + // sanity check + // + ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get scaled usage value + // + return HidParser_GetScaledUsageValue(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetUsageValue( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + OUT PULONG UsageValue, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + HID_PARSER Parser; + + // + // sanity check + // + ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType == HidP_Feature); + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // get scaled usage value + // + return HidParser_GetUsageValue(&Parser, PreparsedData, ReportType, UsagePage, LinkCollection, Usage, UsageValue, Report, ReportLength); +} + + +HIDAPI +NTSTATUS +NTAPI +HidP_TranslateUsageAndPagesToI8042ScanCodes( + 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) +{ + HID_PARSER Parser; + + // + // init parser + // + HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction, DebugFunction, &Parser); + + // + // translate usage pages + // + return HidParser_TranslateUsageAndPagesToI8042ScanCodes(&Parser, ChangedUsageList, UsageListLength, KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetButtonCaps( + HIDP_REPORT_TYPE ReportType, + PHIDP_BUTTON_CAPS ButtonCaps, + PUSHORT ButtonCapsLength, + PHIDP_PREPARSED_DATA PreparsedData) +{ + return HidP_GetSpecificButtonCaps(ReportType, HID_USAGE_PAGE_UNDEFINED, 0, 0, ButtonCaps, ButtonCapsLength, PreparsedData); +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetSpecificButtonCaps( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + OUT PHIDP_BUTTON_CAPS ButtonCaps, + IN OUT PUSHORT ButtonCapsLength, + IN PHIDP_PREPARSED_DATA PreparsedData) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetData( + IN HIDP_REPORT_TYPE ReportType, + OUT PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetExtendedAttributes( + IN HIDP_REPORT_TYPE ReportType, + IN USHORT DataIndex, + IN PHIDP_PREPARSED_DATA PreparsedData, + OUT PHIDP_EXTENDED_ATTRIBUTES Attributes, + IN OUT PULONG LengthAttributes) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetLinkCollectionNodes( + OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, + IN OUT PULONG LinkCollectionNodesLength, + IN PHIDP_PREPARSED_DATA PreparsedData) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidP_SysPowerEvent( + IN PCHAR HidPacket, + IN USHORT HidPacketLength, + IN PHIDP_PREPARSED_DATA Ppd, + OUT PULONG OutputBuffer) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidP_SysPowerCaps( + IN PHIDP_PREPARSED_DATA Ppd, + OUT PULONG OutputBuffer) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_GetUsageValueArray( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + OUT PCHAR UsageValue, + IN USHORT UsageValueByteLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + + +HIDAPI +NTSTATUS +NTAPI +HidP_UnsetUsages( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_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) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_SetUsages( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN PUSAGE UsageList, + IN OUT PULONG UsageLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_SetUsageValueArray( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN PCHAR UsageValue, + IN USHORT UsageValueByteLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_SetUsageValue( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection, + IN USAGE Usage, + IN ULONG UsageValue, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_SetScaledUsageValue( + IN HIDP_REPORT_TYPE ReportType, + IN USAGE UsagePage, + IN USHORT LinkCollection OPTIONAL, + IN USAGE Usage, + IN LONG UsageValue, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_SetData( + IN HIDP_REPORT_TYPE ReportType, + IN PHIDP_DATA DataList, + IN OUT PULONG DataLength, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +ULONG +NTAPI +HidP_MaxDataListLength( + IN HIDP_REPORT_TYPE ReportType, + IN PHIDP_PREPARSED_DATA PreparsedData) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +HIDAPI +NTSTATUS +NTAPI +HidP_InitializeReportForID( + IN HIDP_REPORT_TYPE ReportType, + IN UCHAR ReportID, + IN PHIDP_PREPARSED_DATA PreparsedData, + IN OUT PCHAR Report, + IN ULONG ReportLength) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +#undef HidP_GetValueCaps + +HIDAPI +NTSTATUS +NTAPI +HidP_GetValueCaps( + HIDP_REPORT_TYPE ReportType, + PHIDP_VALUE_CAPS ValueCaps, + PUSHORT ValueCapsLength, + PHIDP_PREPARSED_DATA PreparsedData) +{ + UNIMPLEMENTED; + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} diff --git a/sdk/lib/drivers/hidparser/hidp.h b/sdk/lib/drivers/hidparser/hidp.h new file mode 100644 index 00000000000..629bc86bf3c --- /dev/null +++ b/sdk/lib/drivers/hidparser/hidp.h @@ -0,0 +1,6 @@ +PVOID NTAPI AllocFunction(ULONG Size); +VOID NTAPI FreeFunction(PVOID Item); +VOID NTAPI ZeroFunction(PVOID Item, ULONG Size); +VOID NTAPI CopyFunction(PVOID Target, PVOID Source, ULONG Size); +VOID __cdecl DebugFunction(LPCSTR Src, ...); + diff --git a/sdk/lib/drivers/hidparser/hidparser.h b/sdk/lib/drivers/hidparser/hidparser.h index 581193a319f..befcd32bda6 100644 --- a/sdk/lib/drivers/hidparser/hidparser.h +++ b/sdk/lib/drivers/hidparser/hidparser.h @@ -57,7 +57,7 @@ typedef struct // // free function // - PFREE_FUNCTION Free; + PHIDPARSER_FREE_FUNCTION Free; // // zero function