]> git.mxchange.org Git - flightgear.git/blobdiff - src/Controls/controls.cxx
Update controls so we can specify each tank on/off individually. Also
[flightgear.git] / src / Controls / controls.cxx
index 14685770a60fb68a59d9ee60d0f4dcbc9ad90ea1..106208d807e2f7f7ea0523e54ea4e37c3e6fdc90 100644 (file)
@@ -59,23 +59,27 @@ 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 );
     throttle_idle = true;
+    set_fuel_selector( ALL_TANKS, true );
     gear_down = true;
 }
 
@@ -156,11 +160,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);
@@ -198,12 +209,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)
 {
 }
 
@@ -463,6 +475,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 )
 {