[HID] Use hidparser static library for HidP_* functions

hid.dll and hidparse.sys must understand the same HID preparsed data,
so use the same code in hid.dll and in hidparse.sys

At the same time, this permis implementation of some HidP_* functions.
This commit is contained in:
Hervé Poussineau 2019-04-27 14:17:10 +02:00
parent 2978d4b61b
commit 7033ab18df
4 changed files with 59 additions and 432 deletions

View file

@ -3,9 +3,11 @@ spec2def(hid.dll hid.spec ADD_IMPORTLIB)
list(APPEND SOURCE
hid.c
stubs.c
precomp.h)
include_directories(
${REACTOS_SOURCE_DIR}/sdk/lib/drivers/hidparser)
add_library(hid MODULE
${SOURCE}
hid.rc
@ -13,5 +15,6 @@ add_library(hid MODULE
set_module_type(hid win32dll UNICODE)
add_importlibs(hid msvcrt kernel32 ntdll)
target_link_libraries(hid hidparser_um)
add_pch(hid precomp.h SOURCE)
add_cd_file(TARGET hid DESTINATION reactos/system32 FOR all)

View file

@ -27,17 +27,67 @@
*/
#include "precomp.h"
#include <stdarg.h>
#include <winbase.h>
#define NDEBUG
#include <debug.h>
#include "hidp.h"
HINSTANCE hDllInstance;
/* device interface GUID for HIDClass devices */
const GUID HidClassGuid = {0x4D1E55B2, 0xF16F, 0x11CF, {0x88,0xCB,0x00,0x11,0x11,0x00,0x00,0x30}};
PVOID
NTAPI
AllocFunction(
IN ULONG ItemSize)
{
return LocalAlloc(LHND, ItemSize);
}
VOID
NTAPI
FreeFunction(
IN PVOID Item)
{
LocalFree((HLOCAL)Item);
}
VOID
NTAPI
ZeroFunction(
IN PVOID Item,
IN ULONG ItemSize)
{
memset(Item, 0, ItemSize);
}
VOID
NTAPI
CopyFunction(
IN PVOID Target,
IN PVOID Source,
IN ULONG Length)
{
memcpy(Target, Source, Length);
}
VOID
__cdecl
DebugFunction(
IN LPCSTR FormatStr, ...)
{
#if 0
va_arg list;
va_start(list, FormatStr);
vDbgPrintEx(FormatStr, list);
va_end(list);
#endif
}
BOOL WINAPI
DllMain(HINSTANCE hinstDLL,
DWORD dwReason,
@ -123,23 +173,6 @@ HidD_GetAttributes(IN HANDLE HidDeviceObject,
}
/*
* HidP_GetButtonCaps EXPORTED
*
* @implemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_GetButtonCaps(IN HIDP_REPORT_TYPE ReportType,
OUT PHIDP_BUTTON_CAPS ButtonCaps,
IN OUT PUSHORT ButtonCapsLength,
IN PHIDP_PREPARSED_DATA PreparsedData)
{
return HidP_GetSpecificButtonCaps(ReportType, 0, 0, 0, ButtonCaps,
ButtonCapsLength, PreparsedData);
}
/*
* HidD_GetFeature EXPORTED
*
@ -340,23 +373,6 @@ HidD_GetSerialNumberString(IN HANDLE HidDeviceObject,
}
/*
* HidP_GetValueCaps EXPORTED
*
* @implemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_GetValueCaps(IN HIDP_REPORT_TYPE ReportType,
OUT PHIDP_VALUE_CAPS ValueCaps,
IN OUT PUSHORT ValueCapsLength,
IN PHIDP_PREPARSED_DATA PreparsedData)
{
return HidP_GetSpecificValueCaps(ReportType, 0, 0, 0, ValueCaps,
ValueCapsLength, PreparsedData);
}
/*
* HidD_Hello EXPORTED
*
@ -525,23 +541,4 @@ HidD_SetConfiguration(IN HANDLE HidDeviceObject,
return Ret;
}
/*
* HidP_GetUsagesEx EXPORTED
*
* @implemented
*/
HIDAPI
NTSTATUS WINAPI
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, ButtonList->UsagePage, LinkCollection, &ButtonList->Usage, UsageLength, PreparsedData, Report, ReportLength);
}
/* EOF */

View file

@ -1,378 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Hid User Library
* FILE: lib/hid/stubs.c
* PURPOSE: hid.dll stubs
* NOTES: If you implement a function, remove it from this file
*
* UPDATE HISTORY:
* 07/12/2004 Created
*/
#include "precomp.h"
#define NDEBUG
#include <debug.h>
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData,
OUT PHIDP_CAPS Capabilities)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_GetLinkCollectionNodes(OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,
IN OUT PULONG LinkCollectionNodesLength,
IN PHIDP_PREPARSED_DATA PreparsedData)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_GetUsages(IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage,
IN USHORT LinkCollection OPTIONAL,
OUT USAGE *UsageList,
IN OUT ULONG *UsageLength,
IN PHIDP_PREPARSED_DATA PreparsedData,
IN PCHAR Report,
IN ULONG ReportLength)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_InitializeReportForID(IN HIDP_REPORT_TYPE ReportType,
IN UCHAR ReportID,
IN PHIDP_PREPARSED_DATA PreparsedData,
IN OUT PCHAR Report,
IN ULONG ReportLength)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
ULONG WINAPI
HidP_MaxDataListLength(IN HIDP_REPORT_TYPE ReportType,
IN PHIDP_PREPARSED_DATA PreparsedData)
{
UNIMPLEMENTED;
return 0;
}
/*
* @unimplemented
*/
HIDAPI
ULONG WINAPI
HidP_MaxUsageListLength(IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage OPTIONAL,
IN PHIDP_PREPARSED_DATA PreparsedData)
{
UNIMPLEMENTED;
return 0;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_SetUsages(IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage,
IN USHORT LinkCollection OPTIONAL,
IN PUSAGE UsageList,
IN OUT PULONG UsageLength,
IN PHIDP_PREPARSED_DATA PreparsedData,
IN OUT PCHAR Report,
IN ULONG ReportLength)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
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;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_UnsetUsages(IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage,
IN USHORT LinkCollection OPTIONAL,
IN PUSAGE UsageList,
IN OUT PULONG UsageLength,
IN PHIDP_PREPARSED_DATA PreparsedData,
IN OUT PCHAR Report,
IN ULONG ReportLength)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
HIDAPI
NTSTATUS WINAPI
HidP_UsageListDifference(IN PUSAGE PreviousUsageList,
IN PUSAGE CurrentUsageList,
OUT PUSAGE BreakUsageList,
OUT PUSAGE MakeUsageList,
IN ULONG UsageListLength)
{
UNIMPLEMENTED;
return HIDP_STATUS_NOT_IMPLEMENTED;
}
/* EOF */

View file

@ -10,6 +10,11 @@ list(APPEND SOURCE
hidp.c
hidp.h)
add_library(hidparser_um ${SOURCE})
add_importlibs(hidparser_um ntdll)
add_dependencies(hidparser_um bugcodes xdk)
add_pch(hidparser_um parser.h SOURCE)
add_library(hidparser_km ${SOURCE})
add_importlibs(hidparser_km ntoskrnl)
add_dependencies(hidparser_km bugcodes xdk)