From d908e70163e6fdf38738d71901c7b980d05cf146 Mon Sep 17 00:00:00 2001 From: Michael Plante Date: Tue, 6 Apr 2010 17:30:41 +0100 Subject: Added missing Feature Report descriptor feature also allowed the use of LIBUSB_RECIPIENT_DEVICE in _hid_class_request Issue reported by Axel Rohde --- libusb/os/windows_usb.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 7adc21a..46d08a2 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -3022,6 +3022,22 @@ static int _hid_get_report_descriptor(struct hid_device_priv* dev, void *data, s /* output (data, variable, absolute) */ d[i++] = 0x91; d[i++] = 0x00; } + /* feature report */ + if (dev->feature_report_size) { + /* usage (vendor defined) */ + d[i++] = 0x09; d[i++] = 0x03; + /* logical minimum (0) */ + d[i++] = 0x15; d[i++] = 0x00; + /* logical maximum (255) */ + d[i++] = 0x25; d[i++] = 0xFF; + /* report size (8 bits) */ + d[i++] = 0x75; d[i++] = 0x08; + /* report count */ + d[i++] = 0x95; d[i++] = (uint8_t)dev->feature_report_size - 1; + /* feature (data, variable, absolute) */ + d[i++] = 0xb2; d[i++] = 0x02; d[i++] = 0x01; + } + /* end collection */ d[i++] = 0xC0; @@ -3268,7 +3284,8 @@ static int _hid_class_request(struct hid_device_priv* dev, HANDLE hid_handle, in int report_type = (value >> 8) & 0xFF; int report_id = value & 0xFF; - if (LIBUSB_REQ_RECIPIENT(request_type) != LIBUSB_RECIPIENT_INTERFACE) + if ( (LIBUSB_REQ_RECIPIENT(request_type) != LIBUSB_RECIPIENT_INTERFACE) + && (LIBUSB_REQ_RECIPIENT(request_type) != LIBUSB_RECIPIENT_DEVICE) ) return LIBUSB_ERROR_INVALID_PARAM; if (LIBUSB_REQ_OUT(request_type) @@ -3576,8 +3593,9 @@ static int hid_submit_control_transfer(struct usbi_transfer *itransfer) safe_free(transfer_priv->hid_buffer); size = transfer->length - LIBUSB_CONTROL_SETUP_SIZE; - if (size > MAX_CTRL_BUFFER_LENGTH) + if (size > MAX_CTRL_BUFFER_LENGTH) { return LIBUSB_ERROR_INVALID_PARAM; + } current_interface = get_valid_interface(transfer->dev_handle); // Attempt to claim an interface if none was found @@ -4024,4 +4042,4 @@ static int composite_copy_transfer_data(struct usbi_transfer *itransfer, uint32_ struct windows_device_priv *priv = __device_priv(transfer->dev_handle->dev); return priv->usb_interface[transfer_priv->interface_number].apib->copy_transfer_data(itransfer, io_size); -} +} \ No newline at end of file -- cgit v1.2.1