X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/f6f4ac588cec25ad7f9baa67fc3c22c9306f962e..c7f4752d6bacf15aaea13a111c1d9bb8576f186d:/Bootloaders/HID/Descriptors.c?ds=inline diff --git a/Bootloaders/HID/Descriptors.c b/Bootloaders/HID/Descriptors.c index f79d34686..fef43ab94 100644 --- a/Bootloaders/HID/Descriptors.c +++ b/Bootloaders/HID/Descriptors.c @@ -154,23 +154,33 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, const void** const DescriptorAddress) { - const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorType = (wValue >> 8); const void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; + /* If/Else If chain compiles slightly smaller than a switch case */ if (DescriptorType == DTYPE_Device) - Address = &DeviceDescriptor; + { + Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + } else if (DescriptorType == DTYPE_Configuration) - Address = &ConfigurationDescriptor; + { + Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + } else if (DescriptorType == HID_DTYPE_HID) - Address = &ConfigurationDescriptor.HID_VendorHID; + { + Address = &ConfigurationDescriptor.HID_VendorHID; + Size = sizeof(USB_HID_Descriptor_HID_t); + } else - Address = &HIDReport; + { + Address = &HIDReport; + Size = sizeof(HIDReport); + } - if (Address != NULL) - Size = (Address == &HIDReport) ? sizeof(HIDReport) : ((USB_Descriptor_Header_t*)Address)->Size; - *DescriptorAddress = Address; return Size; }