Multiple HID Devices on LPC1769 (LPCXpresso board)

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

Multiple HID Devices on LPC1769 (LPCXpresso board)

740 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LVL on Thu Sep 13 02:25:47 MST 2012
Hi,

The nxpusblib is wonderful, however, it does has it's limitations.
I want to create a device that contains multiple HID Gamepads/Joysticks.
I don't think I am talking about composite devices, since I need 2 devices which are exactly the same.
The usb descriptor is already edit(see below). It now shows one device on the pc, but 2 controllers within that device.


USB descriptor:
<code>
HID_RI_USAGE_PAGE (8, 0x01), \
HID_RI_USAGE (8, 0x05), \
HID_RI_COLLECTION (8, 0x01), \
HID_RI_COLLECTION (8, 0x00), \
HID_RI_REPORT_ID (8, 0x01), \
HID_RI_USAGE_PAGE (8, 0x09), \
HID_RI_USAGE_MINIMUM (8, 0x01), \
HID_RI_USAGE_MAXIMUM (8, 0x08), \
HID_RI_LOGICAL_MINIMUM (8, 0x00), \
HID_RI_LOGICAL_MAXIMUM (8, 0x01), \
HID_RI_REPORT_COUNT (8, 0x08), \
HID_RI_REPORT_SIZE (8, 0x01), \
HID_RI_INPUT (8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_USAGE_PAGE (8, 0x01), \
HID_RI_USAGE (8, 0x30), \
HID_RI_USAGE (8, 0x31), \
HID_RI_USAGE (8, 0x33), \
HID_RI_USAGE (8, 0x34), \
HID_RI_LOGICAL_MINIMUM (8, 0x81), \
HID_RI_LOGICAL_MAXIMUM (8, 0x7f), \
HID_RI_REPORT_SIZE (8, 0x08), \
HID_RI_REPORT_COUNT (8, 0x04), \
HID_RI_INPUT (8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_END_COLLECTION(0), \
HID_RI_END_COLLECTION(0), \
HID_RI_USAGE_PAGE (8, 0x01), \
HID_RI_USAGE (8, 0x05), \
HID_RI_COLLECTION (8, 0x01), \
HID_RI_COLLECTION (8, 0x00), \
HID_RI_REPORT_ID (8, 0x02), \
HID_RI_USAGE_PAGE (8, 0x09), \
HID_RI_USAGE_MINIMUM (8, 0x01), \
HID_RI_USAGE_MAXIMUM (8, 0x08), \
HID_RI_LOGICAL_MINIMUM (8, 0x00), \
HID_RI_LOGICAL_MAXIMUM (8, 0x01), \
HID_RI_REPORT_COUNT (8, 0x08), \
HID_RI_REPORT_SIZE (8, 0x01), \
HID_RI_INPUT (8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_USAGE_PAGE (8, 0x01), \
HID_RI_USAGE (8, 0x30), \
HID_RI_USAGE (8, 0x31), \
HID_RI_USAGE (8, 0x33), \
HID_RI_USAGE (8, 0x34), \
HID_RI_LOGICAL_MINIMUM (8, 0x81), \
HID_RI_LOGICAL_MAXIMUM (8, 0x7f), \
HID_RI_REPORT_SIZE (8, 0x08), \
HID_RI_REPORT_COUNT (8, 0x04), \
HID_RI_INPUT (8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_END_COLLECTION(0), \
HID_RI_END_COLLECTION(0)
</code>


Data structure:
<code>
typedef struct
{
uint8_t report_id;
uint8_t buttons;
int8_t left_x;
int8_t left_y;
int8_t right_x;
int8_t right_y;
} ATTR_PACKED USB_GamepadReport_Data_t;
</code>


This is of course the easy part. Right now I am learning about endpoints, which seem to play a role in my 'multiple HID gamepads'-idea.
And of course the Report_ID, which is connected to every data pack that the device sends to the pc.
Right now, I cannot receive anything from the device.(only with one device and without the report_id in the struct)

Can anybody help me with this? It somehow seems easy, but I am just not seeing it...
Labels (1)
0 Kudos
3 Replies

644 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LVL on Thu Sep 20 07:44:11 MST 2012
Thank you very much for your reply.
I will try what you suggested.
You will hear from me again!
If I succeed, I might create a tutorial. ;)
0 Kudos

644 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nxpUSBlib team on Wed Sep 19 14:01:53 MST 2012
It sounds like you do need to create a composite device, even though two of your HID devices are exactly the same. nxpUSBlib does support composite devices, we just haven't created an example yet. This is on our plate though.

To create a composite HID device I suggest you start with the generic HID example and attempt to duplicate it to just get the composite changes working first.

To do this you would clone the report descriptor and clone those portions of the configuration descriptor that describe the device.

Be careful to change the interface numbers and endpoints so they are unique and don't forget to increase the total interface count value.

You will need to clone the Address = and Size = lines in the cases for HID_DTYPE_HID and HID_DTYPE_Report in CALLBACK_USB_GetDescriptor at the bottom of the file. Key off wIndex to determine which Address and Size to return to the host.

In GenericHID.c you will need to clone the Generic_HID_Interface structure and give the new one a unique name and InterfaceNumber.

In the EVENT_ handlers add a new line that passes this new interface to the functions they call.

And in the CreateHIDReport and ProcessHIDReport callbacks you will need to key off of the HIDInterfaceInfo argument to determine which HID interface is being addressed.
0 Kudos

644 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LVL on Wed Sep 19 02:01:52 MST 2012
Can nobody help me? I think it's really important that the nxpusblib supports composite devices...
0 Kudos