forked from len0rd/rockbox
Support libusb-1.0.
Use "qmake -config libusb1" to use libusb-1.0 instead of libusb-0.1. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22205 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bd5b744a6d
commit
363cbc22b5
2 changed files with 49 additions and 1 deletions
|
|
@ -40,7 +40,11 @@
|
||||||
|
|
||||||
// Linux and Mac includes
|
// Linux and Mac includes
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
|
#if defined(LIBUSB1)
|
||||||
|
#include <libusb-1.0/libusb.h>
|
||||||
|
#else
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
|
#endif
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
@ -190,7 +194,45 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
||||||
{
|
{
|
||||||
QMap<uint32_t, QString> usbids;
|
QMap<uint32_t, QString> usbids;
|
||||||
// usb pid detection
|
// usb pid detection
|
||||||
|
qDebug() << "[Detect] Searching for USB devices";
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
|
#if defined(LIBUSB1)
|
||||||
|
libusb_device **devs;
|
||||||
|
int res;
|
||||||
|
ssize_t count;
|
||||||
|
res = libusb_init(NULL);
|
||||||
|
|
||||||
|
count = libusb_get_device_list(NULL, &devs);
|
||||||
|
libusb_device *dev;
|
||||||
|
int i = 0;
|
||||||
|
while((dev = devs[i++]) != NULL) {
|
||||||
|
QString name;
|
||||||
|
unsigned char buf[256];
|
||||||
|
uint32_t id;
|
||||||
|
struct libusb_device_descriptor descriptor;
|
||||||
|
if(libusb_get_device_descriptor(dev, &descriptor) == 0) {
|
||||||
|
id = descriptor.idVendor << 16 | descriptor.idProduct;
|
||||||
|
|
||||||
|
libusb_device_handle *dh;
|
||||||
|
if(libusb_open(dev, &dh) == 0) {
|
||||||
|
libusb_get_string_descriptor_ascii(dh, descriptor.iManufacturer, buf, 256);
|
||||||
|
name += QString::fromAscii((char*)buf) + " ";
|
||||||
|
libusb_get_string_descriptor_ascii(dh, descriptor.iProduct, buf, 256);
|
||||||
|
name += QString::fromAscii((char*)buf);
|
||||||
|
libusb_close(dh);
|
||||||
|
}
|
||||||
|
if(name.isEmpty())
|
||||||
|
name = QObject::tr("(no description available)");
|
||||||
|
if(id) {
|
||||||
|
usbids.insert(id, name);
|
||||||
|
qDebug("[Detect] USB: 0x%08x, %s", id, name.toLocal8Bit().data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
libusb_free_device_list(devs, 1);
|
||||||
|
libusb_exit(NULL);
|
||||||
|
#else
|
||||||
usb_init();
|
usb_init();
|
||||||
usb_find_busses();
|
usb_find_busses();
|
||||||
usb_find_devices();
|
usb_find_devices();
|
||||||
|
|
@ -237,6 +279,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
HDEVINFO deviceInfo;
|
HDEVINFO deviceInfo;
|
||||||
|
|
|
||||||
|
|
@ -209,9 +209,14 @@ unix {
|
||||||
SOURCES += ../ipodpatcher/ipodio-posix.c
|
SOURCES += ../ipodpatcher/ipodio-posix.c
|
||||||
SOURCES += ../sansapatcher/sansaio-posix.c
|
SOURCES += ../sansapatcher/sansaio-posix.c
|
||||||
}
|
}
|
||||||
unix:!static {
|
unix:!static:!libusb1 {
|
||||||
LIBS += -lusb
|
LIBS += -lusb
|
||||||
}
|
}
|
||||||
|
unix:!static:libusb1 {
|
||||||
|
DEFINES += LIBUSB1
|
||||||
|
LIBS += -lusb-1.0
|
||||||
|
}
|
||||||
|
|
||||||
unix:static {
|
unix:static {
|
||||||
# force statically linking of libusb. Libraries that are appended
|
# force statically linking of libusb. Libraries that are appended
|
||||||
# later will get linked dynamically again.
|
# later will get linked dynamically again.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue