]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/input.cxx
Added a <solve-weight> subtag of the approach/cruise parameters that can
[flightgear.git] / src / Input / input.cxx
index 4a099e4f894a88fc27112d88a556de9d0563a8a5..9c52389d9b1dfc5674454e41f72d35191f068b49 100644 (file)
@@ -48,8 +48,8 @@
 #include <simgear/props/props.hxx>
 
 #include <Aircraft/aircraft.hxx>
-#include <Autopilot/auto_gui.hxx>
-#include <Autopilot/newauto.hxx>
+// #include <Autopilot/auto_gui.hxx>
+#include <Autopilot/xmlauto.hxx>
 #include <Cockpit/hud.hxx>
 #include <Cockpit/panel.hxx>
 #include <Cockpit/panel_io.hxx>
@@ -94,11 +94,6 @@ FGBinding::FGBinding (const SGPropertyNode * node)
   read(node);
 }
 
-FGBinding::~FGBinding ()
-{
-  delete _arg;                       // Delete the saved arguments
-}
-
 void
 FGBinding::read (const SGPropertyNode * node)
 {
@@ -113,7 +108,6 @@ FGBinding::read (const SGPropertyNode * node)
     return;
   }
 
-  delete _arg;
   _arg = new SGPropertyNode;
   _setting = 0;
   copyProperties(node, _arg);  // FIXME: don't use whole node!!!
@@ -229,6 +223,9 @@ FGInput::makeDefault (bool status)
 void
 FGInput::doKey (int k, int modifiers, int x, int y)
 {
+    static SGPropertyNode *heading_enabled
+        = fgGetNode("/autopilot/locks/heading", true);
+
                                 // Sanity check.
   if (k < 0 || k >= MAX_KEYS) {
     SG_LOG(SG_INPUT, SG_WARN, "Key value " << k << " out of range");
@@ -303,14 +300,11 @@ FGInput::doKey (int k, int modifiers, int x, int y)
 // START SPECIALS
 
         case 256+GLUT_KEY_F6: // F6 toggles Autopilot target location
-            if ( globals->get_autopilot()->get_HeadingMode() !=
-                 FGAutopilot::FG_HEADING_WAYPOINT ) {
-                globals->get_autopilot()->set_HeadingMode(
-                    FGAutopilot::FG_HEADING_WAYPOINT );
-                globals->get_autopilot()->set_HeadingEnabled( true );
+            if ( strcmp( heading_enabled->getStringValue(),
+                         "true-heading-hold" ) != 0 ) {
+                heading_enabled->setStringValue( "true-heading-hold" );
             } else {
-                globals->get_autopilot()->set_HeadingMode(
-                    FGAutopilot::FG_TC_HEADING_LOCK );
+                heading_enabled->setStringValue( "" );
             }
             return;
         }
@@ -454,7 +448,7 @@ FGInput::_init_joystick ()
     jsJoystick * js = new jsJoystick(i);
     _joystick_bindings[i].js = js;
     if (js->notWorking()) {
-      SG_LOG(SG_INPUT, SG_WARN, "Joystick " << i << " not found");
+      SG_LOG(SG_INPUT, SG_DEBUG, "Joystick " << i << " not found");
       continue;
     } else {
       bool found_js = false;
@@ -622,8 +616,11 @@ FGInput::_init_mouse ()
                                 // Grab node pointers
     char buf[64];
     sprintf(buf, "/devices/status/mice/mouse[%d]/mode", i);
-    m.mode_node = fgGetNode(buf, true);
-    m.mode_node->setIntValue(0);
+    m.mode_node = fgGetNode(buf);
+    if (m.mode_node == NULL) {
+      m.mode_node = fgGetNode(buf, true);
+      m.mode_node->setIntValue(0);
+    }
     for (j = 0; j < MAX_MOUSE_BUTTONS; j++) {
       sprintf(buf, "/devices/status/mice/mouse[%d]/button[%d]", i, j);
       m.mouse_button_nodes[j] = fgGetNode(buf, true);
@@ -847,22 +844,27 @@ FGInput::_read_bindings (const SGPropertyNode * node,
 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