]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/FGKeyboardInput.cxx
Allow using the system version of flite and the HTS engine
[flightgear.git] / src / Input / FGKeyboardInput.cxx
index 49426d27afa429250b917a4d1d05b138cf760fe3..8ff3d0a81b9fac1141321c1565240c550332d596 100644 (file)
@@ -71,7 +71,16 @@ static bool getModHyper ()
 FGKeyboardInput * FGKeyboardInput::keyboardInput = NULL;
 
 FGKeyboardInput::FGKeyboardInput() :
-    _key_event(fgGetNode("/devices/status/keyboard/event", true))
+    _key_event(fgGetNode("/devices/status/keyboard/event", true)),
+    _key_code(0),
+    _key_modifiers(0),
+    _key_pressed(0),
+    _key_shift(0),
+    _key_ctrl(0),
+    _key_alt(0),
+    _key_meta(0),
+    _key_super(0),
+    _key_hyper(0)
 {
   if( keyboardInput == NULL )
     keyboardInput = this;
@@ -92,7 +101,7 @@ void FGKeyboardInput::init()
 void FGKeyboardInput::postinit()
 {
   SG_LOG(SG_INPUT, SG_DEBUG, "Initializing key bindings");
-  string module = "__kbd";
+  std::string module = "__kbd";
   SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
   if (key_nodes == NULL) {
     SG_LOG(SG_INPUT, SG_WARN, "No key bindings (/input/keyboard)!!");
@@ -124,7 +133,7 @@ void FGKeyboardInput::postinit()
 
 void FGKeyboardInput::bind()
 {
-  _tiedProperties.setRoot(fgGetNode("/device/status", true));
+  _tiedProperties.setRoot(fgGetNode("/devices/status", true));
   _tiedProperties.Tie("keyboard",       getModifiers);
   _tiedProperties.Tie("keyboard/shift", getModShift);
   _tiedProperties.Tie("keyboard/ctrl",  getModCtrl);
@@ -160,7 +169,7 @@ const FGCommonInput::binding_list_t & FGKeyboardInput::_find_key_bindings (unsig
   FGButton &b = bindings[k];
 
                                 // Try it straight, first.
-  if (b.bindings[modifiers].size() > 0)
+  if (! b.bindings[modifiers].empty())
     return b.bindings[modifiers];
 
                                 // Alt-Gr is CTRL+ALT
@@ -222,9 +231,7 @@ void FGKeyboardInput::doKey (int k, int modifiers, int x, int y)
     SG_LOG( SG_INPUT, SG_DEBUG, "User pressed key " << k << " with modifiers " << modifiers );
     if (!b.last_state || b.is_repeatable) {
       const binding_list_t &bindings = _find_key_bindings(k, modifiers);
-
-      for (unsigned int i = 0; i < bindings.size(); i++)
-        bindings[i]->fire();
+      fireBindingList(bindings);
       b.last_state = 1;
     }
   }
@@ -233,8 +240,7 @@ void FGKeyboardInput::doKey (int k, int modifiers, int x, int y)
     SG_LOG(SG_INPUT, SG_DEBUG, "User released key " << k << " with modifiers " << modifiers);
     if (b.last_state) {
       const binding_list_t &bindings = _find_key_bindings(k, modifiers);
-      for (unsigned int i = 0; i < bindings.size(); i++)
-        bindings[i]->fire();
+      fireBindingList(bindings);
       b.last_state = 0;
     }
   }