]> git.mxchange.org Git - flightgear.git/commitdiff
make the state of the Meta and Super modifier keys available. These keys
authormfranz <mfranz>
Sat, 1 Dec 2007 13:09:11 +0000 (13:09 +0000)
committermfranz <mfranz>
Sat, 1 Dec 2007 13:09:11 +0000 (13:09 +0000)
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.

src/Input/input.cxx
src/Input/input.hxx
src/Main/FGManipulator.cxx
src/Main/fg_os.hxx
src/Main/fg_os_sdl.cxx

index 704b25be86f5d58014f1a195dd47f95a56942665..a6906140540adcdb0e036da365a99867d3900d88 100644 (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);
+}
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // 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,13 +241,15 @@ 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;
+    return;
 
   button &b = _key_bindings[k];
 
index 3b3803e9fe7877100dd4ce4ee80b48dc6a38325d..eef9e243457e90f8962c4993a7c291012893c0a3 100644 (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
index 646e6b386929ea69afbd8529cf7e63e3d388ff79..499c843e3c26b6083500dadae077bfa2331ef36c 100644 (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';
index 9bbbb4d95ebed17be798ccc1b893773e7fd8bc34..43bea933a8e98e6c0a213840ca3d48b4dc188cae 100644 (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
index 0b43ef93beb3caebb84a3dab005fc8735ef77f68..2c104c4abb3ce382f21d1d5df1bfc5285dc47849 100644 (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;