void
FGInput::_init_keyboard ()
{
- // TODO: zero the old bindings first.
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing key bindings");
SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
if (key_nodes == 0) {
for (unsigned int i = 0; i < keys.size(); i++) {
int index = keys[i]->getIndex();
SG_LOG(SG_INPUT, SG_DEBUG, "Binding key " << index);
+
+ _key_bindings[index].bindings->clear();
_key_bindings[index].is_repeatable = keys[i]->getBoolValue("repeatable");
_read_bindings(keys[i], _key_bindings[index].bindings, FG_MOD_NONE);
}
const vector<FGBinding *> &
FGInput::_find_key_bindings (unsigned int k, int modifiers)
{
+ unsigned char kc = (unsigned char)k;
button &b = _key_bindings[k];
// Try it straight, first.
if (b.bindings[modifiers].size() > 0)
return b.bindings[modifiers];
+ // Alt-Gr is CTRL+ALT
+ else if (modifiers&(FG_MOD_CTRL|FG_MOD_ALT))
+ return _find_key_bindings(k, modifiers&~(FG_MOD_CTRL|FG_MOD_ALT));
+
// Try removing the control modifier
// for control keys.
- else if ((modifiers&FG_MOD_CTRL) && iscntrl(k))
+ else if ((modifiers&FG_MOD_CTRL) && iscntrl(kc))
return _find_key_bindings(k, modifiers&~FG_MOD_CTRL);
// Try removing shift modifier
// for upper case or any punctuation
// (since different keyboards will
// shift different punctuation types)
- else if ((modifiers&FG_MOD_SHIFT) && (isupper(k) || ispunct(k)))
+ else if ((modifiers&FG_MOD_SHIFT) && (isupper(kc) || ispunct(kc)))
return _find_key_bindings(k, modifiers&~FG_MOD_SHIFT);
// Try removing alt modifier for