aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/peripherals.xml28
-rw-r--r--xbmc/peripherals/Peripherals.cpp24
-rw-r--r--xbmc/peripherals/devices/Peripheral.cpp25
-rw-r--r--xbmc/peripherals/devices/Peripheral.h2
-rw-r--r--xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp17
5 files changed, 68 insertions, 28 deletions
diff --git a/system/peripherals.xml b/system/peripherals.xml
index 72042ec70d..6c91e49cb0 100644
--- a/system/peripherals.xml
+++ b/system/peripherals.xml
@@ -1,22 +1,22 @@
<peripherals>
<peripheral vendor_product="1915:003B,22B8:003B" bus="usb" name="Motorola Nyxboard Hybrid" mapTo="nyxboard">
- <setting key="keymap_enabled" type="bool" value="1" label="35008" />
+ <setting key="keymap_enabled" type="bool" value="1" label="35008" order="1" />
<setting key="keymap" value="nyxboard" label="35007" configurable="0" />
- <setting key="enable_flip_commands" type="bool" value="1" label="36005" />
- <setting key="flip_keyboard" value="XBMC.VideoLibrary.Search" label="36002" />
- <setting key="flip_remote" value="Dialog.Close(virtualkeyboard)" label="36003" />
- <setting key="key_user" value="" label="36004" />
+ <setting key="enable_flip_commands" type="bool" value="1" label="36005" order="2" />
+ <setting key="flip_keyboard" value="XBMC.VideoLibrary.Search" label="36002" order="3" />
+ <setting key="flip_remote" value="Dialog.Close(virtualkeyboard)" label="36003" order="4" />
+ <setting key="key_user" value="" label="36004" order="5" />
</peripheral>
<peripheral vendor_product="2548:1001" bus="usb" name="Pulse-Eight CEC Adaptor" mapTo="cec">
- <setting key="enabled" type="bool" value="1" label="305" />
- <setting key="port" type="string" value="" label="792" />
- <setting key="cec_hdmi_port" type="int" value="1" min="1" max="16" label="36015" />
- <setting key="cec_power_on_startup" type="bool" value="1" label="36007" />
- <setting key="cec_power_off_shutdown" type="bool" value="1" label="36008" />
- <setting key="cec_standby_screensaver" type="bool" value="1" label="36009" />
- <setting key="standby_pc_on_tv_standby" type="bool" value="1" label="36014" />
- <setting key="use_tv_menu_language" type="bool" value="1" label="36018" />
- <setting key="connected_device" type="int" label="36019" value="0" min="0" max="15" step="1" />
+ <setting key="enabled" type="bool" value="1" label="305" order="1" />
+ <setting key="cec_hdmi_port" type="int" value="1" min="1" max="16" label="36015" order="2" />
+ <setting key="connected_device" type="int" label="36019" value="0" min="0" max="15" step="1" order="3" />
+ <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="4" />
+ <setting key="cec_power_on_startup" type="bool" value="1" label="36007" order="5" />
+ <setting key="cec_power_off_shutdown" type="bool" value="1" label="36008" order="6" />
+ <setting key="cec_standby_screensaver" type="bool" value="1" label="36009" order="7" />
+ <setting key="standby_pc_on_tv_standby" type="bool" value="1" label="36014" order="8" />
+ <setting key="port" type="string" value="" label="792" order="9" />
</peripheral>
</peripherals>
diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp
index 53ce5c2f26..00e7d081fa 100644
--- a/xbmc/peripherals/Peripherals.cpp
+++ b/xbmc/peripherals/Peripherals.cpp
@@ -447,6 +447,8 @@ bool CPeripherals::LoadMappings(void)
void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdString, CSetting *> &m_settings)
{
TiXmlElement *currentNode = xmlNode->FirstChildElement("setting");
+ int iMaxOrder(0);
+
while (currentNode)
{
CSetting *setting = NULL;
@@ -492,10 +494,32 @@ void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdSt
}
//TODO add more types if needed
+
+ /* set the visibility */
setting->SetVisible(bConfigurable);
+
+ /* set the order */
+ int iOrder(0);
+ currentNode->Attribute("order", &iOrder);
+ /* if the order attribute is invalid or 0, then the setting will be added at the end */
+ if (iOrder < 0)
+ iOrder = 0;
+ setting->SetOrder(iOrder);
+ if (iOrder > iMaxOrder)
+ iMaxOrder = iOrder;
+
+ /* and add this new setting */
m_settings[strKey] = setting;
+
currentNode = currentNode->NextSiblingElement("setting");
}
+
+ /* add the settings without an order attribute or an invalid order attribute set at the end */
+ for (map<CStdString, CSetting *>::iterator it = m_settings.begin(); it != m_settings.end(); it++)
+ {
+ if (it->second->GetOrder() == 0)
+ it->second->SetOrder(++iMaxOrder);
+ }
}
void CPeripherals::GetDirectory(const CStdString &strPath, CFileItemList &items) const
diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp
index d07acaf13e..ab14e6cf37 100644
--- a/xbmc/peripherals/devices/Peripheral.cpp
+++ b/xbmc/peripherals/devices/Peripheral.cpp
@@ -30,6 +30,14 @@
using namespace PERIPHERALS;
using namespace std;
+struct SortBySettingsOrder
+{
+ bool operator()(const CSetting *left, const CSetting *right)
+ {
+ return left->GetOrder() < right->GetOrder();
+ }
+};
+
CPeripheral::CPeripheral(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
m_type(type),
m_busType(busType),
@@ -168,6 +176,15 @@ bool CPeripheral::IsMultiFunctional(void) const
return m_subDevices.size() > 0;
}
+vector<CSetting *> CPeripheral::GetSettings(void) const
+{
+ vector<CSetting *> settings;
+ for (map<CStdString, CSetting *>::const_iterator it = m_settings.begin(); it != m_settings.end(); it++)
+ settings.push_back(it->second);
+ sort(settings.begin(), settings.end(), SortBySettingsOrder());
+ return settings;
+}
+
void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
{
if (!setting)
@@ -183,7 +200,7 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
case SETTINGS_TYPE_BOOL:
{
const CSettingBool *mappedSetting = (const CSettingBool *) setting;
- CSettingBool *boolSetting = new CSettingBool(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->GetControlType());
+ CSettingBool *boolSetting = new CSettingBool(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->GetControlType());
if (boolSetting)
{
boolSetting->SetVisible(mappedSetting->IsVisible());
@@ -194,7 +211,7 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
case SETTINGS_TYPE_INT:
{
const CSettingInt *mappedSetting = (const CSettingInt *) setting;
- CSettingInt *intSetting = new CSettingInt(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
+ CSettingInt *intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
if (intSetting)
{
intSetting->SetVisible(mappedSetting->IsVisible());
@@ -205,7 +222,7 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
case SETTINGS_TYPE_FLOAT:
{
const CSettingFloat *mappedSetting = (const CSettingFloat *) setting;
- CSettingFloat *floatSetting = new CSettingFloat(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_fMin, mappedSetting->m_fStep, mappedSetting->m_fMax, mappedSetting->GetControlType());
+ CSettingFloat *floatSetting = new CSettingFloat(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_fMin, mappedSetting->m_fStep, mappedSetting->m_fMax, mappedSetting->GetControlType());
if (floatSetting)
{
floatSetting->SetVisible(mappedSetting->IsVisible());
@@ -216,7 +233,7 @@ void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
case SETTINGS_TYPE_STRING:
{
const CSettingString *mappedSetting = (const CSettingString *) setting;
- CSettingString *stringSetting = new CSettingString(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData().c_str(), mappedSetting->GetControlType(), mappedSetting->m_bAllowEmpty, mappedSetting->m_iHeadingString);
+ CSettingString *stringSetting = new CSettingString(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData().c_str(), mappedSetting->GetControlType(), mappedSetting->m_bAllowEmpty, mappedSetting->m_iHeadingString);
if (stringSetting)
{
stringSetting->SetVisible(mappedSetting->IsVisible());
diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h
index 7851554049..00375bcb5c 100644
--- a/xbmc/peripherals/devices/Peripheral.h
+++ b/xbmc/peripherals/devices/Peripheral.h
@@ -142,6 +142,8 @@ namespace PERIPHERALS
virtual void LoadPersistedSettings(void);
virtual void ResetDefaultSettings(void);
+ virtual std::vector<CSetting *> GetSettings(void) const;
+
virtual bool ErrorOccured(void) const { return m_bError; }
protected:
diff --git a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
index c79f9617cb..cc801efb49 100644
--- a/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
+++ b/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
@@ -66,17 +66,15 @@ void CGUIDialogPeripheralSettings::CreateSettings()
if (m_item)
{
- int iIndex = 1;
CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath());
if (peripheral)
{
- map<CStdString, CSetting *>::iterator it = peripheral->m_settings.begin();
- while (it != peripheral->m_settings.end())
+ vector<CSetting *> settings = peripheral->GetSettings();
+ for (size_t iPtr = 0; iPtr < settings.size(); iPtr++)
{
- CSetting *setting = (*it).second;
+ CSetting *setting = settings[iPtr];
if (!setting->IsVisible())
{
- ++it;
CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__);
continue;
}
@@ -89,7 +87,7 @@ void CGUIDialogPeripheralSettings::CreateSettings()
if (boolSetting)
{
m_boolSettings.insert(make_pair(CStdString(boolSetting->GetSetting()), boolSetting->GetData()));
- AddBool(iIndex++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetSetting()], true);
+ AddBool(boolSetting->GetOrder(), boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetSetting()], true);
}
}
break;
@@ -99,7 +97,7 @@ void CGUIDialogPeripheralSettings::CreateSettings()
if (intSetting)
{
m_intSettings.insert(make_pair(CStdString(intSetting->GetSetting()), (float) intSetting->GetData()));
- AddSlider(iIndex++, intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
+ AddSlider(intSetting->GetOrder(), intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
}
}
break;
@@ -109,7 +107,7 @@ void CGUIDialogPeripheralSettings::CreateSettings()
if (floatSetting)
{
m_floatSettings.insert(make_pair(CStdString(floatSetting->GetSetting()), floatSetting->GetData()));
- AddSlider(iIndex++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetSetting()], floatSetting->m_fMin, floatSetting->m_fStep, floatSetting->m_fMax, CGUIDialogVideoSettings::FormatFloat, false);
+ AddSlider(floatSetting->GetOrder(), floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetSetting()], floatSetting->m_fMin, floatSetting->m_fStep, floatSetting->m_fMax, CGUIDialogVideoSettings::FormatFloat, false);
}
}
break;
@@ -119,7 +117,7 @@ void CGUIDialogPeripheralSettings::CreateSettings()
if (stringSetting)
{
m_stringSettings.insert(make_pair(CStdString(stringSetting->GetSetting()), stringSetting->GetData()));
- AddString(iIndex, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetSetting()]);
+ AddString(stringSetting->GetOrder(), stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetSetting()]);
}
}
break;
@@ -128,7 +126,6 @@ void CGUIDialogPeripheralSettings::CreateSettings()
CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__);
break;
}
- ++it;
}
}
else