#ifndef _CONTROLS_HXX
#define _CONTROLS_HXX
-#include <Main/options.hxx>
+#include <simgear/misc/props.hxx>
+
+#include <Main/fgfs.hxx>
+#include <Main/globals.hxx>
#ifndef __cplusplus
# error This library requires C++
// Define a structure containing the control parameters
-class FGControls {
+class FGControls : public FGSubsystem
+{
public:
- enum
- {
+ enum {
ALL_ENGINES = -1,
MAX_ENGINES = 10
};
- enum
- {
+ enum {
ALL_WHEELS = -1,
MAX_WHEELS = 3
};
+ enum {
+ ALL_TANKS = -1,
+ MAX_TANKS = 4
+ };
+
private:
double aileron;
+ double aileron_trim;
double elevator;
double elevator_trim;
double rudder;
+ double rudder_trim;
+ double flaps;
double throttle[MAX_ENGINES];
+ double mixture[MAX_ENGINES];
+ double prop_advance[MAX_ENGINES];
+ double parking_brake;
double brake[MAX_WHEELS];
+ int magnetos[MAX_ENGINES];
+ bool throttle_idle;
+ bool starter[MAX_ENGINES];
+ bool fuel_selector[MAX_TANKS];
+ bool gear_down;
+
+ SGPropertyNode * auto_coordination;
public:
FGControls();
~FGControls();
+ // Implementation of FGSubsystem.
+ void init ();
+ void bind ();
+ void unbind ();
+ void update (double dt);
+
// Reset function
void reset_all(void);
// Query functions
inline double get_aileron() const { return aileron; }
+ inline double get_aileron_trim() const { return aileron_trim; }
inline double get_elevator() const { return elevator; }
inline double get_elevator_trim() const { return elevator_trim; }
inline double get_rudder() const { return rudder; }
+ inline double get_rudder_trim() const { return rudder_trim; }
+ inline double get_flaps() const { return flaps; }
inline double get_throttle(int engine) const { return throttle[engine]; }
+ inline double get_mixture(int engine) const { return mixture[engine]; }
+ inline double get_prop_advance(int engine) const {
+ return prop_advance[engine];
+ }
+ inline double get_parking_brake() const { return parking_brake; }
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_fuel_selector(int tank) const {
+ return fuel_selector[tank];
+ }
+ inline bool get_gear_down() const { return gear_down; }
// Update functions
- inline void set_aileron( double pos ) {
- aileron = pos;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
-
- // check for autocoordination
- if ( current_options.get_auto_coordination() ==
- fgOPTIONS::FG_AUTO_COORD_ENABLED )
- {
- set_rudder( aileron / 2.0 );
- }
- }
- inline void move_aileron( double amt ) {
- aileron += amt;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
-
- // check for autocoordination
- if ( current_options.get_auto_coordination() ==
- fgOPTIONS::FG_AUTO_COORD_ENABLED )
- {
- set_rudder( aileron / 2.0 );
- }
- }
- inline void set_elevator( double pos ) {
- elevator = pos;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
- }
- inline void move_elevator( double amt ) {
- elevator += amt;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
- }
- inline void set_elevator_trim( double pos ) {
- elevator_trim = pos;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
- }
- inline void move_elevator_trim( double amt ) {
- elevator_trim += amt;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
- }
- inline void set_rudder( double pos ) {
- rudder = pos;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
- }
- inline void move_rudder( double amt ) {
- rudder += amt;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
- }
- inline void set_throttle( int engine, double pos ) {
- if ( engine == ALL_ENGINES ) {
- for ( int i = 0; i < MAX_ENGINES; i++ ) {
- throttle[i] = pos;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
- }
- } else {
- if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
- throttle[engine] = pos;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
- }
- }
- }
- inline void move_throttle( int engine, double amt ) {
- if ( engine == ALL_ENGINES ) {
- for ( int i = 0; i < MAX_ENGINES; i++ ) {
- throttle[i] += amt;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
- }
- } else {
- if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
- throttle[engine] += amt;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
- }
- }
- }
- inline void set_brake( int wheel, double pos ) {
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] = pos;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] = pos;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
- }
- }
- }
- inline void move_brake( int wheel, double amt ) {
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] += amt;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] += amt;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
- }
- }
- }
+ void set_aileron( double pos );
+ void move_aileron( double amt );
+ void set_aileron_trim( double pos );
+ void move_aileron_trim( double amt );
+ void set_elevator( double pos );
+ void move_elevator( double amt );
+ void set_elevator_trim( double pos );
+ void move_elevator_trim( double amt );
+ void set_rudder( double pos );
+ void move_rudder( double amt );
+ void set_rudder_trim( double pos );
+ void move_rudder_trim( double amt );
+ void set_flaps( double pos );
+ void move_flaps( double amt );
+ void set_throttle( int engine, double pos );
+ void move_throttle( int engine, double amt );
+ void set_mixture( int engine, double pos );
+ void move_mixture( int engine, double amt );
+ void set_prop_advance( int engine, double pos );
+ void move_prop_advance( int engine, double amt );
+ void set_magnetos( int engine, int pos );
+ void move_magnetos( int engine, int amt );
+ void set_starter( int engine, bool flag );
+ void set_fuel_selector( int tank, bool pos );
+ void set_parking_brake( double pos );
+ void set_brake( int wheel, double pos );
+ void move_brake( int wheel, double amt );
+ void set_gear_down( bool gear );
};
-extern FGControls controls;
-
-
#endif // _CONTROLS_HXX