This is an ugly fix for an ugly problem. And no, the two uglies don't cancel
each other out. The problem is this: if we press, for example, "Ctrl-a", but release the "Ctrl" modifier button *before* the "a" button (which nobody does intentionally, but which happens all the time), then we don't get the RELEASE signal on "Ctrl-a" (keycode 1), but on the "a" (79). But "a" hasn't been pressed, so the signal is dropped. And who releases "Ctrl-a"? Nobody! So the next PRESSED signal for "Ctrl-a" is ignored, too. It is still "pressed" after all, isn't it? That's the reason for the occasional non-functioning of keys. Due to the nearing 0.9.9 release, I only commit a crude last-minute fix. It's not as intrusive as it looks, and shouldn't be "dangerous" at all. It only makes sure that when we get an unexpected RELEASE for one letter key ("a") that the two twins "A" and "Ctrl-A" are released if they are still in "pressed" state. The proper fix will be to let fg_os{,_sdl}.cxx always report presses on the same key ("a", "Shift-a", "Ctrl-a", "Alt-a", and other combinations of modifiers) as the *same* key (97), only with modifiers appropriately set.
This commit is contained in:
parent
e5d3c3134b
commit
0eef853caa
1 changed files with 18 additions and 1 deletions
|
@ -263,6 +263,23 @@ FGInput::doKey (int k, int modifiers, int x, int y)
|
|||
for (unsigned int i = 0; i < bindings.size(); i++)
|
||||
bindings[i]->fire();
|
||||
b.last_state = 0;
|
||||
} else {
|
||||
if (k >= 1 && k <= 26) {
|
||||
if (_key_bindings[k + '@'].last_state)
|
||||
doKey(k + '@', KEYMOD_RELEASED, x, y);
|
||||
if (_key_bindings[k + '`'].last_state)
|
||||
doKey(k + '`', KEYMOD_RELEASED, x, y);
|
||||
} else if (k >= 'A' && k <= 'Z') {
|
||||
if (_key_bindings[k - '@'].last_state)
|
||||
doKey(k - '@', KEYMOD_RELEASED, x, y);
|
||||
if (_key_bindings[tolower(k)].last_state)
|
||||
doKey(tolower(k), KEYMOD_RELEASED, x, y);
|
||||
} else if (k >= 'a' && k <= 'z') {
|
||||
if (_key_bindings[k - '`'].last_state)
|
||||
doKey(k - '`', KEYMOD_RELEASED, x, y);
|
||||
if (_key_bindings[toupper(k)].last_state)
|
||||
doKey(toupper(k), KEYMOD_RELEASED, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,7 +973,7 @@ FGInput::_find_key_bindings (unsigned int k, int modifiers)
|
|||
|
||||
FGInput::button::button ()
|
||||
: is_repeatable(false),
|
||||
last_state(-1)
|
||||
last_state(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue