diff options
author | Benson Leung <bleung@chromium.org> | 2020-07-28 17:15:27 -0700 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2020-07-29 10:13:01 +0100 |
commit | 8e9c45859f30d515bdbf18c0ca7904d63405dfb5 (patch) | |
tree | 7e1ac40aaf0f857907ed46b8f1a4cd6c6d3eb336 | |
parent | 4a86b0843969b96c3ba443903ef01b2cc572e11a (diff) | |
download | gusb-8e9c45859f30d515bdbf18c0ca7904d63405dfb5.tar.gz |
Add a way to get iConfiguration
Adds a getter for a gusb_device to get the string index for the active
configuration's description.
-rw-r--r-- | gusb/gusb-device.c | 30 | ||||
-rw-r--r-- | gusb/gusb-device.h | 1 | ||||
-rw-r--r-- | gusb/libgusb.ver | 6 |
3 files changed, 37 insertions, 0 deletions
diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c index be03131..fb29a13 100644 --- a/gusb/gusb-device.c +++ b/gusb/gusb-device.c @@ -1777,6 +1777,36 @@ g_usb_device_get_pid_as_str (GUsbDevice *device) } /** + * g_usb_device_get_configuration_index + * @device: a #GUsbDevice + * + * Get the index for the active Configuration string descriptor + * ie, iConfiguration. + * + * Return value: a string descriptor index. + * + * Since: 0.3.5 + **/ +guint8 +g_usb_device_get_configuration_index (GUsbDevice *device) +{ + struct libusb_config_descriptor *config; + gint rc; + guint8 index; + + g_return_val_if_fail (G_USB_IS_DEVICE (device), 0); + + rc = libusb_get_active_config_descriptor (device->priv->device, &config); + g_return_val_if_fail (rc == 0, 0); + + index = config->iConfiguration; + + libusb_free_config_descriptor (config); + return index; +} + + +/** * g_usb_device_get_manufacturer_index: * @device: a #GUsbDevice * diff --git a/gusb/gusb-device.h b/gusb/gusb-device.h index 7c7ec6f..e5d45f8 100644 --- a/gusb/gusb-device.h +++ b/gusb/gusb-device.h @@ -156,6 +156,7 @@ guint8 g_usb_device_get_device_class (GUsbDevice *device); guint8 g_usb_device_get_device_subclass (GUsbDevice *device); guint8 g_usb_device_get_device_protocol (GUsbDevice *device); +guint8 g_usb_device_get_configuration_index (GUsbDevice *device); guint8 g_usb_device_get_manufacturer_index (GUsbDevice *device); guint8 g_usb_device_get_product_index (GUsbDevice *device); guint8 g_usb_device_get_serial_number_index (GUsbDevice *device); diff --git a/gusb/libgusb.ver b/gusb/libgusb.ver index a58a451..b32ca1c 100644 --- a/gusb/libgusb.ver +++ b/gusb/libgusb.ver @@ -141,3 +141,9 @@ LIBGUSB_0.3.3 { g_usb_interface_get_endpoints; local: *; } LIBGUSB_0.3.1; + +LIBGUSB_0.3.5 { + global: + g_usb_device_get_configuration_index; + local: *; +} LIBGUSB_0.3.3; |