1
0
Fork 0

make the state of the Meta and Super modifier keys available. These keys

are not available out-of-the-box on all systems and keyboards, and should
therefore not be used in files committed to CVS. This makes them well
suited for local key bindings, as they aren't likely to get overwritten
with later releases. SDL supports Meta and Super, OSG supports only Meta,
and GLUT supports neither.
This commit is contained in:
mfranz 2007-12-01 13:09:11 +00:00
parent ae8509c827
commit 9fa86acc65
5 changed files with 38 additions and 4 deletions

View file

@ -102,6 +102,18 @@ getModAlt ()
return bool(fgGetKeyModifiers() & KEYMOD_ALT);
}
static bool
getModMeta ()
{
return bool(fgGetKeyModifiers() & KEYMOD_META);
}
static bool
getModSuper ()
{
return bool(fgGetKeyModifiers() & KEYMOD_SUPER);
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGInput.
@ -151,6 +163,8 @@ FGInput::bind ()
fgTie("/devices/status/keyboard/shift", getModShift);
fgTie("/devices/status/keyboard/ctrl", getModCtrl);
fgTie("/devices/status/keyboard/alt", getModAlt);
fgTie("/devices/status/keyboard/meta", getModMeta);
fgTie("/devices/status/keyboard/super", getModSuper);
_key_event->tie("key", SGRawValuePointer<int>(&_key_code));
_key_event->tie("pressed", SGRawValuePointer<bool>(&_key_pressed));
@ -158,6 +172,8 @@ FGInput::bind ()
_key_event->tie("modifier/shift", SGRawValuePointer<bool>(&_key_shift));
_key_event->tie("modifier/ctrl", SGRawValuePointer<bool>(&_key_ctrl));
_key_event->tie("modifier/alt", SGRawValuePointer<bool>(&_key_alt));
_key_event->tie("modifier/meta", SGRawValuePointer<bool>(&_key_meta));
_key_event->tie("modifier/super", SGRawValuePointer<bool>(&_key_super));
}
void
@ -166,6 +182,8 @@ FGInput::unbind ()
fgUntie("/devices/status/keyboard/shift");
fgUntie("/devices/status/keyboard/ctrl");
fgUntie("/devices/status/keyboard/alt");
fgUntie("/devices/status/keyboard/meta");
fgUntie("/devices/status/keyboard/super");
_key_event->untie("key");
_key_event->untie("pressed");
@ -173,6 +191,8 @@ FGInput::unbind ()
_key_event->untie("modifier/shift");
_key_event->untie("modifier/ctrl");
_key_event->untie("modifier/alt");
_key_event->untie("modifier/meta");
_key_event->untie("modifier/super");
}
void
@ -221,10 +241,12 @@ FGInput::doKey (int k, int modifiers, int x, int y)
_key_code = k;
_key_modifiers = modifiers & ~KEYMOD_RELEASED;
_key_pressed = bool(!(modifiers & KEYMOD_RELEASED));
_key_pressed = !bool(modifiers & KEYMOD_RELEASED);
_key_shift = bool(modifiers & KEYMOD_SHIFT);
_key_ctrl = bool(modifiers & KEYMOD_CTRL);
_key_alt = bool(modifiers & KEYMOD_ALT);
_key_meta = bool(modifiers & KEYMOD_META);
_key_super = bool(modifiers & KEYMOD_SUPER);
_key_event->fireValueChanged();
if (!_key_code)
return;

View file

@ -336,9 +336,11 @@ private:
int _key_code;
int _key_modifiers;
bool _key_pressed;
bool _key_shift;
bool _key_ctrl;
bool _key_alt;
bool _key_shift;
bool _key_meta;
bool _key_super;
};
#endif // _INPUT_HXX

View file

@ -32,6 +32,10 @@ FGManipulator::FGManipulator() :
= GUIEventAdapter::MODKEY_RIGHT_CTRL;
keyMaskMap[GUIEventAdapter::KEY_Alt_L] = GUIEventAdapter::MODKEY_LEFT_ALT;
keyMaskMap[GUIEventAdapter::KEY_Alt_R] = GUIEventAdapter::MODKEY_RIGHT_ALT;
keyMaskMap[GUIEventAdapter::KEY_Meta_L] = GUIEventAdapter::MODKEY_LEFT_META;
keyMaskMap[GUIEventAdapter::KEY_Meta_R] = GUIEventAdapter::MODKEY_RIGHT_META;
keyMaskMap[GUIEventAdapter::KEY_Super_L] = GUIEventAdapter::MODKEY_LEFT_META;
keyMaskMap[GUIEventAdapter::KEY_Super_R] = GUIEventAdapter::MODKEY_RIGHT_META;
// We have to implement numlock too.
numlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = '0';
numlockKeyMap[GUIEventAdapter::KEY_KP_End] = '1';

View file

@ -27,7 +27,9 @@ enum { KEYMOD_NONE = 0,
KEYMOD_SHIFT = 2,
KEYMOD_CTRL = 4,
KEYMOD_ALT = 8,
KEYMOD_MAX = 16 };
KEYMOD_META = 16,
KEYMOD_SUPER = 32,
KEYMOD_MAX = 64 };
// A note on key codes: none are defined here. FlightGear has no
// hard-coded interpretations of codes other than modifier keys, so we

View file

@ -133,6 +133,10 @@ int SDLKeyTranslator::handleKey(int key, int raw, int keyup)
case SDLK_LCTRL: modmask = KEYMOD_CTRL; osgKey = KEY_Control_L; break;
case SDLK_RALT: modmask = KEYMOD_ALT; osgKey = KEY_Alt_R; break;
case SDLK_LALT: modmask = KEYMOD_ALT; osgKey = KEY_Alt_L; break;
case SDLK_RMETA: modmask = KEYMOD_META; osgKey = KEY_Meta_R; break;
case SDLK_LMETA: modmask = KEYMOD_META; osgKey = KEY_Meta_L; break;
case SDLK_RSUPER: modmask = KEYMOD_SUPER; osgKey = KEY_Super_R; break;
case SDLK_LSUPER: modmask = KEYMOD_SUPER; osgKey = KEY_Super_L; break;
case SDLK_LEFT: osgKey = KEY_Left; break;
case SDLK_UP: osgKey = KEY_Up; break;