Skip to content

Commit

Permalink
CustomHID: support different report descriptor sizes
Browse files Browse the repository at this point in the history
Right now if you have more than 1 CustomHID interface, all interfaces
have report descriptors of the same size.

Support different sizes by adding an entry to USBD_CUSTOM_HID_ItfTypeDef.
The default is USBD_CUSTOM_HID_REPORT_DESC_SIZE, so this is backwards
compatible.
  • Loading branch information
XelaRellum committed Sep 25, 2023
1 parent 7b5e688 commit 5436df4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Class/CompositeBuilder/Src/usbd_composite_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
pDesc->bCountryCode = 0x00U;
pDesc->bNumDescriptors = 0x01U;
pDesc->bDescriptorType = 0x22U;
pDesc->wItemLength = USBD_CUSTOM_HID_REPORT_DESC_SIZE;
pDesc->wItemLength = ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->wReportDescrLen;
*Sze += (uint32_t)sizeof(USBD_DescTypeDef);

/* Descriptor of Custom HID endpoints */
Expand Down
1 change: 1 addition & 0 deletions Class/CustomHID/Inc/usbd_customhid.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef enum
typedef struct _USBD_CUSTOM_HID_Itf
{
uint8_t *pReport;
uint16_t wReportDescrLen;
int8_t (* Init)(void);
int8_t (* DeInit)(void);
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
Expand Down
1 change: 1 addition & 0 deletions Class/CustomHID/Src/usbd_customhid_if_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ __ALIGN_BEGIN static uint8_t TEMPLATE_CUSTOM_HID_ReportDesc[USBD_CUSTOM_HID_REPO
USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
{
TEMPLATE_CUSTOM_HID_ReportDesc,
USBD_CUSTOM_HID_REPORT_DESC_SIZE,
TEMPLATE_CUSTOM_HID_Init,
TEMPLATE_CUSTOM_HID_DeInit,
TEMPLATE_CUSTOM_HID_OutEvent,
Expand Down

0 comments on commit 5436df4

Please sign in to comment.