forked from len0rd/rockbox
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
This commit is contained in:
parent
71f70112b2
commit
c659f9979a
3 changed files with 21 additions and 12 deletions
|
@ -43,12 +43,12 @@ bool Autodetection::detect()
|
||||||
|
|
||||||
// Try detection via rockbox.info / rbutil.log
|
// Try detection via rockbox.info / rbutil.log
|
||||||
QStringList mounts = Utils::mountpoints();
|
QStringList mounts = Utils::mountpoints();
|
||||||
|
qDebug() << "[Autodetect] paths to check:" << mounts;
|
||||||
|
|
||||||
for(int i=0; i< mounts.size();i++)
|
for(int i=0; i< mounts.size();i++)
|
||||||
{
|
{
|
||||||
// do the file checking
|
// do the file checking
|
||||||
QDir dir(mounts.at(i));
|
QDir dir(mounts.at(i));
|
||||||
qDebug() << "[Autodetect] paths to check:" << mounts;
|
|
||||||
if(dir.exists())
|
if(dir.exists())
|
||||||
{
|
{
|
||||||
// check logfile first.
|
// check logfile first.
|
||||||
|
@ -205,9 +205,9 @@ bool Autodetection::detectUsb()
|
||||||
// usbids holds the mapping in the form
|
// usbids holds the mapping in the form
|
||||||
// ((VID<<16)|(PID)), targetname
|
// ((VID<<16)|(PID)), targetname
|
||||||
// the ini file needs to hold the IDs as hex values.
|
// the ini file needs to hold the IDs as hex values.
|
||||||
QMap<int, QString> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice);
|
QMap<int, QStringList> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice);
|
||||||
QMap<int, QString> usberror = SystemInfo::usbIdMap(SystemInfo::MapError);
|
QMap<int, QStringList> usberror = SystemInfo::usbIdMap(SystemInfo::MapError);
|
||||||
QMap<int, QString> usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible);
|
QMap<int, QStringList> usbincompat = SystemInfo::usbIdMap(SystemInfo::MapIncompatible);
|
||||||
|
|
||||||
// usb pid detection
|
// usb pid detection
|
||||||
QList<uint32_t> attached;
|
QList<uint32_t> attached;
|
||||||
|
@ -216,12 +216,12 @@ bool Autodetection::detectUsb()
|
||||||
int i = attached.size();
|
int i = attached.size();
|
||||||
while(i--) {
|
while(i--) {
|
||||||
if(usbids.contains(attached.at(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;
|
qDebug() << "[USB] detected supported player" << m_device;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(usberror.contains(attached.at(i))) {
|
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;
|
qDebug() << "[USB] detected problem with player" << m_errdev;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,11 +159,11 @@ QMap<QString, QStringList> SystemInfo::languages(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<int, QString> SystemInfo::usbIdMap(enum MapType type)
|
QMap<int, QStringList> SystemInfo::usbIdMap(enum MapType type)
|
||||||
{
|
{
|
||||||
ensureSystemInfoExists();
|
ensureSystemInfoExists();
|
||||||
|
|
||||||
QMap<int, QString> map;
|
QMap<int, QStringList> map;
|
||||||
// get a list of ID -> target name
|
// get a list of ID -> target name
|
||||||
QStringList platforms;
|
QStringList platforms;
|
||||||
systemInfos->beginGroup("platforms");
|
systemInfos->beginGroup("platforms");
|
||||||
|
@ -191,9 +191,18 @@ QMap<int, QString> SystemInfo::usbIdMap(enum MapType type)
|
||||||
systemInfos->beginGroup(target);
|
systemInfos->beginGroup(target);
|
||||||
QStringList ids = systemInfos->value(t).toStringList();
|
QStringList ids = systemInfos->value(t).toStringList();
|
||||||
int j = ids.size();
|
int j = ids.size();
|
||||||
while(j--)
|
while(j--) {
|
||||||
map.insert(ids.at(j).toInt(0, 16), target);
|
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();
|
systemInfos->endGroup();
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
|
|
@ -81,7 +81,7 @@ class SystemInfo : public QObject
|
||||||
//! returns a map of all languages
|
//! returns a map of all languages
|
||||||
static QMap<QString, QStringList> languages(void);
|
static QMap<QString, QStringList> languages(void);
|
||||||
//! returns a map of usb-ids and their targets
|
//! returns a map of usb-ids and their targets
|
||||||
static QMap<int, QString> usbIdMap(enum MapType);
|
static QMap<int, QStringList> usbIdMap(enum MapType type);
|
||||||
//! get a value from system settings
|
//! get a value from system settings
|
||||||
static QVariant value(enum SystemInfos info);
|
static QVariant value(enum SystemInfos info);
|
||||||
//! get a value from system settings for a named platform.
|
//! get a value from system settings for a named platform.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue