From dd2e2c21a62c5969b41b6f26fb32734e07dd4f29 Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 28 Apr 2004 08:03:40 +0000 Subject: [PATCH] Revert the previous patch. The tag is not supported anymore. Instead Frederic Bouvier suggests to add a tag to the axis definition which accepts values for and for now but which can be extended later on: Rudder 2 3 property-scale /controls/flight/rudder 0.0 1.0 2.0 --- src/Input/input.cxx | 49 ++++++++++++++++++++++++--------------------- src/Input/input.hxx | 4 ++-- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 04b356a38..b25eb088a 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -404,12 +404,6 @@ FGInput::_init_joystick () vector nodes = js_nodes->getChildren("js-named"); for (unsigned int i = 0; i < nodes.size(); i++) { SGPropertyNode_ptr node = nodes[i]; - SGPropertyNode *tgt = node->getNode("target-platform", false); - if (tgt != NULL) { - if ((strcmp(tgt->getStringValue(), TGT_PLATFORM) != NULL) && - (strcmp(tgt->getStringValue(), "All") != NULL)) - continue; // Different target platform - } vector name_nodes = node->getChildren("name"); for (unsigned int j = 0; j < name_nodes.size(); j++) { const char * js_name = name_nodes[j]->getStringValue(); @@ -459,22 +453,25 @@ FGInput::_init_joystick () // // Initialize the axes. // + vector axes = js_node->getChildren("axis"); + size_t nb_axes = axes.size(); int j; - for (j = 0; j < naxes; j++) { - const SGPropertyNode * axis_node = js_node->getChild("axis", j); - if (axis_node == 0) { - SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for axis " << j); - axis_node = js_node->getChild("axis", j, true); + for (j = 0; j < nb_axes; j++) { + const SGPropertyNode * axis_node = axes[j]; + const SGPropertyNode * num_node = axis_node->getChild("number"); + size_t n_axe = axis_node->getIndex(); + if (num_node != 0) { + n_axe = num_node->getIntValue(TGT_PLATFORM,n_axe); } - - axis &a = _joystick_bindings[i].axes[j]; - js->setDeadBand(j, axis_node->getDoubleValue("dead-band", 0.0)); + axis &a = _joystick_bindings[i].axes[n_axe]; + + js->setDeadBand(n_axe, axis_node->getDoubleValue("dead-band", 0.0)); a.tolerance = axis_node->getDoubleValue("tolerance", 0.002); - minRange[j] = axis_node->getDoubleValue("min-range", minRange[j]); - maxRange[j] = axis_node->getDoubleValue("max-range", maxRange[j]); - center[j] = axis_node->getDoubleValue("center", center[j]); + minRange[n_axe] = axis_node->getDoubleValue("min-range", minRange[n_axe]); + maxRange[n_axe] = axis_node->getDoubleValue("max-range", maxRange[n_axe]); + center[n_axe] = axis_node->getDoubleValue("center", center[n_axe]); _read_bindings(axis_node, a.bindings, KEYMOD_NONE); @@ -491,17 +488,23 @@ FGInput::_init_joystick () // // Initialize the buttons. // + vector buttons = js_node->getChildren("button"); char buf[32]; for (j = 0; j < nbuttons; j++) { - sprintf(buf, "%d", j); - SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << j); - _init_button(js_node->getChild("button", j), - _joystick_bindings[i].buttons[j], + const SGPropertyNode * button_node = buttons[j]; + const SGPropertyNode * num_node = button_node->getChild("number"); + size_t n_but = button_node->getIndex(); + if (num_node != 0) { + n_but = num_node->getIntValue(TGT_PLATFORM,n_but); + } + sprintf(buf, "%d", n_but); + SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << n_but); + _init_button(button_node, + _joystick_bindings[i].buttons[n_but], buf); // get interval-sec property - button &b = _joystick_bindings[i].buttons[j]; - const SGPropertyNode * button_node = js_node->getChild("button", j); + button &b = _joystick_bindings[i].buttons[n_but]; if (button_node != 0) { b.interval_sec = button_node->getDoubleValue("interval-sec",0.0); b.last_dt = 0.0; diff --git a/src/Input/input.hxx b/src/Input/input.hxx index e61d9c95d..e2bcb9744 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -52,9 +52,9 @@ SG_USING_STD(vector); #if defined( UL_WIN32 ) -#define TGT_PLATFORM "Windows" +#define TGT_PLATFORM "windows" #else -#define TGT_PLATFORM "UNIX" +#define TGT_PLATFORM "unix" #endif