- Don't consider modifiers in axis bindings, as this means to
temporarily lose control over the aircraft while pressing a modifier for a button. - cosmetics: remove trailing spaces and commented out debug messages
This commit is contained in:
parent
9bc662e655
commit
80560b6633
1 changed files with 9 additions and 15 deletions
|
@ -821,14 +821,11 @@ FGInput::_update_keyboard ()
|
||||||
void
|
void
|
||||||
FGInput::_update_joystick (double dt)
|
FGInput::_update_joystick (double dt)
|
||||||
{
|
{
|
||||||
|
float axis_values[MAX_JOYSTICK_AXES];
|
||||||
int modifiers = fgGetKeyModifiers();
|
int modifiers = fgGetKeyModifiers();
|
||||||
int buttons;
|
int buttons;
|
||||||
float axis_values[MAX_JOYSTICK_AXES];
|
|
||||||
|
|
||||||
int i;
|
for (int i = 0; i < MAX_JOYSTICKS; i++) {
|
||||||
int j;
|
|
||||||
|
|
||||||
for ( i = 0; i < MAX_JOYSTICKS; i++) {
|
|
||||||
|
|
||||||
jsJoystick * js = _joystick_bindings[i].js;
|
jsJoystick * js = _joystick_bindings[i].js;
|
||||||
if (js == 0 || js->notWorking())
|
if (js == 0 || js->notWorking())
|
||||||
|
@ -837,21 +834,18 @@ FGInput::_update_joystick (double dt)
|
||||||
js->read(&buttons, axis_values);
|
js->read(&buttons, axis_values);
|
||||||
|
|
||||||
// Fire bindings for the axes.
|
// Fire bindings for the axes.
|
||||||
for ( j = 0; j < _joystick_bindings[i].naxes; j++) {
|
for (int j = 0; j < _joystick_bindings[i].naxes; j++) {
|
||||||
axis &a = _joystick_bindings[i].axes[j];
|
axis &a = _joystick_bindings[i].axes[j];
|
||||||
|
|
||||||
// Do nothing if the axis position
|
// Do nothing if the axis position
|
||||||
// is unchanged; only a change in
|
// is unchanged; only a change in
|
||||||
// position fires the bindings.
|
// position fires the bindings.
|
||||||
if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
|
if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
|
||||||
// SG_LOG(SG_INPUT, SG_DEBUG, "Axis " << j << " has moved");
|
|
||||||
a.last_value = axis_values[j];
|
a.last_value = axis_values[j];
|
||||||
// SG_LOG(SG_INPUT, SG_DEBUG, "There are "
|
for (unsigned int k = 0; k < a.bindings[KEYMOD_NONE].size(); k++)
|
||||||
// << a.bindings[modifiers].size() << " bindings");
|
a.bindings[KEYMOD_NONE][k]->fire(axis_values[j]);
|
||||||
for (unsigned int k = 0; k < a.bindings[modifiers].size(); k++)
|
|
||||||
a.bindings[modifiers][k]->fire(axis_values[j]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we have to emulate axis buttons?
|
// do we have to emulate axis buttons?
|
||||||
a.last_dt += dt;
|
a.last_dt += dt;
|
||||||
if(a.last_dt >= a.interval_sec) {
|
if(a.last_dt >= a.interval_sec) {
|
||||||
|
@ -860,7 +854,7 @@ FGInput::_update_joystick (double dt)
|
||||||
modifiers,
|
modifiers,
|
||||||
axis_values[j] < a.low_threshold,
|
axis_values[j] < a.low_threshold,
|
||||||
-1, -1);
|
-1, -1);
|
||||||
|
|
||||||
if (a.high.bindings[modifiers].size())
|
if (a.high.bindings[modifiers].size())
|
||||||
_update_button(_joystick_bindings[i].axes[j].high,
|
_update_button(_joystick_bindings[i].axes[j].high,
|
||||||
modifiers,
|
modifiers,
|
||||||
|
@ -871,7 +865,7 @@ 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 (int j = 0; j < _joystick_bindings[i].nbuttons; j++) {
|
||||||
button &b = _joystick_bindings[i].buttons[j];
|
button &b = _joystick_bindings[i].buttons[j];
|
||||||
b.last_dt += dt;
|
b.last_dt += dt;
|
||||||
if(b.last_dt >= b.interval_sec) {
|
if(b.last_dt >= b.interval_sec) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue