]> git.mxchange.org Git - flightgear.git/blobdiff - src/Controls/controls.cxx
Boris Koenig:
[flightgear.git] / src / Controls / controls.cxx
index 6b0967f7fdf08a55eee0f3100174d1d6ed5c372c..a36ee4d9d3c33a62fa3d910668ab7ca7c9014dcb 100644 (file)
 // $Id$
 
 
-#include "controls.hxx"
-
+#include <simgear/compiler.h>
 #include <simgear/debug/logstream.hxx>
 #include <Main/fg_props.hxx>
 
+#include "controls.hxx"
+
+
+static const int MAX_NAME_LEN = 128;
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -69,7 +72,11 @@ FGControls::FGControls() :
     drag_chute( false ),
     throttle_idle( true ),
     dump_valve( false ),
-    parking_brake( 0.0 ),
+    brake_left( 0.0 ),
+    brake_right( 0.0 ),
+    copilot_brake_left( 0.0 ),
+    copilot_brake_right( 0.0 ),
+    brake_parking( 0.0 ),
     steering( 0.0 ),
     gear_down( true ),
     antiskid( true ),
@@ -85,6 +92,7 @@ FGControls::FGControls() :
     APU_bleed( false ),
     mode( 0 ),
     dump( false ),
+    outflow_valve( 0.0 ),
     taxi_light( false ),
     logo_lights( false ),
     nav_lights( false ),
@@ -98,7 +106,6 @@ FGControls::FGControls() :
     release_ALL( false ),
     vertical_adjust( 0.0 ),
     fore_aft_adjust( 0.0 ),
-    eject( false ),
     off_start_run( 0 ),
     APU_fire_switch( false ),
     autothrottle_arm( false ),
@@ -143,7 +150,7 @@ void FGControls::reset_all()
     set_augmentation( ALL_ENGINES, false );
     set_reverser( ALL_ENGINES, false );
     set_water_injection( ALL_ENGINES, false );
-    set_condition( ALL_ENGINES, 0 );
+    set_condition( ALL_ENGINES, 1.0 );
     throttle_idle = true;
     set_fuel_selector( ALL_TANKS, true );
     dump_valve = false;
@@ -162,7 +169,9 @@ void FGControls::reset_all()
     landing_lights = false;
     turn_off_lights = false;
     master_arm = false;
-    eject = false;
+    set_ejection_seat( ALL_EJECTION_SEATS, false );
+    set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
+    set_cmd_selector_valve( CMD_SEL_NORM );
     APU_fire_switch = false;
     autothrottle_arm = false;
     autothrottle_engage = false;
@@ -193,11 +202,14 @@ FGControls::init ()
         reverser[engine] = false;
         water_injection[engine] = false;
         nitrous_injection[engine] = false;
-        condition[engine] = 0;
+        cowl_flaps_norm[engine] = 0.0;
+        condition[engine] = 1.0;
     }
 
+    brake_left = brake_right
+        = copilot_brake_left = copilot_brake_right
+        = brake_parking = 0.0;
     for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
-        brake[wheel] = 0.0;
         alternate_extension[wheel] = false;
     }
 
