From c659f9979a482521950c6db74221330dc1895219 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 6 Oct 2012 10:44:56 +0200 Subject: Allow USB IDs to be non-unique. When retrieving USB IDs create a list of players matching to a USB ID instead of assuming only one player. This prevents non-unique IDs overwriting each other and will be used for improved autodetection later. Currently only the first ID is used during detection, and no additional IDs have been added yet. Change-Id: Ieac5594108bae708e364bd2c8df88f61fcdcbdcd --- rbutil/rbutilqt/base/autodetection.cpp | 12 ++++++------ rbutil/rbutilqt/base/systeminfo.cpp | 19 ++++++++++++++----- rbutil/rbutilqt/base/systeminfo.h | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'rbutil') diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index 6427d929c4..0206502202 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp @@ -43,12 +43,12 @@ bool Autodetection::detect() // Try detection via rockbox.info / rbutil.log QStringList mounts = Utils::mountpoints(); + qDebug() << "[Autodetect] paths to check:" << mounts; for(int i=0; i< mounts.size();i++) { // do the file checking QDir dir(mounts.at(i)); - qDebug() << "[Autodetect] paths to check:" << mounts; if(dir.exists()) { // check logfile first. @@ -205,9 +205,9 @@ bool Autodetection::detectUsb() // usbids holds the mapping in the form // ((VID<<16)|(PID)), targetname // the ini file needs to hold the IDs as hex values. - QMap usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice); - QMap usberror = SystemInfo::usbIdMap(SystemInfo::MapError); - QMap usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible); + QMap usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice); + QMap usberror = SystemInfo::usbIdMap(SystemInfo::MapError); + QMap usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible); // usb pid detection QList attached; @@ -216,12 +216,12 @@ bool Autodetection::detectUsb() int i = attached.size(); while(i--) { if(usbids.contains(attached.at(i))) { - m_device = usbids.value(attached.at(i)); + m_device = usbids.value(attached.at(i)).at(0); qDebug() << "[USB] detected supported player" << m_device; return true; } if(usberror.contains(attached.at(i))) { - m_errdev = usberror.value(attached.at(i)); + m_errdev = usberror.value(attached.at(i)).at(0); qDebug() << "[USB] detected problem with player" << m_errdev; return true; } diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp index fde43d27dd..971a1196ac 100644 --- a/rbutil/rbutilqt/base/systeminfo.cpp +++ b/rbutil/rbutilqt/base/systeminfo.cpp @@ -159,11 +159,11 @@ QMap SystemInfo::languages(void) } -QMap SystemInfo::usbIdMap(enum MapType type) +QMap SystemInfo::usbIdMap(enum MapType type) { ensureSystemInfoExists(); - QMap map; + QMap map; // get a list of ID -> target name QStringList platforms; systemInfos->beginGroup("platforms"); @@ -191,9 +191,18 @@ QMap SystemInfo::usbIdMap(enum MapType type) systemInfos->beginGroup(target); QStringList ids = systemInfos->value(t).toStringList(); int j = ids.size(); - while(j--) - map.insert(ids.at(j).toInt(0, 16), target); - + while(j--) { + QStringList l; + int id = ids.at(j).toInt(0, 16); + if(id == 0) { + continue; + } + if(map.keys().contains(id)) { + l = map.take(id); + } + l.append(target); + map.insert(id, l); + } systemInfos->endGroup(); } return map; diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h index 0e603f865e..5e75f36a08 100644 --- a/rbutil/rbutilqt/base/systeminfo.h +++ b/rbutil/rbutilqt/base/systeminfo.h @@ -81,7 +81,7 @@ class SystemInfo : public QObject //! returns a map of all languages static QMap languages(void); //! returns a map of usb-ids and their targets - static QMap usbIdMap(enum MapType); + static QMap usbIdMap(enum MapType type); //! get a value from system settings static QVariant value(enum SystemInfos info); //! get a value from system settings for a named platform. -- cgit v1.2.3