Commit b7f43c99 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

hidclass.sys: Add USB Descriptor parsing.

parent 69d57ee7
......@@ -5,6 +5,7 @@ DELAYIMPORTS = setupapi hid
C_SRCS = \
buffer.c \
descriptor.c \
device.c \
main.c \
pnp.c
......@@ -81,3 +81,6 @@ void HID_DeleteDevice(HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT *device
/* Pseudo-Plug and Play support*/
NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT* PDO) DECLSPEC_HIDDEN;
void PNP_CleanupPNP(DRIVER_OBJECT *driver) DECLSPEC_HIDDEN;
/* Parsing HID Report Descriptors into preparsed data */
WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) DECLSPEC_HIDDEN;
......@@ -53,6 +53,9 @@ NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO)
DWORD index = HID_STRING_ID_ISERIALNUMBER;
NATIVE_DEVICE *tracked_device, *ptr;
INT interface_index = 1;
HID_DESCRIPTOR descriptor;
BYTE *reportDescriptor;
INT i;
static const WCHAR ig_fmtW[] = {'I','G','_','%','i',0};
static const WCHAR im_fmtW[] = {'I','M','_','%','i',0};
......@@ -104,6 +107,40 @@ NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO)
list_add_tail(&tracked_devices, &tracked_device->entry);
status = call_minidriver(IOCTL_HID_GET_DEVICE_DESCRIPTOR, device, NULL, 0,
&descriptor, sizeof(descriptor));
if (status != STATUS_SUCCESS)
{
ERR("Cannot get Device Descriptor(%x)\n",status);
HID_DeleteDevice(&minidriver->minidriver, device);
return status;
}
for (i = 0; i < descriptor.bNumDescriptors; i++)
if (descriptor.DescriptorList[i].bReportType == HID_REPORT_DESCRIPTOR_TYPE)
break;
if (i >= descriptor.bNumDescriptors)
{
ERR("No Report Descriptor found in reply\n");
HID_DeleteDevice(&minidriver->minidriver, device);
return status;
}
reportDescriptor = HeapAlloc(GetProcessHeap(), 0, descriptor.DescriptorList[i].wReportLength);
status = call_minidriver(IOCTL_HID_GET_REPORT_DESCRIPTOR, device, NULL, 0,
reportDescriptor, descriptor.DescriptorList[i].wReportLength);
if (status != STATUS_SUCCESS)
{
ERR("Cannot get Report Descriptor(%x)\n",status);
HID_DeleteDevice(&minidriver->minidriver, device);
HeapFree(GetProcessHeap(), 0, reportDescriptor);
return status;
}
ext->preparseData = ParseDescriptor(reportDescriptor, descriptor.DescriptorList[0].wReportLength);
ext->information.DescriptorSize = ext->preparseData->dwSize;
HeapFree(GetProcessHeap(), 0, reportDescriptor);
serial[0] = 0;
status = call_minidriver(IOCTL_HID_GET_STRING, device,
&index, sizeof(DWORD), serial, sizeof(serial));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment