HID and Host Data

Hello, I have a problem i want make a HID Joystick with a arduino but i want too with the same carde display data like date from the PC so i want to know if is possible to make a driver or have a COM port at the same time than the HID Device

Keyglove launch multiple HID and a serial at the same time but i only understand how it swith, i don’t understand how to modify my firmware

Thank you

Edit :

I’ve started to do this in the Descriptor.c

#include "Descriptors.h"

#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)
	#warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.
#endif

const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
{
	0x05, 0x01,          /* Usage Page (Generic Desktop)                       */
	0x09, 0x04,          /* Usage (Joystick)                                   */

	0xa1, 0x01,          /* Collection (Application)                           */
	0x09, 0x01,          /*   Usage (Pointer)                                  */

	/* 8 axes, signed 16 bit resolution, range -32768 to 32767 (16 bytes) */
	0xa1, 0x00,          /*   Collection (Physical)                            */
	0x05, 0x01,          /*     Usage Page (Generic Desktop)                   */
	0x09, 0x30,          /*     Usage (X)                                      */
	0x09, 0x31,          /*     Usage (Y)                                      */
	0x09, 0x32,          /*     Usage (Analog1)                                */
	0x09, 0x33,          /*     Usage (Analog2)                                */
	0x09, 0x34,          /*     Usage (Analog3)                                */
	0x09, 0x35,          /*     Usage (Analog4)                                */
	0x09, 0x36,          /*     Usage (Analog5)                                */
	0x09, 0x37,          /*     Usage (Analog6)                                */
	0x16, 0x00, 0x80,    /*     Logical Minimum (-32768)                       */
	0x26, 0xff, 0x7f,    /*     Logical Maximum (32767)                        */
	0x75, 16,            /*     Report Size (16)                               */
	0x95, 8,             /*     Report Count (8)                               */
	0x81, 0x82,          /*     Input (Data, Variable, Absolute, Volatile)     */
	0xc0,                /*   End Collection                                   */

	/* 40 buttons, value 0=off, 1=on (5 bytes) */
	0x05, 0x09,          /*   Usage Page (Button)                              */
	0x19, 1,             /*     Usage Minimum (Button 1)                       */
	0x29, 40,            /*     Usage Maximum (Button 40)                      */
	0x15, 0x00,          /*   Logical Minimum (0)                              */
	0x25, 0x01,          /*   Logical Maximum (1)                              */
	0x75, 1,             /*   Report Size (1)                                  */
	0x95, 40,            /*   Report Count (40)                                */
	0x81, 0x02,          /*   Input (Data, Variable, Absolute)                 */
	0xc0                 /* End Collection                                     */
};

const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
{
	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
		
	.USBSpecification       = VERSION_BCD(01.10),
	.Class                  = 0x02,
	.SubClass               = 0x00,
	.Protocol               = 0x00,
				
	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,
		
	//.VendorID               = 0x03EB, // Atmel
	.VendorID               = 0x2341, // Arduino

	//.ProductID          	= 0x204B, // LUFA USB to Serial Demo Application
	.ProductID          	= 0x0043, // Arduino Uno
	.ReleaseNumber          = 0x0001,
		
	.ManufacturerStrIndex   = 0x01,
	.ProductStrIndex        = 0x02,
	.SerialNumStrIndex      = USE_INTERNAL_SERIAL,
		
	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
};

