X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/5251bc6e4e312ec5c4f57c43a92ba49c19684c51..7227e133a9cf8d4de1214671211a0d93edb2b4bc:/Demos/Host/ClassDriver/MouseHost/MouseHost.c diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c index 88518a845..61d7d7bb6 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c @@ -50,11 +50,6 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface = .MatchInterfaceProtocol = true, .HIDInterfaceProtocol = 0x02, }, - - .State = - { - // Leave all state values to their defaults - } }; @@ -76,10 +71,24 @@ int main(void) case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - if (HID_Host_ConfigurePipes(&Mouse_HID_Interface, 512) != HID_ENUMERROR_NoError) + uint16_t ConfigDescriptorSize; + uint8_t ConfigDescriptorData[512]; + + if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) || + (ConfigDescriptorSize > sizeof(ConfigDescriptorData))) { - printf("Attached device is not a valid Mouse.\r\n"); - + printf("Error Retrieving Configuration Descriptor.\r\n"); + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData); + + if (HID_Host_ConfigurePipes(&Mouse_HID_Interface, + ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) + { + printf("Attached Device Not a Valid Mouse.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -88,7 +97,6 @@ int main(void) if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { printf("Error Setting Device Configuration.\r\n"); - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break;