]> git.mxchange.org Git - flightgear.git/commitdiff
David Megginson's changes:
authorcurt <curt>
Sun, 23 Jul 2000 00:11:04 +0000 (00:11 +0000)
committercurt <curt>
Sun, 23 Jul 2000 00:11:04 +0000 (00:11 +0000)
src/Cockpit/radiostack.cxx
- extended VOR ranges to make them slightly more usable (pending some
  real radio code)

src/Cockpit/sp_panel.cxx
- fixed heading bug on gyro compass (sort-of -- the AP still doesn't
  work quite as expected)
- skid ball moves the right direction
- moved whiskey compass more to the co-pilot's side, as suggested by
  Alex a while back

src/Joystick/joystick.cxx
- included Norm's Windows patches
- renamed brake properties (see bfi.cxx, below)

src/Main/bfi.cxx
src/Main/bfi.hxx
- renamed getBrake and setBrake to getBrakes and setBrakes
- added getCenterBrake and setCenterBrake
- added getAPHeading (without mag correction, needed for the panel)
- renamed property /controls/brake to /controls/brakes/all
- renamed property /controls/left-brake to /controls/brakes/left (as
  requested by Alex)
- renamed property /controls/right-brake to /controls/brakes/right (as
  requested by Alex)
- added property /controls/brakes/center
- added property /autopilot/settings/heading
- fixed bug in setAltitude so that altitude will be property restored
  from a save file
- fixed getBrakes to return the highest of the three brake settings

src/Main/save.cxx
- call FGBFI::getBrakes instead of FGBFI::getBrake

src/Cockpit/radiostack.cxx
src/Cockpit/sp_panel.cxx
src/Joystick/joystick.cxx
src/Main/bfi.cxx
src/Main/bfi.hxx
src/Main/save.cxx

index 78b177f041aa961d3bdd9c229900e14924b64725..46931cf66146ce8fa8437828ec10afc1fcd582a7 100644 (file)
@@ -37,7 +37,7 @@ kludgeRange (double stationElev, double aircraftElev, double nominalRange)
                                // Assume that the nominal range (usually
                                // 50nm) applies at a 5,000 ft difference.
                                // Just a wild guess!
-  double factor = ((aircraftElev*METER_TO_FEET) - stationElev) / 5000.0;
+  double factor = ((aircraftElev*METER_TO_FEET) - stationElev) / 1000.0;
   double range = fabs(nominalRange * factor);
 
                                // Clamp the range to keep it sane; for
index 136fbefbcc16bd63d078046fed41c104cfcfd5a6..d36d178aec3ad0cc040d9f41b68c593e3f8ba643 100644 (file)
@@ -403,7 +403,7 @@ struct InstrumentData
 InstrumentData instruments[] =
 {
 
-  {"magcompass", 512, 459, SIX_W, SIX_W/2, {}, {
+  {"magcompass", 768, 459, SIX_W, SIX_W/2, {}, {
     {new MagRibbon(int(SIX_W*0.8), int(SIX_W*0.2))},
     {new MyTexturedLayer("compassFront", SIX_W, SIX_W*(24.0/80.0))}
   }},
@@ -465,7 +465,7 @@ InstrumentData instruments[] =
     {new MyTexturedLayer("turnBall",
        int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0))), {
       {TransData::Rotation, FGSteam::get_TC_rad,
-        -0.1, 0.1, -2000.0, 0.0},
+        -0.1, 0.1, 400.0, 0.0},
       {TransData::YShift, 0, 0.0, 0.0, 0.0, -(SIX_W/4)+4}
     }}
   }},
@@ -558,8 +558,8 @@ InstrumentData instruments[] =
     }},
     {new MyTexturedLayer("bug",
                         int(SIX_W*(4.0/64.0)), int(SIX_W*(4.0/64.0))), {
-      {TransData::Rotation, FGBFI::getAPHeadingMag, -720.0, 720.0, 1.0, 0.0},
-      {TransData::Rotation, FGSteam::get_DG_deg, -720.0, 720.0, 1.0, 0.0},
+      {TransData::Rotation, FGBFI::getAPHeading, -720.0, 720.0, 1.0, 180.0},
+      {TransData::Rotation, FGSteam::get_DG_deg, -720.0, 720.0, -1.0, 0.0},
       {TransData::YShift, 0, 0.0, 0.0, 0.0, -(SIX_W/2.0)+4}
     }},
     {new MyTexturedLayer("compassCenter", int(SIX_W*0.625), int(SIX_W*0.625))},
