2024-07-30 11:55 AM
Hi All,
I'm having issues setting up multiple HID reports.
I had a couple of USB HID projects in the past, all worked fine. This time I started from STM32CubeIDE from Custom HID device.
I have the following report descriptor:
/** Usb HID report descriptor. */
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
/* USER CODE BEGIN 0 */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x85, 3, // REPORT_ID
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x25, // USAGE_MAXIMUM (Button 37)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x25, // REPORT_COUNT (37)
0x65, 0x00, // UNIT (None)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x03, // REPORT_COUNT (# of padding bits)
0x81, 0x03, // INPUT (Const,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x33, // USAGE (RX)
0x09, 0x34, // USAGE (RY)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xA0, 0x0f, // LOGICAL_MAXIMUM (4000)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xC0, // End collection
0x06, 0x00, 0xff, // Usage Page (Vendor Defined)
0x09, 0x01, // Usage (Vendor Usage 1)
0xa1, 0x01, // Collection (Application)
0x85, 90, // REPORT_ID
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (1)
0x75, 0x08, // Report Size (8)
0x95, 19, // Report Count (32)
0x91, 0x02, // Output (Data,Var,Abs)
0x95, 19, // Report Count (32)
0x81, 0x02, // Input (Data,Var,Abs)
/* USER CODE END 0 */
0xC0 /* END_COLLECTION */
};
So, a game controller + 32 byete IN/OUT for communication.
So, the custom input report somehow affects the game controller reports. It doesn't matter what I set for report count in the custom report, it works only if the game controller has the same size. In USB monitor it looks like only 32 byte messages are received and if I report smaller ones, then it waits until it's full. (But I'm not sure that this is on PC side or mcu.)
HAL_Delay(2000);
// Game controller report
uint8_t data[33] = {3};
USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, data, 33);
HAL_Delay(2000);
// Customer report
uint8_t data2[33] = {90};
USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, data2, 33);
So the lines above work fine, but the game controller report should be 9 byte + reportID, instead of 33.
2024-08-12 11:17 AM
Hi @PDan
Which product are you using? HID report descriptor might not correctly define the different report sizes
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.