From 2e871fddb3c852c11ce0b10665857f9243d13bbc Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 13 Oct 2011 17:51:13 +0000 Subject: [PATCH] [HID] - Implement HidD_GetIndexedString, HidD_GetMsGenreDescriptor, HidD_GetConfiguration, HidD_SetConfiguration, HidP_GetUsagesEx svn path=/branches/usb-bringup/; revision=54115 --- dll/win32/hid/hid.c | 131 +++++++++++++++++++++++++++++++++++++----- dll/win32/hid/stubs.c | 75 ------------------------ 2 files changed, 118 insertions(+), 88 deletions(-) diff --git a/dll/win32/hid/hid.c b/dll/win32/hid/hid.c index 89cf57c7c1b..bf5bb5fe173 100644 --- a/dll/win32/hid/hid.c +++ b/dll/win32/hid/hid.c @@ -70,7 +70,7 @@ HidD_FlushQueue(IN HANDLE HidDeviceObject) return DeviceIoControl(HidDeviceObject, IOCTL_HID_FLUSH_QUEUE, NULL, 0, NULL, 0, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -150,7 +150,7 @@ HidD_GetFeature(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_FEATURE, NULL, 0, ReportBuffer, ReportBufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -182,7 +182,7 @@ HidD_GetInputReport(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INPUT_REPORT, NULL, 0, ReportBuffer, ReportBufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -201,7 +201,7 @@ HidD_GetManufacturerString(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MANUFACTURER_STRING, NULL, 0, Buffer, BufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -219,7 +219,7 @@ HidD_GetNumInputBuffers(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS, NULL, 0, NumberBuffers, sizeof(ULONG), - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -238,7 +238,7 @@ HidD_GetPhysicalDescriptor(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_GET_PHYSICAL_DESCRIPTOR, NULL, 0, Buffer, BufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -254,7 +254,7 @@ HidD_GetPreparsedData(IN HANDLE HidDeviceObject, { HID_COLLECTION_INFORMATION hci; DWORD RetLen; - BOOL Ret; + BOOLEAN Ret; if(PreparsedData == NULL) { @@ -279,7 +279,7 @@ HidD_GetPreparsedData(IN HANDLE HidDeviceObject, Ret = DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, NULL, 0, *PreparsedData, hci.DescriptorSize, - &RetLen, NULL); + &RetLen, NULL) != 0; if(!Ret) { @@ -312,7 +312,7 @@ HidD_GetProductString(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_PRODUCT_STRING, NULL, 0, Buffer, BufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -331,7 +331,7 @@ HidD_GetSerialNumberString(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_SERIALNUMBER_STRING, NULL, 0, Buffer, BufferLength, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -394,7 +394,7 @@ HidD_SetFeature(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_FEATURE, ReportBuffer, ReportBufferLength, NULL, 0, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -412,7 +412,7 @@ HidD_SetNumInputBuffers(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS, &NumberBuffers, sizeof(ULONG), NULL, 0, - &RetLen, NULL); + &RetLen, NULL) != 0; } @@ -431,7 +431,112 @@ HidD_SetOutputReport(IN HANDLE HidDeviceObject, return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_OUTPUT_REPORT, ReportBuffer, ReportBufferLength, NULL, 0, - &RetLen, NULL); + &RetLen, NULL) != 0; } +/* + * HidD_GetIndexedString EXPORTED + * + * @implemented + */ +HIDAPI +BOOLEAN WINAPI +HidD_GetIndexedString(IN HANDLE HidDeviceObject, + IN ULONG StringIndex, + OUT PVOID Buffer, + IN ULONG BufferLength) +{ + DWORD RetLen; + return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INDEXED_STRING, + &StringIndex, sizeof(ULONG), + Buffer, BufferLength, + &RetLen, NULL) != 0; +} + +/* + * HidD_GetMsGenreDescriptor EXPORTED + * + * @implemented + */ +HIDAPI +BOOLEAN WINAPI +HidD_GetMsGenreDescriptor(IN HANDLE HidDeviceObject, + OUT PVOID Buffer, + IN ULONG BufferLength) +{ + DWORD RetLen; + return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MS_GENRE_DESCRIPTOR, + 0, 0, + Buffer, BufferLength, + &RetLen, NULL) != 0; +} + +/* + * HidD_GetConfiguration EXPORTED + * + * @implemented + */ +HIDAPI +BOOLEAN WINAPI +HidD_GetConfiguration(IN HANDLE HidDeviceObject, + OUT PHIDD_CONFIGURATION Configuration, + IN ULONG ConfigurationLength) +{ + + // magic cookie + Configuration->cookie = (PVOID)HidD_GetConfiguration; + + return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_DRIVER_CONFIG, + 0, 0, + &Configuration->size, ConfigurationLength - sizeof(ULONG), + (PULONG)&Configuration->cookie, NULL) != 0; +} + +/* + * HidD_SetConfiguration EXPORTED + * + * @implemented + */ +HIDAPI +BOOLEAN WINAPI +HidD_SetConfiguration(IN HANDLE HidDeviceObject, + IN PHIDD_CONFIGURATION Configuration, + IN ULONG ConfigurationLength) +{ + BOOLEAN Ret = FALSE; + + if (Configuration->cookie == (PVOID)HidD_GetConfiguration) + { + Ret = DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_DRIVER_CONFIG, + 0, 0, + (PVOID)&Configuration->size, ConfigurationLength - sizeof(ULONG), + (PULONG)&Configuration->cookie, NULL) != 0; + } + else + { + SetLastError(ERROR_INVALID_PARAMETER); + } + + 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 */ diff --git a/dll/win32/hid/stubs.c b/dll/win32/hid/stubs.c index cb4543da792..1e37efaa166 100644 --- a/dll/win32/hid/stubs.c +++ b/dll/win32/hid/stubs.c @@ -11,63 +11,6 @@ */ #include -/* - * @unimplemented - */ -HIDAPI -BOOLEAN WINAPI -HidD_GetConfiguration(IN HANDLE HidDeviceObject, - OUT PHIDD_CONFIGURATION Configuration, - IN ULONG ConfigurationLength) -{ - UNIMPLEMENTED; - return FALSE; -} - - -/* - * @unimplemented - */ -HIDAPI -BOOLEAN WINAPI -HidD_GetIndexedString(IN HANDLE HidDeviceObject, - IN ULONG StringIndex, - OUT PVOID Buffer, - IN ULONG BufferLength) -{ - UNIMPLEMENTED; - return FALSE; -} - - -/* - * @unimplemented - */ -HIDAPI -BOOLEAN WINAPI -HidD_GetMsGenreDescriptor(IN HANDLE HidDeviceObject, - OUT PVOID Buffer, - IN ULONG BufferLength) -{ - UNIMPLEMENTED; - return FALSE; -} - - -/* - * @unimplemented - */ -HIDAPI -BOOLEAN WINAPI -HidD_SetConfiguration(IN HANDLE HidDeviceObject, - IN PHIDD_CONFIGURATION Configuration, - IN ULONG ConfigurationLength) -{ - UNIMPLEMENTED; - return FALSE; -} - - /* * @unimplemented */ @@ -241,24 +184,6 @@ HidP_GetUsages(IN HIDP_REPORT_TYPE ReportType, } -/* - * @unimplemented - */ -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) -{ - UNIMPLEMENTED; - return HIDP_STATUS_NOT_IMPLEMENTED; -} - - /* * @unimplemented */