Skip to content

Commit

Permalink
Add a way to get iConfiguration
Browse files Browse the repository at this point in the history
Adds a getter for a gusb_device to get the string index for the active
configuration's description.
  • Loading branch information
bleungatchromium authored and hughsie committed Jul 29, 2020
1 parent 4a86b08 commit 8e9c458
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions gusb/gusb-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,36 @@ g_usb_device_get_pid_as_str (GUsbDevice *device)
NULL);
}

/**
* 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
Expand Down
1 change: 1 addition & 0 deletions gusb/gusb-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions gusb/libgusb.ver
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 8e9c458

Please sign in to comment.