Add the ability to add repeat intervals to joystick buttons using the interval-sec property
This commit is contained in:
parent
b1bfd1aa27
commit
709f57fe91
2 changed files with 19 additions and 5 deletions
|
@ -551,7 +551,14 @@ FGInput::_init_joystick ()
|
||||||
_init_button(js_node->getChild("button", j),
|
_init_button(js_node->getChild("button", j),
|
||||||
_joystick_bindings[i].buttons[j],
|
_joystick_bindings[i].buttons[j],
|
||||||
buf);
|
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);
|
js->setMinRange(minRange);
|
||||||
|
@ -748,10 +755,15 @@ FGInput::_update_joystick (double dt)
|
||||||
|
|
||||||
// Fire bindings for the buttons.
|
// Fire bindings for the buttons.
|
||||||
for (j = 0; j < _joystick_bindings[i].nbuttons; j++) {
|
for (j = 0; j < _joystick_bindings[i].nbuttons; j++) {
|
||||||
_update_button(_joystick_bindings[i].buttons[j],
|
button &b = _joystick_bindings[i].buttons[j];
|
||||||
modifiers,
|
b.last_dt += dt;
|
||||||
(buttons & (1 << j)) > 0,
|
if(b.last_dt >= b.interval_sec) {
|
||||||
-1, -1);
|
_update_button(_joystick_bindings[i].buttons[j],
|
||||||
|
modifiers,
|
||||||
|
(buttons & (1 << j)) > 0,
|
||||||
|
-1, -1);
|
||||||
|
b.last_dt -= b.interval_sec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,6 +279,8 @@ private:
|
||||||
button ();
|
button ();
|
||||||
virtual ~button ();
|
virtual ~button ();
|
||||||
bool is_repeatable;
|
bool is_repeatable;
|
||||||
|
float interval_sec;
|
||||||
|
float last_dt;
|
||||||
int last_state;
|
int last_state;
|
||||||
binding_list_t bindings[FG_MOD_MAX];
|
binding_list_t bindings[FG_MOD_MAX];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue