]> git.mxchange.org Git - flightgear.git/blobdiff - src/Controls/controls.cxx
ignore resets for now because every z/Z key press would trigger a call to NOAA. We...
[flightgear.git] / src / Controls / controls.cxx
index 8ce911f843412788a2ad3bf6e7ebb80f5d8c7e73..c66088873896e58f001f8bf543fecbecf5a7f8b7 100644 (file)
@@ -72,7 +72,9 @@ FGControls::FGControls() :
     drag_chute( false ),
     throttle_idle( true ),
     dump_valve( false ),
-    parking_brake( 0.0 ),
+    brake_left( 0.0 ),
+    brake_right( 0.0 ),
+    brake_parking( 0.0 ),
     steering( 0.0 ),
     gear_down( true ),
     antiskid( true ),
@@ -88,6 +90,7 @@ FGControls::FGControls() :
     APU_bleed( false ),
     mode( 0 ),
     dump( false ),
+    outflow_valve( 0.0 ),
     taxi_light( false ),
     logo_lights( false ),
     nav_lights( false ),
@@ -101,7 +104,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 ),
@@ -165,7 +167,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;
@@ -196,11 +200,12 @@ FGControls::init ()
         reverser[engine] = false;
         water_injection[engine] = false;
         nitrous_injection[engine] = false;
+        cowl_flaps_norm[engine] = 0.0;
         condition[engine] = 0;
     }
 
+    brake_left = brake_right = brake_parking = 0.0;
     for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
-        brake[wheel] = 0.0;
         alternate_extension[wheel] = false;
     }
 
@@ -417,10 +422,20 @@ FGControls::bind ()
   }
 
   // gear
-  fgTie("/controls/gear/parking-brake", this,
-       &FGControls::get_parking_brake, 
-        &FGControls::set_parking_brake);
-  fgSetArchivable("/controls/gear/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/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);
@@ -445,11 +460,6 @@ FGControls::bind ()
 
   for (index = 0; index < MAX_WHEELS; index++) {
       char name[MAX_NAME_LEN];
-      snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
-      fgTie(name, this, index,
-            &FGControls::get_brake, &FGControls::set_brake);
-      fgSetArchivable(name);
-
       snprintf(name, MAX_NAME_LEN,
                "/controls/gear/wheel[%d]/alternate-extension", index);
       fgTie(name, this, index,
@@ -679,9 +689,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,
@@ -844,7 +875,9 @@ void FGControls::unbind ()
       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");
@@ -852,8 +885,6 @@ void FGControls::unbind ()
   fgUntie("/controls/gear/tailwheel-lock");
   for (index = 0; index < MAX_WHEELS; index++) {
     char name[MAX_NAME_LEN];
-    snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
-    fgUntie(name);
     snprintf(name, MAX_NAME_LEN, 
        "/controls/gear/wheel[%d]/alternate-extension", index);
     fgUntie(name);
@@ -940,7 +971,17 @@ void FGControls::unbind ()
 #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++) {
@@ -1560,10 +1601,38 @@ 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 )
 {
-    parking_brake = pos;
-    CLAMP(&parking_brake, 0.0, 1.0);
+    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_brake_parking( double pos )
+{
+    brake_parking = pos;
+    CLAMP(&brake_parking, 0.0, 1.0);
 }
 
 void
@@ -1605,38 +1674,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 )
 {
@@ -2031,11 +2068,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 )
 {