From 5b790bde5e2045aaa6678da6ca5903fec46ddc6e Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 30 Jun 2015 07:40:13 -0500 Subject: [PATCH] hid: Implement HidD_GetPreparsedData and HidD_FreePreparsedData. --- dlls/hid/hid.spec | 4 ++-- dlls/hid/hidd.c | 32 ++++++++++++++++++++++++++++++++ include/ddk/hidclass.h | 9 +++++++++ include/ddk/hidsdi.h | 2 ++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/dlls/hid/hid.spec b/dlls/hid/hid.spec index 5659a887876..c72b0b8e229 100644 --- a/dlls/hid/hid.spec +++ b/dlls/hid/hid.spec @@ -1,5 +1,5 @@ @ stub HidD_FlushQueue -@ stub HidD_FreePreparsedData +@ stdcall HidD_FreePreparsedData(ptr) @ stub HidD_GetAttributes @ stub HidD_GetConfiguration @ stdcall HidD_GetFeature(long ptr long) @@ -10,7 +10,7 @@ @ stub HidD_GetMsGenreDescriptor @ stub HidD_GetNumInputBuffers @ stub HidD_GetPhysicalDescriptor -@ stub HidD_GetPreparsedData +@ stdcall HidD_GetPreparsedData(ptr ptr) @ stdcall HidD_GetProductString(long ptr long) @ stub HidD_GetSerialNumberString @ stub HidD_Hello diff --git a/dlls/hid/hidd.c b/dlls/hid/hidd.c index 144e804e3bd..4c1c1fdbcc1 100644 --- a/dlls/hid/hidd.c +++ b/dlls/hid/hidd.c @@ -32,10 +32,19 @@ #include "winioctl.h" #include "ddk/wdm.h" +#include "hidusage.h" #include "ddk/hidclass.h" +#include "ddk/hidpi.h" WINE_DEFAULT_DEBUG_CHANNEL(hid); +BOOLEAN WINAPI HidD_FreePreparsedData(PHIDP_PREPARSED_DATA PreparsedData) +{ + TRACE("(%p)\n", PreparsedData); + HeapFree(GetProcessHeap(), 0, PreparsedData); + return TRUE; +} + BOOLEAN WINAPI HidD_GetFeature(HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength) { TRACE("(%p %p %u)\n", HidDeviceObject, ReportBuffer, ReportBufferLength); @@ -65,3 +74,26 @@ BOOLEAN WINAPI HidD_GetProductString(HANDLE HidDeviceObject, PVOID Buffer, ULONG TRACE("(%p %p %u)\n", HidDeviceObject, Buffer, BufferLength); return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_PRODUCT_STRING, NULL, 0, Buffer, BufferLength, NULL, NULL); } + +BOOLEAN WINAPI HidD_GetPreparsedData(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData) +{ + HID_COLLECTION_INFORMATION info; + PHIDP_PREPARSED_DATA data; + + TRACE("(%p %p)\n", HidDeviceObject, PreparsedData); + + if (!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, NULL, 0, + &info, sizeof(HID_COLLECTION_INFORMATION), NULL, NULL)) + return FALSE; + + if (!(data = HeapAlloc(GetProcessHeap(), 0, info.DescriptorSize))) return FALSE; + + if (!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, NULL, 0, + data, info.DescriptorSize, NULL, NULL)) + { + HeapFree( GetProcessHeap(), 0, data ); + return FALSE; + } + *PreparsedData = data; + return TRUE; +} diff --git a/include/ddk/hidclass.h b/include/ddk/hidclass.h index 81f892d19fe..09dc467a39e 100644 --- a/include/ddk/hidclass.h +++ b/include/ddk/hidclass.h @@ -56,6 +56,15 @@ DEFINE_GUID (GUID_DEVINTERFACE_HID, \ #define IOCTL_HID_SET_DRIVER_CONFIG HID_BUFFER_CTL_CODE(101) #define IOCTL_HID_GET_MS_GENRE_DESCRIPTOR HID_OUT_CTL_CODE(121) +typedef struct _HID_COLLECTION_INFORMATION { + ULONG DescriptorSize; + BOOLEAN Polled; + UCHAR Reserved1[1]; + USHORT VendorID; + USHORT ProductID; + USHORT VersionNumber; +} HID_COLLECTION_INFORMATION, *PHID_COLLECTION_INFORMATION; + #ifdef __cplusplus } #endif diff --git a/include/ddk/hidsdi.h b/include/ddk/hidsdi.h index 5eb68ff2762..c8aae285ff3 100644 --- a/include/ddk/hidsdi.h +++ b/include/ddk/hidsdi.h @@ -32,5 +32,7 @@ void WINAPI HidD_GetHidGuid(LPGUID guid); BOOLEAN WINAPI HidD_GetManufacturerString(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength); BOOLEAN WINAPI HidD_GetProductString(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength); BOOLEAN WINAPI HidD_SetFeature(HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength); +BOOLEAN WINAPI HidD_GetPreparsedData( HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData); +BOOLEAN WINAPI HidD_FreePreparsedData(PHIDP_PREPARSED_DATA PreparsedData); #endif /* __WINE_HIDSDI_H */