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).
This commit is contained in:
parent
2fec1506d3
commit
1669820bba
1 changed files with 14 additions and 3 deletions
|
@ -471,7 +471,7 @@ FGInput::_init_joystick ()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_JOYSTICKS; i++) {
|
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) {
|
if (js_node == 0) {
|
||||||
SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for joystick " << i);
|
SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for joystick " << i);
|
||||||
js_node = js_nodes->getChild("js", i, true);
|
js_node = js_nodes->getChild("js", i, true);
|
||||||
|
@ -483,8 +483,19 @@ FGInput::_init_joystick ()
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
#ifdef FG_PLIB_JOYSTICK_GETNAME
|
#ifdef FG_PLIB_JOYSTICK_GETNAME
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "");
|
const char * name = js->getName();
|
||||||
SG_LOG(SG_INPUT, SG_INFO, "Found joystick " << js->getName());
|
std::cout << "Looking for bindings for joystick \""
|
||||||
|
<< name << '"' << std::endl;
|
||||||
|
vector<SGPropertyNode_ptr> 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
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
Loading…
Reference in a new issue