]> git.mxchange.org Git - flightgear.git/blobdiff - src/Controls/controls.cxx
Make FlightGear work with 16bpp:
[flightgear.git] / src / Controls / controls.cxx
index 58d91fe7f5c375bd338792deb8ad364f5929720b..a36ee4d9d3c33a62fa3d910668ab7ca7c9014dcb 100644 (file)
@@ -72,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 ),
@@ -146,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;
@@ -199,11 +203,13 @@ FGControls::init ()
         water_injection[engine] = false;
         nitrous_injection[engine] = false;
         cowl_flaps_norm[engine] = 0.0;
-        condition[engine] = 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;
     }
 
@@ -346,7 +352,8 @@ FGControls::bind ()
          &FGControls::set_cowl_flaps_norm);
     fgSetArchivable(name);
 
-    snprintf(name, MAX_NAME_LEN, "/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);
@@ -420,10 +427,30 @@ 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/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);
@@ -448,11 +475,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,
@@ -834,7 +856,8 @@ void FGControls::unbind ()
     snprintf(name, MAX_NAME_LEN,
              "/controls/engines/engine[%d]/cowl-flaps-norm", index);
     fgUntie(name);
-    snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
+    snprintf(name, MAX_NAME_LEN,
+             "/controls/engines/engine[%d]/propeller-feather", index);
     fgUntie(name);
     snprintf(name, MAX_NAME_LEN,
              "/controls/engines/engine[%d]/ignition", index);
@@ -868,7 +891,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");
@@ -876,8 +901,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);
@@ -1514,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 );
        }
     }
 }
@@ -1594,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 )
+{
+    copilot_brake_right = pos;
+    CLAMP(&brake_right, 0.0, 1.0);
+}
+
+void
+FGControls::set_brake_parking( double pos )
 {
-    parking_brake = pos;
-    CLAMP(&parking_brake, 0.0, 1.0);
+    brake_parking = pos;
+    CLAMP(&brake_parking, 0.0, 1.0);
 }
 
 void
@@ -1639,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 )
 {