X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FControls%2Fcontrols.hxx;h=c4376e3e28696170ee3e25a228b10698c558b2c8;hb=250bab50893b0e0929521aa48779dbc382319bb1;hp=e12c4362e971b9962bf3965810330f39c1132dad;hpb=01c44cbb99691b2a38527b40721330b2b143e604;p=flightgear.git diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index e12c4362e..c4376e3e2 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -24,6 +24,10 @@ #ifndef _CONTROLS_HXX #define _CONTROLS_HXX +#include + +#include +#include
#include
#ifndef __cplusplus @@ -33,7 +37,8 @@ // Define a structure containing the control parameters -class FGControls { +class FGControls : public FGSubsystem +{ public: @@ -60,18 +65,34 @@ private: double mixture[MAX_ENGINES]; double prop_advance[MAX_ENGINES]; double brake[MAX_WHEELS]; + int magnetos[MAX_ENGINES]; bool throttle_idle; + bool starter[MAX_ENGINES]; + bool gear_down; + + SGPropertyNode * auto_coordination; inline void CLAMP(double *x, double min, double max ) { if ( *x < min ) { *x = min; } if ( *x > max ) { *x = max; } } - + + inline void CLAMP(int *i, int min, int max ) { + if ( *i < min ) { *i = min; } + if ( *i > max ) { *i = max; } + } + public: FGControls(); ~FGControls(); + // Implementation of FGSubsystem. + void init (); + void bind (); + void unbind (); + void update (); + // Reset function void reset_all(void); @@ -87,6 +108,9 @@ public: return prop_advance[engine]; } inline double get_brake(int wheel) const { return brake[wheel]; } + inline int get_magnetos(int engine) const { return magnetos[engine]; } + inline bool get_starter(int engine) const { return starter[engine]; } + inline bool get_gear_down() const { return gear_down; } // Update functions inline void set_aileron( double pos ) { @@ -94,8 +118,7 @@ public: CLAMP( &aileron, -1.0, 1.0 ); // check for autocoordination - if ( globals->get_options()->get_auto_coordination() == - FGOptions::FG_AUTO_COORD_ENABLED ) + if ( auto_coordination->getBoolValue() ) { set_rudder( aileron / 2.0 ); } @@ -105,8 +128,7 @@ public: CLAMP( &aileron, -1.0, 1.0 ); // check for autocoordination - if ( globals->get_options()->get_auto_coordination() == - FGOptions::FG_AUTO_COORD_ENABLED ) + if ( auto_coordination->getBoolValue() ) { set_rudder( aileron / 2.0 ); } @@ -136,10 +158,16 @@ public: CLAMP( &rudder, -1.0, 1.0 ); } inline void set_flaps( double pos ) { + if ( flaps != pos ) { + globals->get_soundmgr()->play_once( "flaps" ); + } flaps = pos; CLAMP( &flaps, 0.0, 1.0 ); } inline void move_flaps( double amt ) { + if ( fabs(amt) > 0.0 ) { + globals->get_soundmgr()->play_once( "flaps" ); + } flaps += amt; CLAMP( &flaps, 0.0, 1.0 ); } @@ -221,6 +249,43 @@ public: } } } + inline void set_magnetos( int engine, int pos ) { + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + magnetos[i] = pos; + CLAMP( &magnetos[i], 0, 3 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + magnetos[engine] = pos; + CLAMP( &magnetos[engine], 0, 3 ); + } + } + } + inline void move_magnetos( int engine, int amt ) { + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + magnetos[i] += amt; + CLAMP( &magnetos[i], 0, 3 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + magnetos[engine] += amt; + CLAMP( &magnetos[engine], 0, 3 ); + } + } + } + inline void set_starter( int engine, bool flag ) { + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + starter[i] = flag; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + starter[engine] = flag; + } + } + } inline void set_brake( int wheel, double pos ) { if ( wheel == ALL_WHEELS ) { for ( int i = 0; i < MAX_WHEELS; i++ ) { @@ -247,12 +312,10 @@ public: } } } + inline void set_gear_down( bool gear ) { gear_down = gear; } }; -extern FGControls controls; - - #endif // _CONTROLS_HXX