/* Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to the device from the USB host before passing along unhandled control requests to the library for processing internally.  */
void EVENT_USB_Device_ControlRequest(void)
/* Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to the device from the USB host before passing along unhandled control requests to the library for processing internally.  */
void EVENT_USB_Device_ControlRequest(void)
{
	switch (USB_ControlRequest.bRequest)
	{
		case HID_REQ_GetReport:
			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
			{
				uint8_t GenericData[GENERIC_REPORT_SIZE];
				CreateGenericHIDReport(GenericData);
				Endpoint_ClearSETUP();
				Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData));
				Endpoint_ClearOUT();
			}
			break;
		case HID_REQ_SetReport:
			if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
			{
				uint8_t GenericData[GENERIC_REPORT_SIZE];
				Endpoint_ClearSETUP();
				Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));
				Endpoint_ClearIN();
				ProcessGenericHIDReport(GenericData);
			}
			break;
	}
}