Added multiple Report ID support to the HID class driver. Removed OUT endpoint support from HID driver (all OUT reports are now processed through control requests) as a seperate endpoint had issues with determining the exact output report length.
This commit is contained in:
		
							parent
							
								
									7665bf323e
								
							
						
					
					
						commit
						3d1baa6f95
					
				
					 23 changed files with 96 additions and 128 deletions
				
			
		| 
						 | 
				
			
			@ -169,7 +169,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 | 
			
		|||
			.InterfaceNumber        = 0x00,
 | 
			
		||||
			.AlternateSetting       = 0x00,
 | 
			
		||||
			
 | 
			
		||||
			.TotalEndpoints         = 2,
 | 
			
		||||
			.TotalEndpoints         = 1,
 | 
			
		||||
				
 | 
			
		||||
			.Class                  = 0x03,
 | 
			
		||||
			.SubClass               = 0x01,
 | 
			
		||||
| 
						 | 
				
			
			@ -199,16 +199,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
 | 
			
		|||
			.PollingIntervalMS      = 0x02
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
	.KeyboardOutEndpoint = 
 | 
			
		||||
		{
 | 
			
		||||
			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
 | 
			
		||||
 | 
			
		||||
			.EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_OUT_EPNUM),
 | 
			
		||||
			.Attributes             = EP_TYPE_INTERRUPT,
 | 
			
		||||
			.EndpointSize           = HID_EPSIZE,
 | 
			
		||||
			.PollingIntervalMS      = 0x02
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
	.MouseInterface = 
 | 
			
		||||
		{
 | 
			
		||||
			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,6 @@
 | 
			
		|||
			USB_Descriptor_Interface_t            KeyboardInterface;
 | 
			
		||||
			USB_Descriptor_HID_t                  KeyboardHID;
 | 
			
		||||
	        USB_Descriptor_Endpoint_t             KeyboardInEndpoint;
 | 
			
		||||
	        USB_Descriptor_Endpoint_t             KeyboardOutEndpoint;
 | 
			
		||||
			USB_Descriptor_Interface_t            MouseInterface;
 | 
			
		||||
			USB_Descriptor_HID_t                  MouseHID;
 | 
			
		||||
	        USB_Descriptor_Endpoint_t             MouseInEndpoint;
 | 
			
		||||
| 
						 | 
				
			
			@ -64,9 +63,6 @@
 | 
			
		|||
		/** Endpoint number of the Keyboard HID reporting IN endpoint. */
 | 
			
		||||
		#define KEYBOARD_IN_EPNUM         1
 | 
			
		||||
 | 
			
		||||
		/** Endpoint number of the Keyboard HID reporting OUT endpoint. */
 | 
			
		||||
		#define KEYBOARD_OUT_EPNUM        2
 | 
			
		||||
 | 
			
		||||
		/** Endpoint number of the Mouse HID reporting IN endpoint. */
 | 
			
		||||
		#define MOUSE_IN_EPNUM            3
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
 | 
			
		|||
 | 
			
		||||
		.ReportINEndpointNumber  = KEYBOARD_IN_EPNUM,
 | 
			
		||||
		.ReportINEndpointSize    = HID_EPSIZE,
 | 
			
		||||
 | 
			
		||||
		.ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM,
 | 
			
		||||
		.ReportOUTEndpointSize   = HID_EPSIZE,
 | 
			
		||||
		
 | 
			
		||||
		.ReportINBufferSize      = sizeof(USB_KeyboardReport_Data_t),
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,9 +67,6 @@ USB_ClassInfo_HID_t Mouse_HID_Interface =
 | 
			
		|||
		.ReportINEndpointSize    = HID_EPSIZE,
 | 
			
		||||
 | 
			
		||||
		.ReportINBufferSize      = sizeof(USB_MouseReport_Data_t),
 | 
			
		||||
 | 
			
		||||
		.ReportOUTEndpointNumber = 0,
 | 
			
		||||
		.ReportOUTEndpointSize   = 0,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
/** Main program entry point. This routine contains the overall program flow, including initial
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +156,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
 | 
			
		|||
 *
 | 
			
		||||
 *  \return Number of bytes written in the report (or zero if no report is to be sent
 | 
			
		||||
 */
 | 
			
		||||
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)
 | 
			
		||||
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t JoyStatus_LCL    = Joystick_GetStatus();
 | 
			
		||||
	uint8_t ButtonStatus_LCL = Buttons_GetStatus();
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +215,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI
 | 
			
		|||
 *  \param ReportData  Pointer to a buffer where the created report has been stored
 | 
			
		||||
 *  \param ReportSize  Size in bytes of the received HID report
 | 
			
		||||
 */
 | 
			
		||||
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)
 | 
			
		||||
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
 | 
			
		||||
                                               void* ReportData, uint16_t ReportSize)
 | 
			
		||||
{
 | 
			
		||||
	if (HIDInterfaceInfo == &Keyboard_HID_Interface)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,8 +90,8 @@
 | 
			
		|||
		void EVENT_USB_ConfigurationChanged(void);
 | 
			
		||||
		void EVENT_USB_UnhandledControlPacket(void);
 | 
			
		||||
 | 
			
		||||
		uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);
 | 
			
		||||
		void     CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,
 | 
			
		||||
		uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
 | 
			
		||||
		void     CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, 
 | 
			
		||||
		                                                   void* ReportData, uint16_t ReportSize);
 | 
			
		||||
		
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue