Combined USB keyboard and mouse device

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Combined USB keyboard and mouse device

1,843 Views
julianmorrison
Contributor II

I am using the Freescale USB stack v4.1.1 and I need to have a combined USB keyboard and mouse device.

It appears to me that the hid device demo is hard coded for one end point so I think I will need a combined device descriptor.

Has any one had any luck doing this?

Any help would be appreciated.

Cheers, Julian

4 Replies

735 Views
perlam_i_au
Senior Contributor I

Hi Julian:

In this case you can use as base example the composite descriptor on the USB Stack for Audio+Video (Please find this on path: C:\Freescale\Freescale USB Stack v4.1.1\Source\Device\app_composite\hid_audio_video) specifically check usb_descriptor.c


Have a nice day,
Perla Moncada

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

735 Views
julianmorrison
Contributor II

Perla,

Thanks for your help, I now have two HID input devices showing in windows device manager along with a USB Composite device controller.

Unfortunately, windows is not starting the device showing a 'This device cannot start. (Code 10)' in the properties.

Do you have any further suggestions on where I'm going wrong?

Thanks, Julian

Here is my configuration descriptor:

uint_8 USB_DESC_CONST g_config_descriptor_composite[CONFIG_DESC_SIZE_COMPOSITE] =
{
   CONFIG_ONLY_DESC_SIZE,      /*  Configuration Descriptor Size - always 9 bytes*/
   USB_CONFIG_DESCRIPTOR,      /* "Configuration" type of descriptor */
   CONFIG_DESC_SIZE_COMPOSITE, 0x00,  /*  Total length of the Configuration descriptor */
   2,                          /*  NumInterfaces */
   1,                          /*  Configuration Value */
   0,                          /*  Configuration Description String Index*/
   BUS_POWERED|SELF_POWERED|(REMOTE_WAKEUP_SUPPORT<<REMOTE_WAKEUP_SHIFT),
   /* S08/CFv1 are both self powered (its compulsory to set bus powered)*/
   /* Attributes.support RemoteWakeup and self power */
   0x32,                       /*  Current draw from bus */
  
   /* Interface 0 Descriptor */
   IFACE_ONLY_DESC_SIZE,    /* Size */
   USB_IFACE_DESCRIPTOR,    /* INTERFACE descriptor type */
   0x00,        /* Index of this interface */
   0x00,        /* Index of this alternate setting */
   HID_DESC_ENDPOINT_COUNT,    /* endpoint */
   0x03,        /* USB DEVICE CLASS */
   0x01,        /* SUBCLASS */
   0x01,         /* 0x01 for keyboard */
   0x00,

   /*Endpoint 0 descriptor */
   ENDP_ONLY_DESC_SIZE,
   USB_ENDPOINT_DESCRIPTOR,
   HID_ENDPOINT|(USB_SEND << 7),
   USB_INTERRUPT_PIPE,
   HID_ENDPOINT_PACKET_SIZE, 0x00,
   0x0A,                                 /* Poll at least every 10ms */
  
   /* Interface 1 Descriptor */
   IFACE_ONLY_DESC_SIZE,    /* Size */
   USB_IFACE_DESCRIPTOR,    /* INTERFACE descriptor type */
   0x01,        /* Index of this interface */
   0x00,        /* Index of this alternate setting */
   HID_DESC_ENDPOINT_COUNT,    /* endpoint */
   0x03,        /* USB DEVICE CLASS */
   0x01,        /* SUBCLASS */
   0x02,         /* 0x02 for mouse */
   0x00,

   /*Endpoint  1 descriptor */
   ENDP_ONLY_DESC_SIZE,
   USB_ENDPOINT_DESCRIPTOR,
   HID_ENDPOINT|(USB_SEND << 7),
   USB_INTERRUPT_PIPE,
   HID_ENDPOINT_PACKET_SIZE, 0x00,
   0x0A,                                /* Poll at least every 10ms */

   /* HID descriptor */
   HID_ONLY_DESC_SIZE,
   USB_HID_DESCRIPTOR,
   0x00,0x01,
   0x00,
   0x01,
   0x22,
   REPORT_DESC_SIZE_COMPOSITE, 0x00  /* report descriptor size to follow */
};

0 Kudos

735 Views
mjbcswitzerland
Specialist V

Hi Julian

I think that you need to check the HID report associated with the REPORT_DESC_SIZE_COMPOSITE.

g_config_descriptor_composite[] is informing the USB host that there are two HID devices but the host will then request the details of these devices using a REQUEST GET DESCRIPTION of type REPORT and this answer is probably not yet correct for the devices - thus the error code.

Regards

Mark

735 Views
julianmorrison
Contributor II

Thanks Mark,

I will check the report descriptor. There are suggestions elsewhere that I may need to use REPORT_ID's but I'm not sure?

I guess what I'm looking for is a full listing of the Device, Config and Report descriptors for a composite keyboard/mouse device from someone who has succeeded at this already.

It would be nice to understand USB more but I have only just been put on the project which is way behind schedule (usual thing!)

Cheers, Julian

0 Kudos