X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInput%2Finput.cxx;h=98432a6f01803e7b43d3737015601296a27927e1;hb=f88a9aab6a097c65960e978444f64f0ea8a022a1;hp=dea8995c52eb7a5c818b1469c126bdc7aa96edb9;hpb=886d0036885ec162c9bac3ef0bc97db5d316f9e8;p=flightgear.git diff --git a/src/Input/input.cxx b/src/Input/input.cxx index dea8995c5..98432a6f0 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -179,6 +179,12 @@ FGInput::init () fgRegisterMouseMotionHandler(mouseMotionHandler); } +void +FGInput::reinit () +{ + init(); +} + void FGInput::update (double dt) { @@ -470,9 +476,18 @@ FGInput::_init_joystick () const SGPropertyNode * num_node = axis_node->getChild("number"); size_t n_axis = axis_node->getIndex(); if (num_node != 0) { - n_axis = num_node->getIntValue(TGT_PLATFORM,n_axis); + n_axis = num_node->getIntValue(TGT_PLATFORM, -1); + + // Silently ignore platforms that are not specified within the + // section + if (n_axis < 0) + continue; } + if (n_axis >= (size_t)naxes) { + SG_LOG(SG_INPUT, SG_DEBUG, "Dropping bindings for axis " << n_axis); + continue; + } axis &a = _joystick_bindings[i].axes[n_axis]; js->setDeadBand(n_axis, axis_node->getDoubleValue("dead-band", 0.0)); @@ -506,6 +521,12 @@ FGInput::_init_joystick () if (num_node != 0) { n_but = num_node->getIntValue(TGT_PLATFORM,n_but); } + + if (n_but >= (size_t)nbuttons) { + SG_LOG(SG_INPUT, SG_DEBUG, "Dropping bindings for button " << n_but); + continue; + } + sprintf(buf, "%d", n_but); SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << n_but); _init_button(button_node, @@ -535,7 +556,7 @@ FGInput::_init_joystick () // cursors defined as textures referenced in the property tree. This // list could then be eliminated. -Andy // -struct { +static struct { const char * name; int cursor; } mouse_cursor_map[] = {