usb: Allow registration of a single non-contiguous string descriptor for WinUSB
Classic WinUSB support is detected by probing for a string descriptor at index 0xEE with a special string. usbd_register_extra_string() allows registration of a string at this index without having to provide 237 other string descriptors Originally filed as https://github.com/libopencm3/libopencm3/pull/849 WCID reference: https://github.com/pbatard/libwdi/wiki/WCID-Devices
This commit is contained in:
@@ -54,6 +54,8 @@ usbd_device *usbd_init(const usbd_driver *driver,
|
||||
usbd_dev->config = conf;
|
||||
usbd_dev->strings = strings;
|
||||
usbd_dev->num_strings = num_strings;
|
||||
usbd_dev->extra_string_idx = 0;
|
||||
usbd_dev->extra_string = NULL;
|
||||
usbd_dev->ctrl_buf = control_buffer;
|
||||
usbd_dev->ctrl_buf_len = control_buffer_size;
|
||||
|
||||
@@ -94,6 +96,20 @@ void usbd_register_sof_callback(usbd_device *usbd_dev, void (*callback)(void))
|
||||
usbd_dev->user_callback_sof = callback;
|
||||
}
|
||||
|
||||
void usbd_register_extra_string(usbd_device *usbd_dev, int index, const char* string)
|
||||
{
|
||||
/*
|
||||
* Note: string index 0 is reserved for LANGID requests and cannot
|
||||
* be overwritten using this functionality.
|
||||
*/
|
||||
if (string != NULL && index > 0) {
|
||||
usbd_dev->extra_string_idx = index;
|
||||
usbd_dev->extra_string = string;
|
||||
} else {
|
||||
usbd_dev->extra_string_idx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void _usbd_reset(usbd_device *usbd_dev)
|
||||
{
|
||||
usbd_dev->current_address = 0;
|
||||
|
||||
Reference in New Issue
Block a user