]> git.mxchange.org Git - flightgear.git/blobdiff - src/Controls/controls.cxx
Make sure that all elapsed time gets passed to update when a subsystem
[flightgear.git] / src / Controls / controls.cxx
index 100bb8dbb89627a99688a7e41d9a520de22d7abb..a60ae0ca36e7b80119b3507f15edfe13fa1bdde1 100644 (file)
@@ -59,23 +59,28 @@ FGControls::FGControls() :
     elevator_trim( 0.0 ),
     rudder( 0.0 ),
     rudder_trim( 0.0 ),
-    throttle_idle( true )
+    flaps( 0.0 ),
+    parking_brake( 0.0 ),
+    throttle_idle( true ),
+    gear_down( false )
 {
 }
 
 
 void FGControls::reset_all()
 {
-    set_aileron(0.0);
-    set_aileron_trim(0.0);
-    set_elevator(0.0);
-    set_elevator_trim(0.0);
-    set_rudder(0.0);
-    set_rudder_trim(0.0);
-    set_throttle(FGControls::ALL_ENGINES, 0.0);
-    set_starter(FGControls::ALL_ENGINES, false);
-    set_magnetos(FGControls::ALL_ENGINES, 0);
+    set_aileron( 0.0 );
+    set_aileron_trim( 0.0 );
+    set_elevator( 0.0 );
+    set_elevator_trim( 0.0 );
+    set_rudder( 0.0 );
+    set_rudder_trim( 0.0 );
+    set_throttle( ALL_ENGINES, 0.0 );
+    set_starter( ALL_ENGINES, false );
+    set_magnetos( ALL_ENGINES, 0 );
+    set_fuel_pump( ALL_ENGINES, false );
     throttle_idle = true;
+    set_fuel_selector( ALL_TANKS, true );
     gear_down = true;
 }
 
@@ -91,6 +96,7 @@ FGControls::init ()
     for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
        throttle[engine] = 0.0;
        mixture[engine] = 1.0;
+       fuel_pump[engine] = false;
        prop_advance[engine] = 1.0;
        magnetos[engine] = 0;
        starter[engine] = false;
@@ -100,7 +106,6 @@ FGControls::init ()
         brake[wheel] = 0.0;
     }
 
-    parking_brake = 0.0;
     auto_coordination = fgGetNode("/sim/auto-coordination", true);
 }
 
@@ -140,6 +145,10 @@ FGControls::bind ()
     fgTie(name, this, index,
         &FGControls::get_mixture, &FGControls::set_mixture);
     fgSetArchivable(name);
+    sprintf(name, "/controls/fuel-pump[%d]", index);
+    fgTie(name, this, index,
+        &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
+    fgSetArchivable(name);
     sprintf(name, "/controls/propeller-pitch[%d]", index);
     fgTie(name, this, index,
         &FGControls::get_prop_advance, &FGControls::set_prop_advance);
@@ -157,11 +166,18 @@ FGControls::bind ()
        &FGControls::get_parking_brake, &FGControls::set_parking_brake);
   fgSetArchivable("/controls/parking-brake");
   for (index = 0; index < MAX_WHEELS; index++) {
-    char name[32];
-    sprintf(name, "/controls/brakes[%d]", index);
-    fgTie(name, this, index,
-        &FGControls::get_brake, &FGControls::set_brake);
-    fgSetArchivable(name);
+      char name[32];
+      sprintf(name, "/controls/brakes[%d]", index);
+      fgTie(name, this, index,
+            &FGControls::get_brake, &FGControls::set_brake);
+      fgSetArchivable(name);
+  }
+  for (index = 0; index < MAX_TANKS; index++) {
+      char name[32];
+      sprintf(name, "/controls/fuel-selector[%d]", index);
+      fgTie(name, this, index,
+            &FGControls::get_fuel_selector, &FGControls::set_fuel_selector);
+      fgSetArchivable(name);
   }
   fgTie("/controls/gear-down", this,
        &FGControls::get_gear_down, &FGControls::set_gear_down);
@@ -187,6 +203,8 @@ FGControls::unbind ()
     fgUntie(name);
     sprintf(name, "/controls/mixture[%d]", index);
     fgUntie(name);
+    sprintf(name, "/controls/fuel-pump[%d]", index);
+    fgUntie(name);
     sprintf(name, "/controls/propeller-pitch[%d]", index);
     fgUntie(name);
     sprintf(name, "/controls/magnetos[%d]", index);
@@ -199,12 +217,13 @@ FGControls::unbind ()
     sprintf(name, "/controls/brakes[%d]", index);
     fgUntie(name);
   }
+  fgUntie("/controls/fuel-selector");
   fgUntie("/controls/gear-down");
 }
 
 
 void
-FGControls::update (int dt)
+FGControls::update (double dt)
 {
 }
 
@@ -386,6 +405,20 @@ FGControls::move_mixture( int engine, double amt )
     }
 }
 
+void
+FGControls::set_fuel_pump( int engine, bool val )
+{
+    if ( engine == ALL_ENGINES ) {
+       for ( int i = 0; i < MAX_ENGINES; i++ ) {
+           fuel_pump[i] = val;
+       }
+    } else {
+       if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
+           fuel_pump[engine] = val;
+       }
+    }
+}
+
 void
 FGControls::set_prop_advance( int engine, double pos )
 {
@@ -464,6 +497,21 @@ FGControls::set_starter( int engine, bool flag )
     }
 }
 
+void
+FGControls::set_fuel_selector( int tank, bool pos )
+{
+    if ( tank == ALL_TANKS ) {
+       for ( int i = 0; i < MAX_TANKS; i++ ) {
+           fuel_selector[i] = pos;
+       }
+    } else {
+       if ( (tank >= 0) && (tank < MAX_TANKS) ) {
+           fuel_selector[tank] = pos;
+       }
+    }
+}
+
+
 void
 FGControls::set_parking_brake( double pos )
 {