From 1669820bba132b898159cc433515a87c08fee7a4 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 4 Jul 2002 17:38:18 +0000 Subject: [PATCH] Modified to use named-joystick bindings when available (js-named rather than js). This functionality is available only with recent CVS plib versions (i.e. since about May 2002). --- src/Input/input.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 0ee0ebbdf..bb350b432 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -471,7 +471,7 @@ FGInput::_init_joystick () } for (int i = 0; i < MAX_JOYSTICKS; i++) { - SGPropertyNode * js_node = js_nodes->getChild("js", i); + SGPropertyNode_ptr js_node = js_nodes->getChild("js", i); if (js_node == 0) { SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for joystick " << i); js_node = js_nodes->getChild("js", i, true); @@ -483,8 +483,19 @@ FGInput::_init_joystick () continue; } else { #ifdef FG_PLIB_JOYSTICK_GETNAME - SG_LOG(SG_INPUT, SG_INFO, ""); - SG_LOG(SG_INPUT, SG_INFO, "Found joystick " << js->getName()); + const char * name = js->getName(); + std::cout << "Looking for bindings for joystick \"" + << name << '"' << std::endl; + vector nodes = js_nodes->getChildren("js-named"); + for (int i = 0; i < nodes.size(); i++) { + SGPropertyNode_ptr node = nodes[i]; + std::cout << " Trying \"" << node->getStringValue("name") << '"' << std::endl; + if (!strcmp(node->getStringValue("name"), name)) { + std::cout << " Found bindings" << std::endl; + js_node = node; + break; + } + } #endif } #ifdef WIN32