@@ -567,7 +567,7 @@ InstrumentData instruments[] =
        int(SIX_W*(21.0/112.0)), int(SIX_W*(21.0/112.0))), {
       {TransData::XShift, 0, 0.0, 0.0, 0.0, SIX_W/2-10},
       {TransData::YShift, 0, 0.0, 0.0, 0.0, -SIX_W/2+10},
-      {TransData::Rotation, FGBFI::getAPHeadingMag, -360.0, 360.0, 1.0, 0.0}
+      {TransData::Rotation, FGBFI::getAPHeading, -360.0, 360.0, 1.0, 0.0}
     }},
     {new MyTexturedLayer("knob",
                         int(SIX_W*(22.0/112.0)), int(SIX_W*(22.0/112.0))), {
index dc97db4db6a0f55186ed95b0a6be2fb47d659415..18f81ac1f62cf22bcdb530d2ce288a28e5f55898 100644 (file)
@@ -132,20 +132,20 @@ setupDefaults ()
     // Default axis 0 to aileron
     if (!props.getValue("/input/js0/axis0/control")) {
        props.setStringValue("/input/js0/axis0/control", "/controls/aileron");
-       props.setFloatValue("/input/js0/axis0/dead-band", 0.1);
+       props.setDoubleValue("/input/js0/axis0/dead-band", 0.1);
     }
 
     // Default axis 1 to elevator
     if (!props.getValue("/input/js0/axis1/control")) {
        props.setStringValue("/input/js0/axis1/control", "/controls/elevator");
-       props.setFloatValue("/input/js0/axis1/dead-band", 0.1);
-       props.setFloatValue("/input/js0/axis1/factor", -1.0);
+       props.setDoubleValue("/input/js0/axis1/dead-band", 0.1);
+       props.setDoubleValue("/input/js0/axis1/factor", -1.0);
     }
 
     // Default axis 2 to rudder
     if (!props.getValue("/input/js0/axis2/control")) {
        props.setStringValue("/input/js0/axis2/control", "/controls/rudder");
-       props.setFloatValue("/input/js0/axis2/dead-band", 0.1);
+       props.setDoubleValue("/input/js0/axis2/dead-band", 0.1);
     }
 
     // Default axis 3 to throttle
@@ -153,34 +153,35 @@ setupDefaults ()
     // and factor to make it work
     if (!props.getValue("/input/js0/axis3/control")) {
        props.setStringValue("/input/js0/axis3/control", "/controls/throttle");
-       props.setFloatValue("/input/js0/axis3/dead-band", 0.0);
-       props.setFloatValue("/input/js0/axis3/offset", -1.0);
-       props.setFloatValue("/input/js0/axis3/factor", -0.5);
+       props.setDoubleValue("/input/js0/axis3/dead-band", 0.0);
+       props.setDoubleValue("/input/js0/axis3/offset", -1.0);
+       props.setDoubleValue("/input/js0/axis3/factor", -0.5);
     }
 
     // Default button 0 to all brakes
     if (!props.getValue("/input/js0/button0/control")) {
        props.setStringValue("/input/js0/button0/action", "switch");
-       props.setStringValue("/input/js0/button0/control", "/controls/brake");
-       props.setFloatValue("/input/js0/button0/step", 1.0);
-       props.setFloatValue("/input/js0/button0/repeatable", false);
+       props.setStringValue("/input/js0/button0/control", "/controls/brakes/all");
+       props.setDoubleValue("/input/js0/button0/step", 1.0);
+       props.setDoubleValue("/input/js0/button0/repeatable", false);
     }
 
     // Default button 1 to left brake.
     if (!props.getValue("/input/js0/button1/control")) {
        props.setStringValue("/input/js0/button1/action", "switch");
-       props.setStringValue("/input/js0/button1/control", "/controls/left-brake");
-       props.setFloatValue("/input/js0/button1/step", 1.0);
-       props.setFloatValue("/input/js0/button1/repeatable", false);
+       props.setStringValue("/input/js0/button1/control",
+                            "/controls/brakes/left");
+       props.setDoubleValue("/input/js0/button1/step", 1.0);
+       props.setDoubleValue("/input/js0/button1/repeatable", false);
     }
 
     // Default button 2 to right brake.
     if (!props.getValue("/input/js0/button2/control")) {
        props.setStringValue("/input/js0/button2/action", "switch");
        props.setStringValue("/input/js0/button2/control",
-                            "/controls/right-brake");
-       props.setFloatValue("/input/js0/button2/step", 1.0);
-       props.setFloatValue("/input/js0/button2/repeatable", false);
+                            "/controls/brakes/right");
+       props.setDoubleValue("/input/js0/button2/step", 1.0);
+       props.setDoubleValue("/input/js0/button2/repeatable", false);
     }
 
     // Default buttons 3 and 4 to elevator trim
@@ -188,14 +189,14 @@ setupDefaults ()
        props.setStringValue("/input/js0/button3/action", "adjust");
        props.setStringValue("/input/js0/button3/control",
                             "/controls/elevator-trim");
-       props.setFloatValue("/input/js0/button3/step", 0.001);
+       props.setDoubleValue("/input/js0/button3/step", 0.001);
        props.setBoolValue("/input/js0/button3/repeatable", true);
     }
     if (!props.getValue("/input/js0/button4/control")) {
        props.setStringValue("/input/js0/button4/action", "adjust");
        props.setStringValue("/input/js0/button4/control",
                             "/controls/elevator-trim");
-       props.setFloatValue("/input/js0/button4/step", -0.001);
+       props.setDoubleValue("/input/js0/button4/step", -0.001);
        props.setBoolValue("/input/js0/button4/repeatable", true);
     }
 
