summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2008-06-28 18:06:55 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2008-06-28 18:06:55 +0000
commit9aab06ba0dd71e4095b654ae988377d41ba2dd0f (patch)
tree08ba6294f7b15150432f50848cca035509bf54c4 /rbutil/rbutilqt
parentb4beb05d233a1eab3198edc90ea4158ed3581e6b (diff)
downloadrockbox-9aab06ba0dd71e4095b654ae988377d41ba2dd0f.tar.gz
rockbox-9aab06ba0dd71e4095b654ae988377d41ba2dd0f.tar.bz2
rockbox-9aab06ba0dd71e4095b654ae988377d41ba2dd0f.zip
W32: Make System Info screen also show the device description.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17845 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/detect.cpp29
-rw-r--r--rbutil/rbutilqt/detect.h1
-rw-r--r--rbutil/rbutilqt/sysinfo.cpp12
3 files changed, 33 insertions, 9 deletions
diff --git a/rbutil/rbutilqt/detect.cpp b/rbutil/rbutilqt/detect.cpp
index 16ab856ebc..18f4d23ba5 100644
--- a/rbutil/rbutilqt/detect.cpp
+++ b/rbutil/rbutilqt/detect.cpp
@@ -172,12 +172,17 @@ QString Detect::osVersionString(void)
return result;
}
+QList<uint32_t> Detect::listUsbIds(void)
+{
+ return listUsbDevices().keys();
+}
+
/** @brief detect devices based on usb pid / vid.
* @return list with usb VID / PID values.
*/
-QList<uint32_t> Detect::listUsbIds(void)
+QMap<uint32_t, QString> Detect::listUsbDevices(void)
{
- QList<uint32_t> usbids;
+ QMap<uint32_t, QString> usbids;
// usb pid detection
#if defined(Q_OS_LINUX) | defined(Q_OS_MACX)
usb_init();
@@ -195,7 +200,8 @@ QList<uint32_t> Detect::listUsbIds(void)
while(u) {
uint32_t id;
id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
- if(id) usbids.append(id);
+ // FIXME: until description is empty for now.
+ if(id) usbids.insert(id, QString(""));
u = u->next;
}
}
@@ -221,6 +227,7 @@ QList<uint32_t> Detect::listUsbIds(void)
DWORD data;
LPTSTR buffer = NULL;
DWORD buffersize = 0;
+ QString description;
// get device desriptor first
// for some reason not doing so results in bad things (tm)
@@ -238,6 +245,19 @@ QList<uint32_t> Detect::listUsbIds(void)
// now get the hardware id, which contains PID and VID.
while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
+ SPDRP_LOCATION_INFORMATION,&data, (PBYTE)buffer, buffersize, &buffersize)) {
+ if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ if(buffer) free(buffer);
+ // double buffer size to avoid problems as per KB888609
+ buffer = (LPTSTR)malloc(buffersize * 2);
+ }
+ else {
+ break;
+ }
+ }
+ description = QString::fromWCharArray(buffer);
+
+ while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
SPDRP_HARDWAREID,&data, (PBYTE)buffer, buffersize, &buffersize)) {
if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
if(buffer) free(buffer);
@@ -248,6 +268,7 @@ QList<uint32_t> Detect::listUsbIds(void)
break;
}
}
+ qDebug() << "SetupDiGetDeviceRegistryProperty" << description << QString::fromWCharArray(buffer);
unsigned int vid, pid, rev;
if(_stscanf(buffer, _TEXT("USB\\Vid_%x&Pid_%x&Rev_%x"), &vid, &pid, &rev) != 3) {
@@ -256,7 +277,7 @@ QList<uint32_t> Detect::listUsbIds(void)
else {
uint32_t id;
id = vid << 16 | pid;
- usbids.append(id);
+ usbids.insert(id, description);
qDebug("VID: %04x PID: %04x", vid, pid);
}
if(buffer) free(buffer);
diff --git a/rbutil/rbutilqt/detect.h b/rbutil/rbutilqt/detect.h
index 98d6040ac0..d6ffaeee34 100644
--- a/rbutil/rbutilqt/detect.h
+++ b/rbutil/rbutilqt/detect.h
@@ -39,6 +39,7 @@ public:
static QString userName(void);
static QString osVersionString(void);
static QList<uint32_t> listUsbIds(void);
+ static QMap<uint32_t, QString> listUsbDevices(void);
static QUrl systemProxy(void);
static QString installedVersion(QString mountpoint);
diff --git a/rbutil/rbutilqt/sysinfo.cpp b/rbutil/rbutilqt/sysinfo.cpp
index 4cd2666e8b..7ca4b8585c 100644
--- a/rbutil/rbutilqt/sysinfo.cpp
+++ b/rbutil/rbutilqt/sysinfo.cpp
@@ -42,11 +42,13 @@ void Sysinfo::updateSysinfo(void)
info += tr("<b>Permissions:</b><br/>%1<hr/>").arg(Detect::userPermissionsString());
#endif
info += tr("<b>Attached USB devices:</b><br/>");
- QList<uint32_t> usbids = Detect::listUsbIds();
- for(int i = 0; i < usbids.size(); i++)
- info += tr("VID: %1 PID: %2<br/>")
- .arg((usbids.at(i)&0xffff0000)>>16, 4, 16, QChar('0'))
- .arg(usbids.at(i)&0xffff, 4, 16, QChar('0'));
+ QMap<uint32_t, QString> usbids = Detect::listUsbDevices();
+ QList<uint32_t> usbkeys = usbids.keys();
+ for(int i = 0; i < usbkeys.size(); i++)
+ info += tr("VID: %1 PID: %2, %3<br/>")
+ .arg((usbkeys.at(i)&0xffff0000)>>16, 4, 16, QChar('0'))
+ .arg(usbkeys.at(i)&0xffff, 4, 16, QChar('0'))
+ .arg(usbids.value(usbkeys.at(i)));
ui.textBrowser->setHtml(info);
}