using simgear::PropertyList;
using std::string;
-FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path)
+FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path,
+ SGPropertyNode* nodePath,
+ const std::string& nodeName)
{
+ // scan for over-ride configurations, loaded via joysticks.xml, etc
+ BOOST_FOREACH(SGPropertyNode_ptr preloaded, nodePath->getChildren(nodeName)) {
+ BOOST_FOREACH(SGPropertyNode* nameProp, preloaded->getChildren("name")) {
+ overrideDict[nameProp->getStringValue()] = preloaded;
+ } // of names iteration
+ } // of defined overrides iteration
+
scan_dir( SGPath(globals->get_fg_home(), relative_path));
scan_dir( SGPath(globals->get_fg_root(), relative_path));
}
SGPropertyNode_ptr
FGDeviceConfigurationMap::configurationForDeviceName(const std::string& name)
{
+ NameNodeMap::iterator j = overrideDict.find(name);
+ if (j != overrideDict.end()) {
+ return j->second;
+ }
+
+// no override, check out list of config files
NamePathMap::iterator it = namePathMap.find(name);
if (it == namePathMap.end()) {
return SGPropertyNode_ptr();
try {
readProperties(it->second.str(), result);
result->setStringValue("source", it->second.c_str());
- } catch (sg_exception& e) {
+ } catch (sg_exception&) {
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << it->second);
return NULL;
}
bool FGDeviceConfigurationMap::hasConfiguration(const std::string& name) const
{
+ NameNodeMap::const_iterator j = overrideDict.find(name);
+ if (j != overrideDict.end()) {
+ return true;
+ }
+
return namePathMap.find(name) != namePathMap.end();
}
SGPropertyNode_ptr n(new SGPropertyNode);
try {
readProperties(path.str(), n);
- } catch (sg_exception& e) {
+ } catch (sg_exception&) {
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << path);
return;
}