@@ -203,13 +204,13 @@ setupDefaults ()
     if (!props.getValue("/input/js0/button5/control")) {
        props.setStringValue("/input/js0/button5/action", "adjust");
        props.setStringValue("/input/js0/button5/control", "/controls/flaps");
-       props.setFloatValue("/input/js0/button5/step", -0.34);
+       props.setDoubleValue("/input/js0/button5/step", -0.34);
        props.setBoolValue("/input/js0/button5/repeatable", false);
     }
     if (!props.getValue("/input/js0/button6/control")) {
        props.setStringValue("/input/js0/button6/action", "adjust");
        props.setStringValue("/input/js0/button6/control", "/controls/flaps");
-       props.setFloatValue("/input/js0/button6/step", 0.34);
+       props.setDoubleValue("/input/js0/button6/step", 0.34);
        props.setBoolValue("/input/js0/button6/repeatable", false);
     }
 }
@@ -293,7 +294,7 @@ fgJoystickInit()
            name += "/dead-band";
            value = current_properties.getValue(name);
            if (value != 0)
-               js->setDeadBand(j, value->getFloatValue());
+               js->setDeadBand(j, value->getDoubleValue());
            FG_LOG(FG_INPUT, FG_INFO, "    dead-band is " << js->getDeadBand(j));
 
            // Offset
@@ -301,7 +302,7 @@ fgJoystickInit()
            name += "/offset";
            value = current_properties.getValue(name);
            if (value != 0)
-               a.offset = value->getFloatValue();
+               a.offset = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    offset is " << a.offset);
 
 
@@ -310,7 +311,7 @@ fgJoystickInit()
            name += "/factor";
            value = current_properties.getValue(name);
            if (value != 0)
-               a.factor = value->getFloatValue();
+               a.factor = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    factor is " << a.factor);
 
 
@@ -319,7 +320,7 @@ fgJoystickInit()
            name += "/tolerance";
            value = current_properties.getValue(name);
            if (value != 0)
-               a.tolerance = value->getFloatValue();
+               a.tolerance = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    tolerance is " << a.tolerance);
 
 
@@ -328,7 +329,7 @@ fgJoystickInit()
            name += "/saturation";
            value = current_properties.getValue(name);
            if (value != 0)
-               js->setSaturation(j, value->getFloatValue());
+               js->setSaturation(j, value->getDoubleValue());
            FG_LOG(FG_INPUT, FG_INFO, "    saturation is " << js->getSaturation(j));
 
            // Minimum range
@@ -336,7 +337,7 @@ fgJoystickInit()
            name += "/min-range";
            value = current_properties.getValue(name);
            if (value != 0)
-               minRange[j] = value->getFloatValue();
+               minRange[j] = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    min-range is " << minRange[j]);
 
            // Maximum range
@@ -344,7 +345,7 @@ fgJoystickInit()
            name += "/max-range";
            value = current_properties.getValue(name);
            if (value != 0)
-               maxRange[j] = value->getFloatValue();
+               maxRange[j] = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    max-range is " << maxRange[j]);
 
            // Center
