#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
+#include <Main/globals.hxx>
+
#include "aircraft.hxx"
// This is a record containing all the info for the aircraft currently
SG_LOG( SG_AIRCRAFT, SG_INFO, "Initializing Aircraft structure" );
current_aircraft.fdm_state = cur_fdm_state;
- current_aircraft.controls = &controls;
+ current_aircraft.controls = globals->get_controls();
}
SG_LOG( SG_FLIGHT, SG_DEBUG,
"Kts = " << f->get_V_equiv_kts()
- << " Elev = " << controls.get_elevator()
- << " Aileron = " << controls.get_aileron()
- << " Rudder = " << controls.get_rudder()
- << " Power = " << controls.get_throttle( 0 ) );
+ << " Elev = " << globals->get_controls()->get_elevator()
+ << " Aileron = " << globals->get_controls()->get_aileron()
+ << " Rudder = " << globals->get_controls()->get_rudder()
+ << " Power = " << globals->get_controls()->get_throttle( 0 ) );
}
void FGAutopilot::update_old_control_values() {
- old_aileron = controls.get_aileron();
- old_elevator = controls.get_elevator();
- old_elevator_trim = controls.get_elevator_trim();
- old_rudder = controls.get_rudder();
+ old_aileron = globals->get_controls()->get_aileron();
+ old_elevator = globals->get_controls()->get_elevator();
+ old_elevator_trim = globals->get_controls()->get_elevator_trim();
+ old_rudder = globals->get_controls()->get_rudder();
}
double AileronSet = -turn / 2.0;
if ( AileronSet < -1.0 ) { AileronSet = -1.0; }
if ( AileronSet > 1.0 ) { AileronSet = 1.0; }
- controls.set_aileron( AileronSet );
- controls.set_rudder( AileronSet / 4.0 );
+ globals->get_controls()->set_aileron( AileronSet );
+ globals->get_controls()->set_rudder( AileronSet / 4.0 );
} else {
// steer towards the target heading
MaxAileron );
}
- controls.set_aileron( AileronSet );
- controls.set_rudder( AileronSet / 4.0 );
+ globals->get_controls()->set_aileron( AileronSet );
+ globals->get_controls()->set_rudder( AileronSet / 4.0 );
// controls.set_rudder( 0.0 );
}
}
total_adj = -1.0;
}
- controls.set_elevator( total_adj );
+ globals->get_controls()->set_elevator( total_adj );
}
// auto throttle
total_adj = 0.0;
}
- controls.set_throttle( FGControls::ALL_ENGINES, total_adj );
+ globals->get_controls()->set_throttle( FGControls::ALL_ENGINES,
+ total_adj );
}
#ifdef THIS_CODE_IS_NOT_USED
// stash this runs control settings
// update_old_control_values();
- old_aileron = controls.get_aileron();
- old_elevator = controls.get_elevator();
- old_elevator_trim = controls.get_elevator_trim();
- old_rudder = controls.get_rudder();
+ old_aileron = globals->get_controls()->get_aileron();
+ old_elevator = globals->get_controls()->get_elevator();
+ old_elevator_trim = globals->get_controls()->get_elevator_trim();
+ old_rudder = globals->get_controls()->get_rudder();
// for cross track error
old_lat = lat;
#include <FDM/ADA.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <Main/viewmgr.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
#include <GUI/gui.h>
float get_throttleval( void )
{
- float throttle = controls.get_throttle( 0 );
+ float throttle = globals->get_controls()->get_throttle( 0 );
return (throttle); // Hack limiting to one engine
}
float get_aileronval( void )
{
- float aileronval = controls.get_aileron();
+ float aileronval = globals->get_controls()->get_aileron();
return (aileronval);
}
float get_elevatorval( void )
{
- float elevator_val = (float)controls.get_elevator();
+ float elevator_val = (float)globals->get_controls()->get_elevator();
return elevator_val;
}
float get_elev_trimval( void )
{
- float elevatorval = controls.get_elevator_trim();
+ float elevatorval = globals->get_controls()->get_elevator_trim();
return (elevatorval);
}
float get_rudderval( void )
{
- float rudderval = controls.get_rudder();
+ float rudderval = globals->get_controls()->get_rudder();
return (rudderval);
}
#include <GUI/gui.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <Main/viewmgr.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#endif
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <Main/viewmgr.hxx>
#include <Objects/texload.h>
#include <Time/light.hxx>
scaling capability for the vacuum pump later on.
When we have a real engine model, we can ask it.
*/
- the_ENGINE_rpm = controls.get_throttle(0) * 26.0;
+ the_ENGINE_rpm = globals->get_controls()->get_throttle(0) * 26.0;
/**************************
First, we need to know what the static line is reporting,
#include <Main/fg_props.hxx>
-FGControls controls;
-
-
// Constructor
FGControls::FGControls() :
aileron( 0.0 ),
#include <simgear/misc/props.hxx>
+#include <Sound/soundmgr.hxx>
#include <Main/fgfs.hxx>
#include <Main/globals.hxx>
};
-extern FGControls controls;
-
-
#endif // _CONTROLS_HXX
#include <Controls/controls.hxx>
#include <GUI/gui.h>
+#include <Main/globals.hxx>
#include "ADA.hxx"
// printf("psi = %f %f\n",Psi,Psi*SGD_RADIANS_TO_DEGREES);
// controls
- controls.set_throttle(0,throttle/131.0);
- controls.set_elevator(pstick);
- controls.set_aileron(rstick);
- controls.set_rudder(rpedal);
+ globals->get_controls()->set_throttle(0,throttle/131.0);
+ globals->get_controls()->set_elevator(pstick);
+ globals->get_controls()->set_aileron(rstick);
+ globals->get_controls()->set_rudder(rpedal);
// auxilliary parameters for HUD
set_iaux1(sixdof_to_visuals.iaux1);
}
// set control positions
- current_balloon.set_burner_strength ( controls.get_throttle(0) );
+ current_balloon.set_burner_strength ( globals->get_controls()->get_throttle(0) );
//not more implemented yet
// Inform BalloonSim of the local terrain altitude
aileron_trim->setDoubleValue( FCS->GetDaCmd() );
rudder_trim->setDoubleValue( FCS->GetDrCmd() );
- controls.set_elevator_trim(FCS->GetPitchTrimCmd());
- controls.set_elevator(FCS->GetDeCmd());
- controls.set_throttle(FGControls::ALL_ENGINES,
- FCS->GetThrottleCmd(0));
+ globals->get_controls()->set_elevator_trim(FCS->GetPitchTrimCmd());
+ globals->get_controls()->set_elevator(FCS->GetDeCmd());
+ globals->get_controls()->set_throttle(FGControls::ALL_ENGINES,
+ FCS->GetThrottleCmd(0));
- controls.set_aileron(FCS->GetDaCmd());
- controls.set_rudder( FCS->GetDrCmd());
+ globals->get_controls()->set_aileron(FCS->GetDaCmd());
+ globals->get_controls()->set_rudder( FCS->GetDrCmd());
SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" );
}
for( i=0; i<get_num_engines(); i++ ) {
get_engine(i)->set_RPM( Propulsion->GetThruster(i)->GetRPM() );
- get_engine(i)->set_Throttle( controls.get_throttle(i) );
+ get_engine(i)->set_Throttle( globals->get_controls()->get_throttle(i) );
}
for ( i=0; i < multiloop; i++ ) {
bool FGJSBsim::copy_to_JSBsim() {
// copy control positions into the JSBsim structure
- FCS->SetDaCmd( controls.get_aileron());
- FCS->SetDeCmd( controls.get_elevator());
- FCS->SetPitchTrimCmd(controls.get_elevator_trim());
- FCS->SetDrCmd( -controls.get_rudder());
- FCS->SetDfCmd( controls.get_flaps() );
+ FCS->SetDaCmd( globals->get_controls()->get_aileron());
+ FCS->SetDeCmd( globals->get_controls()->get_elevator());
+ FCS->SetPitchTrimCmd(globals->get_controls()->get_elevator_trim());
+ FCS->SetDrCmd( -globals->get_controls()->get_rudder());
+ FCS->SetDfCmd( globals->get_controls()->get_flaps() );
FCS->SetDsbCmd( 0.0 ); //speedbrakes
FCS->SetDspCmd( 0.0 ); //spoilers
FCS->SetThrottleCmd( FGControls::ALL_ENGINES,
- controls.get_throttle( 0 ));
- FCS->SetLBrake( controls.get_brake( 0 ) );
- FCS->SetRBrake( controls.get_brake( 1 ) );
- FCS->SetCBrake( controls.get_brake( 2 ) );
+ globals->get_controls()->get_throttle( 0 ));
+ FCS->SetLBrake( globals->get_controls()->get_brake( 0 ) );
+ FCS->SetRBrake( globals->get_controls()->get_brake( 1 ) );
+ FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) );
Position->SetSeaLevelRadius( get_Sea_level_radius() );
Position->SetRunwayRadius( scenery.cur_elev*SG_METER_TO_FEET
// set control inputs
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
eng.set_IAS( V_calibrated_kts );
- eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
+ eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
+ * 100.0 );
eng.set_Propeller_Lever_Pos( 100 );
- eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
+ eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
+ * 100.0 );
eng.set_p_amb( Static_pressure );
eng.set_T_amb( Static_temperature );
// copy engine state values onto "bus"
FGEngInterface *e = get_engine( 0 );
- e->set_Throttle( controls.get_throttle( 0 ) * 100.0 );
+ e->set_Throttle( globals->get_controls()->get_throttle( 0 ) * 100.0 );
e->set_Mixture( 80 );
e->set_Prop_Advance( 100 );
e->set_RPM( eng.get_RPM() );
#if 0
SG_LOG( SG_FLIGHT, SG_INFO, "Throttle = "
- << controls.get_throttle( 0 ) * 100.0);
+ << globals->get_controls()->get_throttle( 0 ) * 100.0);
SG_LOG( SG_FLIGHT, SG_INFO, " Mixture = " << 80);
SG_LOG( SG_FLIGHT, SG_INFO, " RPM = " << eng.get_RPM());
SG_LOG( SG_FLIGHT, SG_INFO, " MP = " << eng.get_Manifold_Pressure());
}
// copy control positions into the LaRCsim structure
- Lat_control = controls.get_aileron() /
+ Lat_control = globals->get_controls()->get_aileron() /
speed_up->getIntValue();
- Long_control = controls.get_elevator();
- Long_trim = controls.get_elevator_trim();
- Rudder_pedal = controls.get_rudder() /
+ Long_control = globals->get_controls()->get_elevator();
+ Long_trim = globals->get_controls()->get_elevator_trim();
+ Rudder_pedal = globals->get_controls()->get_rudder() /
speed_up->getIntValue();
- Flap_handle = 30.0 * controls.get_flaps();
+ Flap_handle = 30.0 * globals->get_controls()->get_flaps();
if ( aircraft->getStringValue() == "c172" ) {
Use_External_Engine = 1;
Use_External_Engine = 0;
}
- Throttle_pct = controls.get_throttle( 0 ) * 1.0;
+ Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
- Brake_pct[0] = controls.get_brake( 1 );
- Brake_pct[1] = controls.get_brake( 0 );
+ Brake_pct[0] = globals->get_controls()->get_brake( 1 );
+ Brake_pct[1] = globals->get_controls()->get_brake( 0 );
// Inform LaRCsim of the local terrain altitude
// Runway_altitude = get_Runway_altitude();
double time_step = get_delta_t() * multiloop;
// speed and distance traveled
- double speed = controls.get_throttle( 0 ) * 2000; // meters/sec
+ double speed = globals->get_controls()->get_throttle( 0 ) * 2000; // meters/sec
double dist = speed * time_step;
double kts = speed * SG_METER_TO_NM * 3600.0;
_set_V_equiv_kts( kts );
_set_V_ground_speed( kts );
// angle of turn
- double turn_rate = controls.get_aileron() * SGD_PI_4; // radians/sec
+ double turn_rate = globals->get_controls()->get_aileron() * SGD_PI_4; // radians/sec
double turn = turn_rate * time_step;
// update euler angles
sgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc );
// update altitude
- double real_climb_rate = -controls.get_elevator() * 5000; // feet/sec
+ double real_climb_rate = -globals->get_controls()->get_elevator() * 5000; // feet/sec
_set_Climb_Rate( real_climb_rate / 500.0 );
double climb = real_climb_rate * time_step;
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/options.hxx>
+#include <Main/viewmgr.hxx>
#ifdef FG_NETWORK_OLK
#include <NetworkOLK/network.h>
#include <FDM/flight.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_props.hxx>
-//#include <Main/views.hxx>
-//#include <Network/network.h>
-//#include <Time/fg_time.hxx>
+#include <Main/viewmgr.hxx>
#if defined( WIN32 ) && !defined( __CYGWIN__ )
# include <simgear/screen/win32-printer.h>
} else {
if ( left_button() ) {
offset = (_mX - x) * brake_sensitivity;
- controls.move_brake(FGControls::ALL_WHEELS, offset);
+ globals->get_controls()->move_brake(FGControls::ALL_WHEELS, offset);
offset = (_mY - y) * throttle_sensitivity;
- controls.move_throttle(FGControls::ALL_ENGINES, offset);
+ globals->get_controls()->move_throttle(FGControls::ALL_ENGINES, offset);
} else if ( right_button() ) {
if( ! current_autopilot->get_HeadingEnabled() ) {
offset = (x - _mX) * rudder_sensitivity;
- controls.move_rudder(offset);
+ globals->get_controls()->move_rudder(offset);
}
if( ! current_autopilot->get_AltitudeEnabled() ) {
offset = (_mY - y) * trim_sensitivity;
- controls.move_elevator_trim(offset);
+ globals->get_controls()->move_elevator_trim(offset);
}
} else {
if( ! current_autopilot->get_HeadingEnabled() ) {
offset = (x - _mX) * aileron_sensitivity;
- controls.move_aileron(offset);
+ globals->get_controls()->move_aileron(offset);
}
if( ! current_autopilot->get_AltitudeEnabled() ) {
offset = (_mY - y) * elevator_sensitivity;
- controls.move_elevator(offset);
+ globals->get_controls()->move_elevator(offset);
}
}
}
// try to have the MOUSE_YOKE position
// reflect the current stick position
- offset = controls.get_aileron();
+ offset = globals->get_controls()->get_aileron();
x = _mX - (int)(offset * aileron_sensitivity);
- offset = controls.get_elevator();
+ offset = globals->get_controls()->get_elevator();
y = _mY - (int)(offset * elevator_sensitivity);
glutSetCursor(GLUT_CURSOR_CROSSHAIR);
#include "fg_props.hxx"
#include "fg_io.hxx"
#include "globals.hxx"
+#include "viewmgr.hxx"
\f
#include "fg_props.hxx"
#include "options.hxx"
#include "globals.hxx"
+#include "viewmgr.hxx"
#if defined(FX) && defined(XMESA)
#include <GL/xmesa.h>
// Initialize the controls subsystem.
////////////////////////////////////////////////////////////////////
- controls.init();
- controls.bind();
+ globals->get_controls()->init();
+ globals->get_controls()->bind();
////////////////////////////////////////////////////////////////////
cur_fdm_state->init();
- controls.reset_all();
+ globals->get_controls()->reset_all();
current_autopilot->reset();
fgUpdateSunPos();
#include "fgfs.hxx"
#include "fg_props.hxx"
+#include "viewer.hxx"
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(istream);
if (getAPHeadingLock())
return current_autopilot->get_TargetHeading();
else
- return controls.get_rudder();
+ return globals->get_controls()->get_rudder();
}
// kludge
value -= current_autopilot->get_TargetHeading();
current_autopilot->HeadingAdjust(value < 0.0 ? -1.0 : 1.0);
} else {
- controls.set_rudder(value);
+ globals->get_controls()->set_rudder(value);
}
}
if (getAPAltitudeLock())
return current_autopilot->get_TargetAltitude();
else
- return controls.get_elevator();
+ return globals->get_controls()->get_elevator();
}
// kludge
value -= current_autopilot->get_TargetAltitude();
current_autopilot->AltitudeAdjust(value < 0.0 ? 100.0 : -100.0);
} else {
- controls.set_elevator(value);
+ globals->get_controls()->set_elevator(value);
}
}
if (getAPAutoThrottleLock())
return 0.0; // always resets
else
- return controls.get_throttle(0);
+ return globals->get_controls()->get_throttle(0);
}
// kludge
if (getAPAutoThrottleLock())
current_autopilot->AutoThrottleAdjust(value < 0.0 ? -0.01 : 0.01);
else
- controls.set_throttle(0, value);
+ globals->get_controls()->set_throttle(0, value);
}
#include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx>
-#include <Sound/soundmgr.hxx>
-#include "viewmgr.hxx"
+// #include <Controls/controls.hxx>
+// #include <Sound/soundmgr.hxx>
+// #include "viewmgr.hxx"
SG_USING_STD( vector );
SG_USING_STD( string );
typedef vector<string> string_list;
+// Forward declarations
+class FGControls;
+class FGSoundMgr;
+class FGViewMgr;
+class FGViewer;
+
class FGGlobals {
private:
// sound manager
FGSoundMgr *soundmgr;
+ // control input state
+ FGControls *controls;
+
// viewer manager
FGViewMgr *viewmgr;
FGViewer *current_view;
inline FGSoundMgr *get_soundmgr() const { return soundmgr; }
inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }
+ inline FGControls *get_controls() const { return controls; }
+ inline void set_controls( FGControls *c ) { controls = c; }
+
inline FGViewMgr *get_viewmgr() const { return viewmgr; }
inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
inline FGViewer *get_current_view() const { return current_view; }
#include "fg_props.hxx"
#include "globals.hxx"
#include "splash.hxx"
+#include "viewmgr.hxx"
#ifdef macintosh
# include <console.h> // -dw- for command line dialog
// set up moving parts
if (flaps_selector != NULL) {
- flaps_selector->select( (controls.get_flaps() > 0.5f) ? 1 : 2 );
+ flaps_selector->select( (globals->get_controls()->get_flaps() > 0.5f) ? 1 : 2 );
}
if (prop_selector != NULL) {
current_input.update();
// update the controls subsystem
- controls.update();
+ globals->get_controls()->update();
hud_and_panel->apply();
fgCockpitUpdate();
s1->set_pitch( pitch );
s1->set_volume( volume );
} else {
- double param = controls.get_throttle( 0 ) * 2.0 + 1.0;
+ double param
+ = globals->get_controls()->get_throttle( 0 ) * 2.0 + 1.0;
s1->set_pitch( param );
s1->set_volume( param );
}
SGRoute *route = new SGRoute;
globals->set_route( route );
+ FGControls *controls = new FGControls;
+ globals->set_controls( controls );
+
FGViewMgr *viewmgr = new FGViewMgr;
globals->set_viewmgr( viewmgr );
#include "fg_init.hxx"
#include "fg_props.hxx"
#include "options.hxx"
+#include "viewmgr.hxx"
SG_USING_STD(string);
SG_USING_NAMESPACE(std);
garmin.cxx garmin.hxx \
joyclient.cxx joyclient.hxx \
native.cxx native.hxx \
+ native_ctrls.cxx native_ctrls.hxx \
nmea.cxx nmea.hxx \
props.cxx props.hxx \
pve.cxx pve.hxx \
+ raw_ctrls.hxx \
ray.cxx ray.hxx \
rul.cxx rul.hxx
if ( fabs(elevator) < 0.05 ) {
elevator = 0.0;
}
- controls.set_aileron( aileron );
- controls.set_elevator( -elevator );
+ globals->get_controls()->set_aileron( aileron );
+ globals->get_controls()->set_elevator( -elevator );
}
} else {
while ( io->read( (char *)(& buf), length ) == length ) {
if ( fabs(elevator) < 0.05 ) {
elevator = 0.0;
}
- controls.set_aileron( aileron );
- controls.set_elevator( -elevator );
+ globals->get_controls()->set_aileron( aileron );
+ globals->get_controls()->set_elevator( -elevator );
}
}
}
#include <Cockpit/hud.hxx>
#include <plib/ssg.h>
#include <Main/globals.hxx>
+#include <Main/viewmgr.hxx>
//#define printf //
#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include "hitlist.hxx"
#include <simgear/misc/sg_path.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx> // for scenery.center
#include "newcache.hxx"
#include <Aircraft/aircraft.hxx>
#include <Include/general.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx>
#include <Time/light.hxx>
#include <Objects/apt_signs.hxx>
#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include <Objects/obj.hxx>
#ifndef FG_OLD_WEATHER
#include <Aircraft/aircraft.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include "light.hxx"
#include "sunpos.hxx"
#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx>
#include <Time/light.hxx>
// update the cur_time_params structure with the current moon position
void fgUpdateMoonPos( void ) {
fgLIGHT *l;
- FGViewerRPH *v;
+ FGViewer *v;
sgVec3 nup, nmoon;
Point3D p, rel_moonpos;
double dot, east_dot;
l = &cur_light_params;
SGTime *t = globals->get_time_params();
- v = (FGViewerRPH *)globals->get_current_view();
+ v = globals->get_current_view();
SG_LOG( SG_EVENT, SG_INFO, " Updating Moon position" );
#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
+#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx>
#include <Time/light.hxx>
// update the cur_time_params structure with the current sun position
void fgUpdateSunPos( void ) {
fgLIGHT *l;
- FGViewerRPH *v;
+ FGViewer *v;
sgVec3 nup, nsun;
Point3D p, rel_sunpos;
double dot, east_dot;
l = &cur_light_params;
SGTime *t = globals->get_time_params();
- v = (FGViewerRPH *)globals->get_current_view();
+ v = globals->get_current_view();
SG_LOG( SG_EVENT, SG_INFO, " Updating Sun position" );
SG_LOG( SG_EVENT, SG_INFO, " Gst = " << t->getGst() );