summaryrefslogtreecommitdiff
path: root/components/drivers/usb/usbdevice/class/hid.c
diff options
context:
space:
mode:
authorDillon Min <[email protected]>2021-03-11 17:29:41 +0800
committerDillon Min <[email protected]>2021-03-11 17:29:41 +0800
commiteffcee25b7cbb2bb42d4134d37dc8a9ec4635130 (patch)
treea9d124ef0ee38641b48f12d33de65ff3c4b3f482 /components/drivers/usb/usbdevice/class/hid.c
parent0beaeeef456e5e12dd8c7d76ebd8aea2e83973d3 (diff)
component: driver: usb: Add usb interface string(iInterface) setting
To make compositive usb device string more reansonable, not all devices just show same "RTT Composite Device" on windows device manager. add a interface rt_usbd_device_set_interface_string to set respective interface string. Signed-off-by: Dillon Min <[email protected]> v1 -> v2: remove all tabs to space, to match rt-thread coding style
Diffstat (limited to 'components/drivers/usb/usbdevice/class/hid.c')
-rw-r--r--components/drivers/usb/usbdevice/class/hid.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c
index 52e50296a4..7dc344365d 100644
--- a/components/drivers/usb/usbdevice/class/hid.c
+++ b/components/drivers/usb/usbdevice/class/hid.c
@@ -17,7 +17,7 @@
#include "hid.h"
#ifdef RT_USB_DEVICE_HID
-
+#define HID_INTF_STR_INDEX 7
struct hid_s
{
struct rt_device parent;
@@ -318,8 +318,12 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
#else
USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
#endif
- 0, /* iInterface: Index of string descriptor */
- },
+#ifdef RT_USB_DEVICE_COMPOSITE
+ HID_INTF_STR_INDEX, /* iInterface: Index of string descriptor */
+#else
+ 0,
+#endif
+ },
/* HID Descriptor */
{
@@ -685,8 +689,11 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device)
RT_ASSERT(device != RT_NULL);
/* set usb device string description */
+#ifdef RT_USB_DEVICE_COMPOSITE
+ rt_usbd_device_set_interface_string(device, HID_INTF_STR_INDEX, _ustring[2]);
+#else
rt_usbd_device_set_string(device, _ustring);
-
+#endif
/* create a cdc function */
func = rt_usbd_function_new(device, &_dev_desc, &ops);