@@ -352,7 +353,7 @@ fgJoystickInit()
            name += "/center";
            value = current_properties.getValue(name);
            if (value != 0)
-               center[j] = value->getFloatValue();
+               center[j] = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    center is " << center[j]);
        }
 
@@ -387,7 +388,7 @@ fgJoystickInit()
            name += "/step";
            value = current_properties.getValue(name);
            if (value != 0)
-               b.step = value->getFloatValue();
+               b.step = value->getDoubleValue();
            FG_LOG(FG_INPUT, FG_INFO, "    step is " << b.step);
 
            // Type
index e46c55c790d47ac99e6a651c79bcdc9abcea682b..73ad21679bb6197e4c6f63266fc7c87362182fca 100644 (file)
@@ -139,10 +139,6 @@ FGBFI::init ()
                               getThrottle, setThrottle);
   current_properties.tieDouble("/controls/flaps",
                               getFlaps, setFlaps);
-  current_properties.tieBool  ("/controls/flaps/raise",
-                              0, setFlapsRaise);
-  current_properties.tieBool  ("/controls/flaps/lower",
-                              0, setFlapsLower);
   current_properties.tieDouble("/controls/aileron",
                               getAileron, setAileron);
   current_properties.tieDouble("/controls/rudder",
@@ -151,8 +147,18 @@ FGBFI::init ()
                               getElevator, setElevator);
   current_properties.tieDouble("/controls/elevator-trim",
                               getElevatorTrim, setElevatorTrim);
+  current_properties.tieDouble("/controls/brakes/all",
+                              getBrakes, setBrakes);
+  current_properties.tieDouble("/controls/brakes/left",
+                              getLeftBrake, setLeftBrake);
+  current_properties.tieDouble("/controls/brakes/right",
+                              getRightBrake, setRightBrake);
+  current_properties.tieDouble("/controls/brakes/Center",
+                              getRightBrake, setCenterBrake);
+
+                               // Deprecated...
   current_properties.tieDouble("/controls/brake",
-                              getBrake, setBrake);
+                              getBrakes, setBrakes);
   current_properties.tieDouble("/controls/left-brake",
                               getLeftBrake, setLeftBrake);
   current_properties.tieDouble("/controls/right-brake",
@@ -165,6 +171,8 @@ FGBFI::init ()
                               getAPAltitude, setAPAltitude);
   current_properties.tieBool("/autopilot/locks/heading",
                             getAPHeadingLock, setAPHeadingLock);
+  current_properties.tieDouble("/autopilot/settings/heading",
+                              getAPHeading, setAPHeading);
   current_properties.tieDouble("/autopilot/settings/heading-magnetic",
                               getAPHeadingMag, setAPHeadingMag);
   current_properties.tieBool("/autopilot/locks/nav1",
@@ -258,7 +266,7 @@ FGBFI::reinit ()
   double throttle = getThrottle();
   double elevator_trim = getElevatorTrim();
   double flaps = getFlaps();
-  double brake = getBrake();
+  double brake = getBrakes();
   bool apHeadingLock = getAPHeadingLock();
   double apHeadingMag = getAPHeadingMag();
   bool apAltitudeLock = getAPAltitudeLock();
@@ -291,7 +299,7 @@ FGBFI::reinit ()
   setThrottle(throttle);
   setElevatorTrim(elevator_trim);
   setFlaps(flaps);
-  setBrake(brake);
+  setBrakes(brake);
   setAPHeadingLock(apHeadingLock);
   setAPHeadingMag(apHeadingMag);
   setAPAltitudeLock(apAltitudeLock);
@@ -528,8 +536,8 @@ void
 FGBFI::setAltitude (double altitude)
 {
   fgFDMForceAltitude(getFlightModel(), altitude * FEET_TO_METER);
-//   current_options.set_altitude(altitude * FEET_TO_METER);
-//   current_aircraft.fdm_state->set_Altitude(altitude);
+  current_options.set_altitude(altitude * FEET_TO_METER);
+  current_aircraft.fdm_state->set_Altitude(altitude);
 //   needReinit();
 }
 
@@ -783,24 +791,6 @@ FGBFI::setFlaps (double flaps)
 }
 
 
-void
-FGBFI::setFlapsRaise (bool step)
-{
-    if (step)
-       controls.set_flaps(controls.get_flaps() - 0.26);
-    printf ( "Raise: %i\n", step );
-}
-
-
-void
-FGBFI::setFlapsLower (bool step)
-{
-    if (step)
-       controls.set_flaps(controls.get_flaps() + 0.26);
-    printf ( "Lower: %i\n", step );
-}
-
-
 /**
  * Get the aileron, from -1.0 (left) to 1.0 (right).
  */
