mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-22 10:20:55 +00:00
add descriptor string count for tud_desc_set_t
This commit is contained in:
parent
2bff2a7d97
commit
262be103e0
@ -85,7 +85,9 @@ tud_desc_set_t tud_desc_set =
|
||||
{
|
||||
.device = NULL,
|
||||
.config = NULL,
|
||||
.string_arr = (uint8_t const **) string_desc_arr,
|
||||
|
||||
.string_arr = (uint8_t const **) string_desc_arr,
|
||||
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
|
||||
|
||||
.hid_report =
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ static void usbd_reset(uint8_t rhport)
|
||||
extern tusb_desc_device_t const _desc_auto_device;
|
||||
extern uint8_t const * const _desc_auto_config;
|
||||
|
||||
tud_desc_set.device = &_desc_auto_device;
|
||||
tud_desc_set.device = (uint8_t const*) &_desc_auto_device;
|
||||
tud_desc_set.config = _desc_auto_config;
|
||||
|
||||
#if CFG_TUD_HID_BOOT_PROTOCOL
|
||||
@ -509,13 +509,17 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co
|
||||
break;
|
||||
|
||||
case TUSB_DESC_STRING:
|
||||
// windows sometimes ask for string at index 238 !!!
|
||||
if ( !(desc_index < 100) ) return 0;
|
||||
if ( desc_index < tud_desc_set.string_count )
|
||||
{
|
||||
desc_data = tud_desc_set.string_arr[desc_index];
|
||||
VERIFY( desc_data != NULL, 0 );
|
||||
|
||||
desc_data = tud_desc_set.string_arr[desc_index];
|
||||
VERIFY( desc_data != NULL, 0 );
|
||||
|
||||
len = desc_data[0]; // first byte of descriptor is its size
|
||||
len = desc_data[0]; // first byte of descriptor is its size
|
||||
}else
|
||||
{
|
||||
// out of range
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case TUSB_DESC_DEVICE_QUALIFIER:
|
||||
|
@ -59,9 +59,11 @@
|
||||
|
||||
/// \brief Descriptor pointer collector to all the needed.
|
||||
typedef struct {
|
||||
void const * device; ///< pointer to device descriptor \ref tusb_desc_device_t
|
||||
uint8_t const * config; ///< pointer to the whole configuration descriptor, starting by \ref tusb_desc_configuration_t
|
||||
uint8_t const** string_arr; ///< a array of pointers to string descriptors
|
||||
uint8_t const * device; ///< pointer to device descriptor \ref tusb_desc_device_t
|
||||
uint8_t const * config; ///< pointer to the whole configuration descriptor, starting by \ref tusb_desc_configuration_t
|
||||
|
||||
uint8_t const** string_arr; ///< a array of pointers to string descriptors
|
||||
uint16_t string_count;
|
||||
|
||||
struct {
|
||||
uint8_t const* composite;
|
||||
|
Loading…
x
Reference in New Issue
Block a user