@@ -273,98 +285,107 @@ FGControls::bind ()
   fgSetArchivable("/controls/engines/throttle_idle");
 
   for (index = 0; index < MAX_ENGINES; index++) {
-    char name[32];
-    sprintf(name, "/controls/engines/engine[%d]/throttle", index);
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/throttle", index);
     fgTie(name, this, index,
          &FGControls::get_throttle, &FGControls::set_throttle);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/starter", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
     fgTie(name, this, index,
         &FGControls::get_starter, &FGControls::set_starter);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/fuel-pump", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/fuel-pump", index);
     fgTie(name, this, index,
         &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/fire-switch", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/fire-switch", index);
     fgTie(name, this, index,
         &FGControls::get_fire_switch, &FGControls::set_fire_switch);
     fgSetArchivable(name);
 
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/engines/engine[%d]/fire-bottle-discharge", index);
     fgTie(name, this, index,
         &FGControls::get_fire_bottle_discharge,
          &FGControls::set_fire_bottle_discharge);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/cutoff", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
     fgTie(name, this, index,
         &FGControls::get_cutoff, &FGControls::set_cutoff);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/mixture", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
     fgTie(name, this, index,
         &FGControls::get_mixture, &FGControls::set_mixture);
     fgSetArchivable(name);
 
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/engines/engine[%d]/propeller-pitch", index);
     fgTie(name, this, index,
         &FGControls::get_prop_advance, 
          &FGControls::set_prop_advance);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/magnetos", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/magnetos", index);
     fgTie(name, this, index,
         &FGControls::get_magnetos, &FGControls::set_magnetos);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/WEP", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
     fgTie(name, this, index,
         &FGControls::get_nitrous_injection,
          &FGControls::set_nitrous_injection);
     fgSetArchivable(name);
 
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/engines/engine[%d]/cowl-flaps-norm", index);
     fgTie(name, this, index,
         &FGControls::get_cowl_flaps_norm, 
          &FGControls::set_cowl_flaps_norm);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/feather", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/propeller-feather", index);
     fgTie(name, this, index,
         &FGControls::get_feather, &FGControls::set_feather);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/ignition", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/ignition", index);
     fgTie(name, this, index,
         &FGControls::get_ignition, &FGControls::set_ignition);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/augmentation", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/augmentation", index);
     fgTie(name, this, index,
         &FGControls::get_augmentation, 
          &FGControls::set_augmentation);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/reverser", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/reverser", index);
     fgTie(name, this, index,
         &FGControls::get_reverser, &FGControls::set_reverser);
     fgSetArchivable(name);
 
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/engines/engine[%d]/water-injection", index);
     fgTie(name, this, index,
         &FGControls::get_water_injection,
          &FGControls::set_water_injection);
     fgSetArchivable(name);
 
