1
0
Fork 0

Revert the previous patch. The <target-platform> tag is not supported

anymore. Instead Frederic Bouvier suggests to add a <number> tag to
the axis definition which accepts values for <windows> and <unix>
for now but which can be extended later on:

<axis>
 <desc>Rudder</desc>
 <number>
  <unix>2</unix>
  <windows>3</windows>
 </number>
 <binding>
  <command>property-scale</command>
  <property>/controls/flight/rudder</property>
  <offset type="double">0.0</offset>
  <factor type="double">1.0</factor>
  <power type="double">2.0</power>
 </binding>
</axis>
This commit is contained in:
ehofman 2004-04-28 08:03:40 +00:00
parent dd4d116e00
commit dd2e2c21a6
2 changed files with 28 additions and 25 deletions

View file

@ -404,12 +404,6 @@ FGInput::_init_joystick ()
vector<SGPropertyNode_ptr> 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<SGPropertyNode_ptr> 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<SGPropertyNode_ptr> 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];
axis &a = _joystick_bindings[i].axes[n_axe];
js->setDeadBand(j, axis_node->getDoubleValue("dead-band", 0.0));
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<SGPropertyNode_ptr> 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;

View file

@ -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