diff --git a/src/Input/input.cxx b/src/Input/input.cxx index f4df2882e..cc6ca78fe 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -551,7 +551,14 @@ FGInput::_init_joystick () _init_button(js_node->getChild("button", j), _joystick_bindings[i].buttons[j], buf); - + + // get interval-sec property + button &b = _joystick_bindings[i].buttons[j]; + const SGPropertyNode * button_node = js_node->getChild("button", j); + if (button_node != 0) { + b.interval_sec = button_node->getDoubleValue("interval-sec",0.0); + b.last_dt = 0.0; + } } js->setMinRange(minRange); @@ -748,10 +755,15 @@ FGInput::_update_joystick (double dt) // Fire bindings for the buttons. for (j = 0; j < _joystick_bindings[i].nbuttons; j++) { - _update_button(_joystick_bindings[i].buttons[j], - modifiers, - (buttons & (1 << j)) > 0, - -1, -1); + button &b = _joystick_bindings[i].buttons[j]; + b.last_dt += dt; + if(b.last_dt >= b.interval_sec) { + _update_button(_joystick_bindings[i].buttons[j], + modifiers, + (buttons & (1 << j)) > 0, + -1, -1); + b.last_dt -= b.interval_sec; + } } } } diff --git a/src/Input/input.hxx b/src/Input/input.hxx index 3fe0783b8..690619ec3 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -279,6 +279,8 @@ private: button (); virtual ~button (); bool is_repeatable; + float interval_sec; + float last_dt; int last_state; binding_list_t bindings[FG_MOD_MAX]; };