fix(radio): usb joystick descriptor, unusable joystick axis (#4726)
This commit is contained in:
@@ -123,7 +123,7 @@ __ALIGN_BEGIN static const uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
|
|||||||
0x09, 0x34, // USAGE (Ry)
|
0x09, 0x34, // USAGE (Ry)
|
||||||
0x09, 0x35, // USAGE (Rz)
|
0x09, 0x35, // USAGE (Rz)
|
||||||
0x09, 0x36, // USAGE (Slider)
|
0x09, 0x36, // USAGE (Slider)
|
||||||
0x09, 0x36, // USAGE (Slider)
|
0x09, 0x37, // USAGE (Dial)
|
||||||
0x16, 0x00, 0x00, // LOGICAL_MINIMUM (0)
|
0x16, 0x00, 0x00, // LOGICAL_MINIMUM (0)
|
||||||
0x26, 0xFF, 0x07, // LOGICAL_MAXIMUM (2047)
|
0x26, 0xFF, 0x07, // LOGICAL_MAXIMUM (2047)
|
||||||
0x75, 0x10, // REPORT_SIZE (16)
|
0x75, 0x10, // REPORT_SIZE (16)
|
||||||
@@ -170,8 +170,8 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_E
|
|||||||
/************** Configuration Descriptor ****************/
|
/************** Configuration Descriptor ****************/
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
LOBYTE(USB_HID_CONFIG_DESC_SIZ), /* wTotalLength: Bytes returned */
|
||||||
0x00,
|
HIBYTE(USB_HID_CONFIG_DESC_SIZ),
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: Configuration value */
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
0x00, /* iConfiguration: Index of string descriptor
|
0x00, /* iConfiguration: Index of string descriptor
|
||||||
@@ -200,11 +200,12 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_E
|
|||||||
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
||||||
0x22, /* bDescriptorType */
|
0x22, /* bDescriptorType */
|
||||||
#if !defined(USBJ_EX)
|
#if !defined(USBJ_EX)
|
||||||
sizeof(HID_JOYSTICK_ReportDesc), /*wItemLength: Total length of Report descriptor*/
|
LOBYTE(sizeof(HID_JOYSTICK_ReportDesc)), /* wItemLength: Total length of Report descriptor*/
|
||||||
|
HIBYTE(sizeof(HID_JOYSTICK_ReportDesc)),
|
||||||
#else
|
#else
|
||||||
0, /*wItemLength: Total length of Report descriptor*/
|
0x00, /* wItemLength: Total length of Report descriptor*/
|
||||||
#endif
|
|
||||||
0x00,
|
0x00,
|
||||||
|
#endif
|
||||||
/******************** Endpoint Descriptor for Joystick ********************/
|
/******************** Endpoint Descriptor for Joystick ********************/
|
||||||
/* 27 */
|
/* 27 */
|
||||||
0x07, /* bLength: Endpoint Descriptor size */
|
0x07, /* bLength: Endpoint Descriptor size */
|
||||||
@@ -213,12 +214,13 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_E
|
|||||||
HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
|
HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
|
||||||
0x03, /* bmAttributes: Interrupt endpoint */
|
0x03, /* bmAttributes: Interrupt endpoint */
|
||||||
#if !defined(USBJ_EX)
|
#if !defined(USBJ_EX)
|
||||||
HID_IN_PACKET, /* wMaxPacketSize */
|
LOBYTE(HID_IN_PACKET), /* wMaxPacketSize */
|
||||||
|
HIBYTE(HID_IN_PACKET),
|
||||||
#else
|
#else
|
||||||
0, /* wMaxPacketSize */
|
0x00, /* wMaxPacketSize */
|
||||||
#endif
|
|
||||||
0x00,
|
0x00,
|
||||||
0x01, /*bInterval: Polling Interval (1 ms)*/
|
#endif
|
||||||
|
0x01, /* bInterval: Polling Interval (1 ms) */
|
||||||
/* 34 */
|
/* 34 */
|
||||||
};
|
};
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -234,8 +236,13 @@ __ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END =
|
|||||||
0x00, /* bCountryCode: Hardware target country */
|
0x00, /* bCountryCode: Hardware target country */
|
||||||
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
||||||
0x22, /* bDescriptorType */
|
0x22, /* bDescriptorType */
|
||||||
HID_MOUSE_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
|
#if !defined(USBJ_EX)
|
||||||
|
LOBYTE(sizeof(HID_JOYSTICK_ReportDesc)), /* wItemLength: Total length of Report descriptor */
|
||||||
|
HIBYTE(sizeof(HID_JOYSTICK_ReportDesc))
|
||||||
|
#else
|
||||||
|
0x00, /* wItemLength: Total length of Report descriptor */
|
||||||
0x00,
|
0x00,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
@@ -276,9 +283,9 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
{
|
{
|
||||||
UNUSED(cfgidx);
|
UNUSED(cfgidx);
|
||||||
#if defined(USBJ_EX)
|
#if defined(USBJ_EX)
|
||||||
uint8_t hid_in_pkt_size = usbReportSize();
|
uint16_t hid_in_pkt_size = usbReportSize();
|
||||||
#else
|
#else
|
||||||
uint8_t hid_in_pkt_size = HID_IN_PACKET;
|
uint16_t hid_in_pkt_size = HID_IN_PACKET;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USBD_HID_HandleTypeDef *hhid;
|
USBD_HID_HandleTypeDef *hhid;
|
||||||
@@ -299,14 +306,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
pdev->ep_in[HIDInEpAdd & 0xFU].bInterval = 1;
|
||||||
{
|
|
||||||
pdev->ep_in[HIDInEpAdd & 0xFU].bInterval = 1;
|
|
||||||
}
|
|
||||||
else /* LOW and FULL-speed endpoints */
|
|
||||||
{
|
|
||||||
pdev->ep_in[HIDInEpAdd & 0xFU].bInterval = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open EP IN */
|
/* Open EP IN */
|
||||||
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, hid_in_pkt_size);
|
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, hid_in_pkt_size);
|
||||||
@@ -425,6 +425,11 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
else if ((req->wValue >> 8) == HID_DESCRIPTOR_TYPE)
|
else if ((req->wValue >> 8) == HID_DESCRIPTOR_TYPE)
|
||||||
{
|
{
|
||||||
pbuf = USBD_HID_Desc;
|
pbuf = USBD_HID_Desc;
|
||||||
|
#if defined(USBJ_EX)
|
||||||
|
struct usbReport_t ret = usbReportDesc();
|
||||||
|
pbuf[7] = LOBYTE(ret.size);
|
||||||
|
pbuf[8] = HIBYTE(ret.size);
|
||||||
|
#endif
|
||||||
len = MIN(USB_HID_DESC_SIZ, req->wLength);
|
len = MIN(USB_HID_DESC_SIZ, req->wLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -556,15 +561,27 @@ static uint8_t *USBD_HID_GetFSCfgDesc(uint16_t *length)
|
|||||||
{
|
{
|
||||||
USBD_EpDescTypeDef *pEpDesc = USBD_GetEpDesc(USBD_HID_CfgDesc, HID_EPIN_ADDR);
|
USBD_EpDescTypeDef *pEpDesc = USBD_GetEpDesc(USBD_HID_CfgDesc, HID_EPIN_ADDR);
|
||||||
|
|
||||||
if (pEpDesc != NULL)
|
|
||||||
{
|
|
||||||
pEpDesc->bInterval = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USBJ_EX)
|
#if defined(USBJ_EX)
|
||||||
struct usbReport_t ret = usbReportDesc();
|
struct usbReport_t ret = usbReportDesc();
|
||||||
USBD_HID_CfgDesc[25] = ret.size;
|
|
||||||
USBD_HID_CfgDesc[31] = usbReportSize();
|
USBD_HID_CfgDesc[25] = LOBYTE(ret.size);
|
||||||
|
USBD_HID_CfgDesc[26] = HIBYTE(ret.size);
|
||||||
|
|
||||||
|
uint16_t size = usbReportSize();
|
||||||
|
USBD_HID_CfgDesc[31] = LOBYTE(size);
|
||||||
|
USBD_HID_CfgDesc[32] = HIBYTE(size);
|
||||||
|
|
||||||
|
if (pEpDesc != NULL)
|
||||||
|
{
|
||||||
|
pEpDesc->wMaxPacketSize = size;
|
||||||
|
pEpDesc->bInterval = 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pEpDesc != NULL)
|
||||||
|
{
|
||||||
|
pEpDesc->wMaxPacketSize = HID_IN_PACKET;
|
||||||
|
pEpDesc->bInterval = 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*length = (uint16_t)sizeof(USBD_HID_CfgDesc);
|
*length = (uint16_t)sizeof(USBD_HID_CfgDesc);
|
||||||
@@ -580,21 +597,7 @@ static uint8_t *USBD_HID_GetFSCfgDesc(uint16_t *length)
|
|||||||
*/
|
*/
|
||||||
static uint8_t *USBD_HID_GetHSCfgDesc(uint16_t *length)
|
static uint8_t *USBD_HID_GetHSCfgDesc(uint16_t *length)
|
||||||
{
|
{
|
||||||
USBD_EpDescTypeDef *pEpDesc = USBD_GetEpDesc(USBD_HID_CfgDesc, HID_EPIN_ADDR);
|
return USBD_HID_GetFSCfgDesc(length);
|
||||||
|
|
||||||
if (pEpDesc != NULL)
|
|
||||||
{
|
|
||||||
pEpDesc->bInterval = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USBJ_EX)
|
|
||||||
struct usbReport_t ret = usbReportDesc();
|
|
||||||
USBD_HID_CfgDesc[25] = ret.size;
|
|
||||||
USBD_HID_CfgDesc[31] = usbReportSize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*length = (uint16_t)sizeof(USBD_HID_CfgDesc);
|
|
||||||
return USBD_HID_CfgDesc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -606,20 +609,7 @@ static uint8_t *USBD_HID_GetHSCfgDesc(uint16_t *length)
|
|||||||
*/
|
*/
|
||||||
static uint8_t *USBD_HID_GetOtherSpeedCfgDesc(uint16_t *length)
|
static uint8_t *USBD_HID_GetOtherSpeedCfgDesc(uint16_t *length)
|
||||||
{
|
{
|
||||||
USBD_EpDescTypeDef *pEpDesc = USBD_GetEpDesc(USBD_HID_CfgDesc, HID_EPIN_ADDR);
|
return USBD_HID_GetFSCfgDesc(length);
|
||||||
|
|
||||||
if (pEpDesc != NULL)
|
|
||||||
{
|
|
||||||
pEpDesc->bInterval = 1;
|
|
||||||
}
|
|
||||||
#if defined(USBJ_EX)
|
|
||||||
struct usbReport_t ret = usbReportDesc();
|
|
||||||
USBD_HID_CfgDesc[25] = ret.size;
|
|
||||||
USBD_HID_CfgDesc[31] = usbReportSize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*length = (uint16_t)sizeof(USBD_HID_CfgDesc);
|
|
||||||
return USBD_HID_CfgDesc;
|
|
||||||
}
|
}
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user