diff options
author | Ondrej Čerman <ondrej.cerman@gmail.com> | 2019-12-28 20:02:36 +0100 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-12-29 21:46:38 -0800 |
commit | c125634658751d67492f8640d33247ed3760e481 (patch) | |
tree | c26ad81357f9d8485a6b12823cb40825bb37e84b /hardinfo | |
parent | 145d70e0a9696e194168eafadb3600c034df9e08 (diff) |
inputdevices: Added new vendor info + info from usb.ids
Diffstat (limited to 'hardinfo')
-rw-r--r-- | hardinfo/usb_util.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/hardinfo/usb_util.c b/hardinfo/usb_util.c index 8b73332f..990ae78e 100644 --- a/hardinfo/usb_util.c +++ b/hardinfo/usb_util.c @@ -317,7 +317,7 @@ static gboolean usb_get_interface_sysfs(int conf, int number, return TRUE; } -void find_usb_ids_file() { +static void find_usb_ids_file() { if (usb_ids_file) return; char *file_search_order[] = { g_build_filename(g_get_user_config_dir(), "hardinfo", "usb.ids", NULL), @@ -333,6 +333,25 @@ void find_usb_ids_file() { } } +void usb_lookup_ids_vendor_product_str(gint vendor_id, gint product_id, + gchar **vendor_str, gchar **product_str) { + ids_query_result result = {}; + gchar *qpath; + + if (!usb_ids_file) + find_usb_ids_file(); + if (!usb_ids_file) + return; + + qpath = g_strdup_printf("%04x/%04x", vendor_id, product_id); + scan_ids_file(usb_ids_file, qpath, &result, -1); + if (result.results[0]) + *vendor_str = g_strdup(result.results[0]); + if (result.results[1]) + *product_str = g_strdup(result.results[1]); + g_free(qpath); +} + static gboolean usb_get_device_sysfs(int bus, int dev, const char* sysfspath, usbd *s) { usbi *intf; gboolean ok; |