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();
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();
}
class FGDeviceConfigurationMap
{
public:
- FGDeviceConfigurationMap ( const std::string& relative_path);
+ FGDeviceConfigurationMap ( const std::string& relative_path,
+ SGPropertyNode* nodePath,
+ const std::string& nodeName);
virtual ~FGDeviceConfigurationMap();
SGPropertyNode_ptr configurationForDeviceName(const std::string& name);
void readCachedData(const SGPath& path);
void refreshCacheForFile(const SGPath& path);
+ typedef std::map<std::string, SGPropertyNode_ptr> NameNodeMap;
+// dictionary of over-ridden configurations, where the config data
+// was explicitly loaded and shoudl be picked over a file search
+ NameNodeMap overrideDict;
+
typedef std::map<std::string, SGPath> NamePathMap;
// mapping from joystick name to XML configuration file path
NamePathMap namePathMap;
const char * FGEventInput::PROPERTY_ROOT = "/input/event";
FGEventInput::FGEventInput() :
- configMap( "Input/Event")
+ configMap( "Input/Event", fgGetNode(PROPERTY_ROOT, true), "device-named")
{
}
SGPropertyNode_ptr js_nodes = fgGetNode("/input/joysticks", true);
status_node = fgGetNode("/devices/status/joysticks", true);
- FGDeviceConfigurationMap configMap("Input/Joysticks");
+ FGDeviceConfigurationMap configMap("Input/Joysticks",js_nodes, "js-named");
for (int i = 0; i < MAX_JOYSTICKS; i++) {
jsJoystick * js = new jsJoystick(i);