const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{
	/****/
	.CDC_DataInEndpoint = 
		{
			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
			
			.EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
			.EndpointSize           = CDC_TXRX_EPSIZE,
			.PollingIntervalMS      = 0x01
		},
		
	.HID_Interface = 
		{
			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},

			.InterfaceNumber        = 0x00,
			.AlternateSetting       = 0x00,
			
			.TotalEndpoints         = 1,
				
			.Class                  = 0x03,
			.SubClass               = 0x00,
			.Protocol               = HID_NON_BOOT_PROTOCOL,
				
			.InterfaceStrIndex      = NO_DESCRIPTOR
		},

	.HID_JoystickHID = 
		{
			.Header                 = {.Size = sizeof(USB_HID_Descriptor_t), .Type = DTYPE_HID},
			
			.HIDSpec                = VERSION_BCD(01.11),
			.CountryCode            = 0x00,
			.TotalReportDescriptors = 1,
			.HIDReportType          = DTYPE_Report,
			.HIDReportLength        = sizeof(JoystickReport)
		},

	.HID_ReportINEndpoint = 
		{
			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
			
			.EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | JOYSTICK_EPNUM),
			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
			.EndpointSize           = JOYSTICK_EPSIZE,
			.PollingIntervalMS      = 0x0A
		}	
};

const USB_Descriptor_String_t PROGMEM LanguageString =
{
	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
		
	.UnicodeString          = {LANGUAGE_ID_ENG}
};

const USB_Descriptor_String_t PROGMEM ManufacturerString =
{
	.Header                 = {.Size = USB_STRING_LEN(24), .Type = DTYPE_String},
		
	.UnicodeString          = L"Arduino (www.arduino.cc)"
};
const USB_Descriptor_String_t PROGMEM ProductString =
{
	#if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID)
		.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
			
		.UnicodeString          = L"Arduino Uno"
	#elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID)
		.Header                 = {.Size = USB_STRING_LEN(17), .Type = DTYPE_String},
			
		.UnicodeString          = L"Arduino Mega 2560"
	#endif
	
};

const USB_Descriptor_String_t PROGMEM ProductStringHID =
{
    .Header                 = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String},

    .UnicodeString          = L"Arduino Input Device"
};
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
                                    const uint8_t wIndex,
                                    void** const DescriptorAddress)
{
	const uint8_t  DescriptorType   = (wValue >> 8);
	const uint8_t  DescriptorNumber = (wValue & 0xFF);

	void*    Address = NULL;
	uint16_t Size    = NO_DESCRIPTOR;

	switch (DescriptorType)
	{
		case DTYPE_Device: 
			Address = (void*)&DeviceDescriptor;
			Size    = sizeof(USB_Descriptor_Device_t);
			break;
		case DTYPE_Configuration: 
			Address = (void*)&ConfigurationDescriptor;
			Size    = sizeof(USB_Descriptor_Configuration_t);
			break;
		case DTYPE_String: 
			switch (DescriptorNumber)
			{
				case 0x00: 
					Address = (void*)&LanguageString;
					Size    = pgm_read_byte(&LanguageString.Header.Size);
					break;
				case 0x01: 
					Address = (void*)&ManufacturerString;
					Size    = pgm_read_byte(&ManufacturerString.Header.Size);
					break;
				case 0x02: 
					Address = (void*)&ProductString;
					Size    = pgm_read_byte(&ProductString.Header.Size);
					break;
				case 0x03:
                    Address = &ProductStringHID;
                    Size    = pgm_read_byte(&ProductStringHID.Header.Size);
                    break;
			}
			
			break;
		  case DTYPE_HID:
            Address = &ConfigurationDescriptor.HID_JoystickHID;
            Size    = sizeof(USB_HID_Descriptor_t);
            break;
        case DTYPE_Report:
            Address = &JoystickReport;
            Size    = sizeof(JoystickReport);
            break;
	}
	
	*DescriptorAddress = Address;
	return Size;
}

This have not error in building but i can’t test on my Arduino i’ve still not receive it

arduino-big-joystick -SERIAL.zip (158 KB)

I haven't done it myself, but I've read comments in the forum which imply that the Arduino can act as an HID and a serial port at the same time. I've also seen code for a mouse emulator which performs serial output on the default Serial device as well as generating mouse events.

keyglove use 4 devices, my code is build with a mix of the HID and the Serial now i just wait my card for try it, I thin i can't simulate this level of hardware

I want to do the same thing as you, have you succeded doing this???