summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-08-08 12:28:47 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-08-08 12:28:47 +0000
commit363cbc22b57b1a491176dab6b7f4ca5b6f8bdb52 (patch)
treee413cff1065ca37c7041a86fb416d249bd9474f0
parentbd5b744a6daa17f99a528bd62fdc45203d17233e (diff)
downloadrockbox-363cbc22b57b1a491176dab6b7f4ca5b6f8bdb52.tar.gz
rockbox-363cbc22b57b1a491176dab6b7f4ca5b6f8bdb52.zip
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
-rw-r--r--rbutil/rbutilqt/base/detect.cpp43
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro7
2 files changed, 49 insertions, 1 deletions
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/detect.cpp
index d471c98273..9eaa1c9bb7 100644
--- a/rbutil/rbutilqt/base/detect.cpp
+++ b/rbutil/rbutilqt/base/detect.cpp
@@ -40,7 +40,11 @@
// Linux and Mac includes
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+#if defined(LIBUSB1)
+#include <libusb-1.0/libusb.h>
+#else
#include <usb.h>
+#endif
#include <sys/utsname.h>
#include <unistd.h>
#include <pwd.h>
@@ -190,7 +194,45 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
{
QMap<uint32_t, QString> usbids;
// usb pid detection
+ qDebug() << "[Detect] Searching for USB devices";
#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_find_busses();
usb_find_devices();
@@ -237,6 +279,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
b = b->next;
}
#endif
+#endif
#if defined(Q_OS_WIN32)
HDEVINFO deviceInfo;
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 20adb71e47..998bffc8ad 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -209,9 +209,14 @@ unix {
SOURCES += ../ipodpatcher/ipodio-posix.c
SOURCES += ../sansapatcher/sansaio-posix.c
}
-unix:!static {
+unix:!static:!libusb1 {
LIBS += -lusb
}
+unix:!static:libusb1 {
+ DEFINES += LIBUSB1
+ LIBS += -lusb-1.0
+}
+
unix:static {
# force statically linking of libusb. Libraries that are appended
# later will get linked dynamically again.