-    sprintf(name, "/controls/engines/engine[%d]/condition", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/condition", index);
     fgTie(name, this, index,
         &FGControls::get_condition, &FGControls::set_condition);
     fgSetArchivable(name);
@@ -376,26 +397,27 @@ FGControls::bind ()
   fgSetArchivable("/controls/fuel/dump-valve");
 
   for (index = 0; index < MAX_TANKS; index++) {
-    char name[32];
-    sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index);
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/fuel/tank[%d]/fuel_selector", index);
     fgTie(name, this, index,
          &FGControls::get_fuel_selector, 
           &FGControls::set_fuel_selector);
     fgSetArchivable(name);  
 
-    sprintf(name, "/controls/fuel/tank[%d]/to_engine", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
     fgTie(name, this, index,
          &FGControls::get_to_engine, &FGControls::set_to_engine);
     fgSetArchivable(name);  
 
-    sprintf(name, "/controls/fuel/tank[%d]/to_tank", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
     fgTie(name, this, index,
          &FGControls::get_to_tank, &FGControls::set_to_tank);
     fgSetArchivable(name);  
 
     for (i = 0; i < MAX_BOOSTPUMPS; i++) {
-      char name[32];
-      sprintf(name
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN
          "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
       fgTie(name, this, index * 2 + i,
            &FGControls::get_boost_pump, 
@@ -405,10 +427,30 @@ FGControls::bind ()
   }
 
   // gear
-  fgTie("/controls/gear/parking-brake", this,
-       &FGControls::get_parking_brake, 
-        &FGControls::set_parking_brake);
-  fgSetArchivable("/controls/parking-brake");
+  fgTie("/controls/gear/brake-left", this,
+       &FGControls::get_brake_left, 
+        &FGControls::set_brake_left);
+  fgSetArchivable("/controls/gear/brake-left");
+
+  fgTie("/controls/gear/brake-right", this,
+       &FGControls::get_brake_right, 
+        &FGControls::set_brake_right);
+  fgSetArchivable("/controls/gear/brake-right");
+
+  fgTie("/controls/gear/copilot-brake-left", this,
+       &FGControls::get_copilot_brake_left, 
+        &FGControls::set_copilot_brake_left);
+  fgSetArchivable("/controls/gear/copilot-brake-left");
+
+  fgTie("/controls/gear/copilot-brake-right", this,
+       &FGControls::get_copilot_brake_right, 
+        &FGControls::set_copilot_brake_right);
+  fgSetArchivable("/controls/gear/copilot-brake-right");
+
+  fgTie("/controls/gear/brake-parking", this,
+       &FGControls::get_brake_parking, 
+        &FGControls::set_brake_parking);
+  fgSetArchivable("/controls/gear/brake-parking");
 
   fgTie("/controls/gear/steering", this,
        &FGControls::get_steering, &FGControls::set_steering);
@@ -432,13 +474,9 @@ FGControls::bind ()
   fgSetArchivable("/controls/gear/tailwheel-lock");
 
   for (index = 0; index < MAX_WHEELS; index++) {
-      char name[32];
-      sprintf(name, "/controls/gear/wheel[%d]/brake", index);
-      fgTie(name, this, index,
-            &FGControls::get_brake, &FGControls::set_brake);
-      fgSetArchivable(name);
-
-      sprintf(name, "/controls/gear/wheel[%d]/alternate-extension", index);
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/gear/wheel[%d]/alternate-extension", index);
       fgTie(name, this, index,
             &FGControls::get_alternate_extension, 
             &FGControls::set_alternate_extension);
@@ -463,13 +501,15 @@ FGControls::bind ()
   fgSetArchivable("/controls/anti-ice/window-heat");
 
   for (index = 0; index < MAX_ENGINES; index++) {
-      char name[32];
-      sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index);  
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/anti-ice/engine[%d]/carb-heat", index);  
       fgTie(name, this, index,
        &FGControls::get_carb_heat, &FGControls::set_carb_heat);
       fgSetArchivable(name);
 
-      sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index);  
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/anti-ice/engine[%d]/inlet-heat", index);  
       fgTie(name, this, index,
        &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
       fgSetArchivable(name);
@@ -477,14 +517,14 @@ FGControls::bind ()
 
   // hydraulics
   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
-      char name[32];
-      sprintf(name
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN
          "/controls/hydraulic/system[%d]/engine-pump", index);  
       fgTie(name, this, index,
        &FGControls::get_engine_pump, &FGControls::set_engine_pump);
       fgSetArchivable(name);
 
-      sprintf(name
+      snprintf(name, MAX_NAME_LEN
          "/controls/hydraulic/system[%d]/electric-pump", index);  
       fgTie(name, this, index,
        &FGControls::get_electric_pump, 
@@ -509,15 +549,16 @@ FGControls::bind ()
   fgSetArchivable("/controls/electric/APU-generator");
 
   for (index = 0; index < MAX_ENGINES; index++) {
-      char name[32];
-      sprintf(name
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN
          "/controls/electric/engine[%d]/generator", index);  
       fgTie(name, this, index,
        &FGControls::get_generator_breaker, 
         &FGControls::set_generator_breaker);
       fgSetArchivable(name);
 
-      sprintf(name, "/controls/electric/engine[%d]/bus-tie", index);  
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/electric/engine[%d]/bus-tie", index);  
       fgTie(name, this, index,
        &FGControls::get_bus_tie, 
         &FGControls::set_bus_tie);
@@ -531,8 +572,8 @@ FGControls::bind ()
   fgSetArchivable("/controls/pneumatic/APU-bleed");
 
   for (index = 0; index < MAX_ENGINES; index++) {
-      char name[32];
-      sprintf(name
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN
          "/controls/pneumatic/engine[%d]/bleed", index);  
       fgTie(name, this, index,
        &FGControls::get_engine_bleed, 
@@ -555,8 +596,9 @@ FGControls::bind ()
   fgSetArchivable("/controls/pressurization/outflow-valve");
 
   for (index = 0; index < MAX_PACKS; index++) {
-      char name[32];
-      sprintf(name, "/controls/pressurization/pack[%d]/pack-on", index);  
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/pressurization/pack[%d]/pack-on", index);  
       fgTie(name, this, index,
        &FGControls::get_pack_on, &FGControls::set_pack_on);
       fgSetArchivable(name);
@@ -623,24 +665,27 @@ FGControls::bind ()
   fgSetArchivable("/controls/armament/release-all");  
 
   for (index = 0; index < MAX_STATIONS; index++) {
-      char name[32];
-      sprintf(name, "/controls/armament/station[%d]/stick-size", index);  
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/armament/station[%d]/stick-size", index);  
       fgTie(name, this, index,
        &FGControls::get_stick_size, &FGControls::set_stick_size);
       fgSetArchivable(name);
 
-      sprintf(name
+      snprintf(name, MAX_NAME_LEN
           "/controls/armament/station[%d]/release-stick", index);  
       fgTie(name, this, index,
        &FGControls::get_release_stick, &FGControls::set_release_stick);
       fgSetArchivable(name);
 
-      sprintf(name, "/controls/armament/station[%d]/release-all", index);  
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/armament/station[%d]/release-all", index);  
       fgTie(name, this, index,
        &FGControls::get_release_all, &FGControls::set_release_all);
       fgSetArchivable(name);
 
-      sprintf(name, "/controls/armament/station[%d]/jettison-all", index);  
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/armament/station[%d]/jettison-all", index);  
       fgTie(name, this, index,
        &FGControls::get_jettison_all, &FGControls::set_jettison_all);
       fgSetArchivable(name);
@@ -659,9 +704,30 @@ FGControls::bind ()
         &FGControls::set_fore_aft_adjust);
   fgSetArchivable("/controls/seat/fore-aft-adjust");
   
-  fgTie("/controls/seat/eject", this,
-       &FGControls::get_eject, &FGControls::set_eject);
-  fgSetArchivable("/controls/seat/eject");
+  for (index = 0; index < MAX_EJECTION_SEATS; index++) {
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN,
+              "/controls/seat/eject[%d]/initiate", index);
+      fgTie(name, this, index,
+          &FGControls::get_ejection_seat, 
+          &FGControls::set_ejection_seat);
+      fgSetArchivable(name);
+
+      snprintf(name, MAX_NAME_LEN,
+              "/controls/seat/eject[%d]/status", index);
+
+      fgTie(name, this, index,
+           &FGControls::get_eseat_status,
+          &FGControls::set_eseat_status);
+
+      fgSetArchivable(name);
+  }
+  
+  fgTie("/controls/seat/cmd_selector_valve", this,
+        &FGControls::get_cmd_selector_valve,
+       &FGControls::set_cmd_selector_valve);
+  fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
+
 
   // APU
   fgTie("/controls/APU/off-start-run", this,
@@ -676,8 +742,8 @@ FGControls::bind ()
 
   // autoflight
   for (index = 0; index < MAX_AUTOPILOTS; index++) {
-      char name[32];
-      sprintf(name
+      char name[MAX_NAME_LEN];
+      snprintf(name, MAX_NAME_LEN
          "/controls/autoflight/autopilot[%d]/engage", index);  
       fgTie(name, this, index,
        &FGControls::get_autopilot_engage, 
@@ -756,71 +822,86 @@ void FGControls::unbind ()
   fgUntie("/controls/flight/wing-fold");  
   fgUntie("/controls/flight/drag-chute");
   for (index = 0; index < MAX_ENGINES; index++) {
-    char name[32];
-    sprintf(name, "/controls/engines/engine[%d]/throttle", index);
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/throttle", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/starter", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/starter", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/fuel_pump", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/fuel_pump", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/fire-switch", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/fire-switch", index);
     fgUntie(name);
-    sprintf(name
-       "/controls/engines/engine[%d]/fire-bottle-discharge", index);
+    snprintf(name, MAX_NAME_LEN
+             "/controls/engines/engine[%d]/fire-bottle-discharge", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/throttle_idle", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/throttle_idle", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/cutoff", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/mixture", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
     fgUntie(name);
-    sprintf(name
-       "/controls/engines/engine[%d]/propeller-pitch", index);
+    snprintf(name, MAX_NAME_LEN
+             "/controls/engines/engine[%d]/propeller-pitch", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/magnetos", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/magnetos", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/WEP", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/cowl-flaps-norm", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/cowl-flaps-norm", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/feather", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/propeller-feather", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/ignition", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/ignition", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/augmentation", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/augmentation", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/reverser", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/reverser", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/water-injection", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/water-injection", index);
     fgUntie(name);
-    sprintf(name, "/controls/engines/engine[%d]/condition", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/condition", index);
     fgUntie(name);
   }
   fgUntie("/controls/fuel/dump-valve");
   for (index = 0; index < MAX_TANKS; index++) {
-    char name[32];
-    sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index);
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/fuel/tank[%d]/fuel_selector", index);
     fgUntie(name);
-    sprintf(name, "/controls/fuel/tank[%d]/to_engine", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
     fgUntie(name);
-    sprintf(name, "/controls/fuel/tank[%d]/to_tank", index);
+    snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
     fgUntie(name);
     for (i = 0; index < MAX_BOOSTPUMPS; i++) {
-      sprintf(name, "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
+      snprintf(name, MAX_NAME_LEN,
+               "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
       fgUntie(name);
     }
   }
-  fgUntie("/controls/gear/parking_brake");
+  fgUntie("/controls/gear/brake-left");
+  fgUntie("/controls/gear/brake-right");
+  fgUntie("/controls/gear/brake-parking");
   fgUntie("/controls/gear/steering");
   fgUntie("/controls/gear/gear_down");
   fgUntie("/controls/gear/antiskid");
   fgUntie("/controls/gear/tailhook");
   fgUntie("/controls/gear/tailwheel-lock");
   for (index = 0; index < MAX_WHEELS; index++) {
-    char name[32];
-    sprintf(name, "/controls/gear/wheel[%d]/brakes", index);
-    fgUntie(name);
-    sprintf(name, 
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN, 
        "/controls/gear/wheel[%d]/alternate-extension", index);
     fgUntie(name);
   }
@@ -829,18 +910,20 @@ void FGControls::unbind ()
   fgUntie("/controls/anti-ice/wiper");
   fgUntie("/controls/anti-ice/window-heat");
   for (index = 0; index < MAX_ENGINES; index++) {
-    char name[32];
-    sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index);
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/anti-ice/engine[%d]/carb-heat", index);
     fgUntie(name);
-    sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/anti-ice/engine[%d]/inlet-heat", index);
     fgUntie(name);
   }
   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
-    char name[32];
-    sprintf(name
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN
        "/controls/hydraulic/system[%d]/engine-pump", index);
     fgUntie(name);
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/hydraulic/system[%d]/electric-pump", index);
     fgUntie(name);
   }
@@ -848,26 +931,26 @@ void FGControls::unbind ()
   fgUntie("/controls/electric/external-power");
   fgUntie("/controls/electric/APU-generator");    
   for (index = 0; index < MAX_ENGINES; index++) {
-    char name[32];
-     sprintf(name
+    char name[MAX_NAME_LEN];
+     snprintf(name, MAX_NAME_LEN
        "/controls/electric/engine[%d]/generator", index);
     fgUntie(name);
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/electric/engine[%d]/bus-tie", index);
     fgUntie(name);
   }
   fgUntie("/controls/pneumatic/APU-bleed");
   for (index = 0; index < MAX_ENGINES; index++) {
-    char name[32];
-     sprintf(name
+    char name[MAX_NAME_LEN];
+     snprintf(name, MAX_NAME_LEN
        "/controls/pneumatic/engine[%d]/bleed", index);
     fgUntie(name);
   }
   fgUntie("/controls/pressurization/mode");
   fgUntie("/controls/pressurization/dump");
   for (index = 0; index < MAX_PACKS; index++) {
-    char name[32];
-    sprintf(name
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN
        "/controls/pressurization/pack[%d]/pack-on", index);
     fgUntie(name);
   }
@@ -887,29 +970,39 @@ void FGControls::unbind ()
   fgUntie("/controls/armament/station-select");  
   fgUntie("/controls/armament/release-all");  
   for (index = 0; index < MAX_STATIONS; index++) {
-    char name[32];
-    sprintf(name
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN
        "/controls/armament/station[%d]/stick-size", index);
     fgUntie(name);
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/armament/station[%d]/release-stick", index);
     fgUntie(name);
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/armament/station[%d]/release-all", index);
     fgUntie(name);
-    sprintf(name
+    snprintf(name, MAX_NAME_LEN
        "/controls/armament/station[%d]/jettison-all", index);
     fgUntie(name);
   }
 #endif
   fgUntie("/controls/seat/vertical-adjust");  
   fgUntie("/controls/seat/fore-aft-adjust");  
-  fgUntie("/controls/seat/eject");  
+  for (index = 0; index < MAX_EJECTION_SEATS; index++) {
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
+       "/controls/seat/eject[%d]/initiate", index);
+    fgUntie(name);
+    snprintf(name, MAX_NAME_LEN,
+       "/controls/seat/eject[%d]/status", index);
+    fgUntie(name);
+  }
+  fgUntie("/controls/seat/cmd_selector_valve");
+  
   fgUntie("/controls/APU/off-start-run");  
   fgUntie("/controls/APU/fire-switch");  
   for (index = 0; index < MAX_AUTOPILOTS; index++) {
-    char name[32];
-    sprintf(name, 
+    char name[MAX_NAME_LEN];
+    snprintf(name, MAX_NAME_LEN,
        "/controls/autoflight/autopilot[%d]/engage", index);
     fgUntie(name);
   }
@@ -1444,17 +1537,15 @@ FGControls::set_water_injection( int engine, bool val )
 }
 
 void
-FGControls::set_condition( int engine, int val )
+FGControls::set_condition( int engine, double val )
 {
     if ( engine == ALL_ENGINES ) {
        for ( int i = 0; i < MAX_ENGINES; i++ ) {
            condition[i] = val;
-           CLAMP( &condition[i], 0, 3 );
        }
     } else {
        if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
            condition[engine] = val;
-           CLAMP( &condition[engine], 0, 3 );
        }
     }
 }
@@ -1524,10 +1615,52 @@ FGControls::set_boost_pump( int index, bool val )
 
 
 void
-FGControls::set_parking_brake( double pos )
+FGControls::set_brake_left( double pos )
+{
+    brake_left = pos;
+    CLAMP(&brake_left, 0.0, 1.0);
+}
+
+void
+FGControls::move_brake_left( double amt )
+{
+    brake_left += amt;
+    CLAMP( &brake_left, 0.0, 1.0 );
+}
+
+void
+FGControls::set_brake_right( double pos )
+{
+    brake_right = pos;
+    CLAMP(&brake_right, 0.0, 1.0);
+}
+
+void
+FGControls::move_brake_right( double amt )
+{
+    brake_right += amt;
+    CLAMP( &brake_right, 0.0, 1.0 );
+}
+
+void
+FGControls::set_copilot_brake_left( double pos )
+{
+    copilot_brake_left = pos;
+    CLAMP(&brake_left, 0.0, 1.0);
+}
+
+void
+FGControls::set_copilot_brake_right( double pos )
 {
-    parking_brake = pos;
-    CLAMP(&parking_brake, 0.0, 1.0);
+    copilot_brake_right = pos;
+    CLAMP(&brake_right, 0.0, 1.0);
+}
+
+void
+FGControls::set_brake_parking( double pos )
+{
+    brake_parking = pos;
+    CLAMP(&brake_parking, 0.0, 1.0);
 }
 
 void
@@ -1569,38 +1702,6 @@ FGControls::set_tailwheel_lock( bool state )
 }
 
 
-void
-FGControls::set_brake( int wheel, double pos )
-{
-    if ( wheel == ALL_WHEELS ) {
-       for ( int i = 0; i < MAX_WHEELS; i++ ) {
-           brake[i] = pos;
-           CLAMP( &brake[i], 0.0, 1.0 );
-       }
-    } else {
-       if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
-           brake[wheel] = pos;
-           CLAMP( &brake[wheel], 0.0, 1.0 );
-       }
-    }
-}
-
-void
-FGControls::move_brake( int wheel, double amt )
-{
-    if ( wheel == ALL_WHEELS ) {
-       for ( int i = 0; i < MAX_WHEELS; i++ ) {
-           brake[i] += amt;
-           CLAMP( &brake[i], 0.0, 1.0 );
-       }
-    } else {
-       if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
-           brake[wheel] += amt;
-           CLAMP( &brake[wheel], 0.0, 1.0 );
-       }
-    }
-}
-
 void
 FGControls::set_alternate_extension( int wheel, bool val )
 {
@@ -1995,11 +2096,47 @@ FGControls::move_fore_aft_adjust( double amt )
 }
 
 void
-FGControls::set_eject( bool val )
+FGControls::set_ejection_seat( int which_seat, bool val )
 {
-  eject = val;
+    if ( which_seat == ALL_EJECTION_SEATS ) {
+        for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
+            eject[i] = val;
+        }
+    } else {
+        if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
+            if ( eseat_status[which_seat] == SEAT_SAFED ||
+                 eseat_status[which_seat] == SEAT_FAIL )
+            {
+                // we can never eject if SEAT_SAFED or SEAT_FAIL
+                val = false;
+            }
+
+            eject[which_seat] = val;
+        }
+    }
 }
 
+void
+FGControls::set_eseat_status( int which_seat, int val )
+{
+    if ( which_seat == ALL_EJECTION_SEATS ) {
+        for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
+            eseat_status[i] = val;
+        }
+    } else {
+        if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
+            eseat_status[which_seat] = val;
+        }
+    }
+}
+
+void
+FGControls::set_cmd_selector_valve( int val )
+{
+  cmd_selector_valve = val;
+}
+
+
 void
 FGControls::set_off_start_run( int pos )
 {