From: mfranz Date: Sun, 12 Jun 2005 19:27:20 +0000 (+0000) Subject: leave temporary hint for the nasal init block, so that it can access X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dec07ab83e9ec1cb413e3e042dceb552b85ea376;p=flightgear.git leave temporary hint for the nasal init block, so that it can access its own data, and can distinguish itself from other instances of the same js driver. This property is removed after script execution. Example: self = props.globals.getNode(getprop("/input/joysticks/this")); --- diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 799fd50e0..4f8926da5 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -466,7 +466,7 @@ FGInput::_init_joystick () if ((named = jsmap[name])) { string source = named->getStringValue("source", "user defined"); - SG_LOG(SG_INPUT, SG_INFO, "... found joystick: \"" << source << '"'); + SG_LOG(SG_INPUT, SG_INFO, "... found joystick: " << source); } else if ((named = jsmap["default"])) { string source = named->getStringValue("source", "user defined"); @@ -474,7 +474,8 @@ FGInput::_init_joystick () << "\"\nUsing default: \"" << source << '"'); } else { - throw sg_throwable(string("No joystick configuration file with default entry found!")); + throw sg_throwable(string("No joystick configuration file with " + "default entry found!")); } js_node = js_nodes->getChild("js", i, true); @@ -603,12 +604,17 @@ FGInput::_init_joystick () void FGInput::_postinit_joystick() { - vector js = fgGetNode("/input/joysticks")->getChildren("js"); + SGPropertyNode *js_nodes = fgGetNode("/input/joysticks"); + vector js = js_nodes->getChildren("js"); for (unsigned int i = 0; i < js.size(); i++) { + // leave temporary hint for the nasal init block + js_nodes->setStringValue("this", js[i]->getPath()); + vector nasal = js[i]->getChildren("nasal"); for (unsigned int j = 0; j < nasal.size(); j++) ((FGNasalSys*)globals->get_subsystem("nasal"))->handleCommand(nasal[j]); } + js_nodes->removeChild("this", 0); }