@@ -886,23 +876,47 @@ FGBFI::setElevatorTrim (double trim)
 
 
 /**
- * Get the brake setting, from 0.0 (none) to 1.0 (full).
+ * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
  */
 double
-FGBFI::getBrake ()
+FGBFI::getBrakes ()
+{
+  double b1 = getCenterBrake();
+  double b2 = getLeftBrake();
+  double b3 = getRightBrake();
+  return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
+}
+
+
+/**
+ * Set all brakes, from 0.0 (none) to 1.0 (full).
+ */
+void
+FGBFI::setBrakes (double brake)
+{
+  setCenterBrake(brake);
+  setLeftBrake(brake);
+  setRightBrake(brake);
+}
+
+
+/**
+ * Get the center brake, from 0.0 (none) to 1.0 (full).
+ */
+double
+FGBFI::getCenterBrake ()
 {
-                               // FIXME: add brake selector
   return controls.get_brake(2);
 }
 
 
 /**
- * Set the brake, from 0.0 (none) to 1.0 (full).
+ * Set the center brake, from 0.0 (none) to 1.0 (full).
  */
 void
-FGBFI::setBrake (double brake)
+FGBFI::setCenterBrake (double brake)
 {
-  controls.set_brake(FGControls::ALL_WHEELS, brake);
+  controls.set_brake(2, brake);
 }
 
 
@@ -1029,6 +1043,26 @@ FGBFI::setAPHeadingLock (bool lock)
 }
 
 
+/**
+ * Get the autopilot target heading in degrees.
+ */
+double
+FGBFI::getAPHeading ()
+{
+  return current_autopilot->get_TargetHeading();
+}
+
+
+/**
+ * Set the autopilot target heading in degrees.
+ */
+void
+FGBFI::setAPHeading (double heading)
+{
+  current_autopilot->set_TargetHeading( heading );
+}
+
+
 /**
  * Get the autopilot target heading in degrees.
  */
index 867acce49e1570aa484f01606596be05487217b7..aa249200878e16ca0bcbc45b1342d0d5b72a43ee 100644 (file)
@@ -110,32 +110,34 @@ public:
   static double getRudder ();
   static double getElevator ();
   static double getElevatorTrim ();
-  static double getBrake ();
+  static double getBrakes ();
   static double getLeftBrake ();
   static double getRightBrake ();
+  static double getCenterBrake ();
 
   static void setThrottle (double throttle);
   static void setFlaps (double flaps);
-  static void setFlapsRaise (bool step);
-  static void setFlapsLower (bool step);
   static void setAileron (double aileron);
   static void setRudder (double rudder);
   static void setElevator (double elevator);
   static void setElevatorTrim (double trim);
-  static void setBrake (double brake);
+  static void setBrakes (double brake);
   static void setLeftBrake (double brake);
   static void setRightBrake (double brake);
+  static void setCenterBrake (double brake);
 
 
                                // Autopilot
   static bool getAPAltitudeLock ();
   static double getAPAltitude ();
   static bool getAPHeadingLock ();
+  static double getAPHeading ();
   static double getAPHeadingMag ();
 
   static void setAPAltitudeLock (bool lock);
   static void setAPAltitude (double altitude);
   static void setAPHeadingLock (bool lock);
+  static void setAPHeading (double heading);
   static void setAPHeadingMag (double heading);
 
   static bool getAPNAV1Lock ();
index 2cb9dedde35d804231c693231c14756c52f17e96..0fd919c13173581bb96866e3f2cebd987cad4cb8 100644 (file)
@@ -104,8 +104,7 @@ fgSaveFlight (ostream &output)
   //
   SAVE("elevator-trim", FGBFI::getElevatorTrim());
   SAVE("flaps", FGBFI::getFlaps());
-                               // FIXME: save each brake separately
-  SAVE("brake", FGBFI::getBrake());
+  SAVE("brake", FGBFI::getBrakes());
 
   //
   // Radio navigation
@@ -323,7 +322,7 @@ fgLoadFlight (istream &input)
     else if (text == "brake:") {
       input >> n;
       cout << "brake is " << n << endl;
-      FGBFI::setBrake(n);
+      FGBFI::setBrakes(n);
     }