haiku/headers/private/shared/usb-utils.h
Jérôme Duval 4ea3e0d3b8 listusb: display USB vendor and devices names based on usb.ids
* download usb.ids, processed like pci.ids to generate a header.
* best would be to load and parse the file at runtime with shared code.
2012-02-18 14:25:10 +01:00

44 lines
904 B
C

/*
* Copyright 2008-2012, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Jérôme Duval
*/
#include <stdio.h>
#include "usbhdr.h"
void
usb_get_vendor_info(uint16 vendorID, const char **vendorName)
{
int i;
for (i = 0; i < (int)USB_VENTABLE_LEN; i++) {
if (UsbVenTable[i].VenId == vendorID) {
*vendorName = UsbVenTable[i].VenName && UsbVenTable[i].VenName[0]
? UsbVenTable[i].VenName : NULL;
return;
}
}
*vendorName = NULL;
}
void
usb_get_device_info(uint16 vendorID, uint16 deviceID, const char **deviceName)
{
int i;
// search for the device
for (i = 0; i < (int)USB_DEVTABLE_LEN; i++) {
if (UsbDevTable[i].VenId == vendorID && UsbDevTable[i].DevId == deviceID ) {
*deviceName = UsbDevTable[i].ChipDesc && UsbDevTable[i].ChipDesc[0]
? UsbDevTable[i].ChipDesc : NULL;
return;
}
}
*deviceName = NULL;
}