]> git.mxchange.org Git - flightgear.git/blob - src/Controls/controls.hxx
Added a fuel selector switch. I understand that this won't handle all
[flightgear.git] / src / Controls / controls.hxx
1 // controls.hxx -- defines a standard interface to all flight sim controls
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _CONTROLS_HXX
25 #define _CONTROLS_HXX
26
27 #include <simgear/misc/props.hxx>
28
29 #include <Main/fgfs.hxx>
30 #include <Main/globals.hxx>
31
32 #ifndef __cplusplus                                                          
33 # error This library requires C++
34 #endif                                   
35
36
37 // Define a structure containing the control parameters
38
39 class FGControls : public FGSubsystem
40 {
41
42 public:
43
44     enum {
45         ALL_ENGINES = -1,
46         MAX_ENGINES = 10
47     };
48
49     enum {
50         ALL_WHEELS = -1,
51         MAX_WHEELS = 3
52     };
53
54     enum {
55         FUEL_OFF = 0,
56         FUEL_LEFT = 1,
57         FUEL_RIGHT = 2,
58         FUEL_BOTH = 3
59     };
60
61 private:
62
63     double aileron;
64     double aileron_trim;
65     double elevator;
66     double elevator_trim;
67     double rudder;
68     double rudder_trim;
69     double flaps;
70     double throttle[MAX_ENGINES];
71     double mixture[MAX_ENGINES];
72     double prop_advance[MAX_ENGINES];
73     double parking_brake;
74     double brake[MAX_WHEELS];
75     int magnetos[MAX_ENGINES];
76     bool throttle_idle;
77     bool starter[MAX_ENGINES];
78     int fuel_selector;
79     bool gear_down;
80
81     SGPropertyNode * auto_coordination;
82
83 public:
84
85     FGControls();
86     ~FGControls();
87
88     // Implementation of FGSubsystem.
89     void init ();
90     void bind ();
91     void unbind ();
92     void update (double dt);
93
94     // Reset function
95     void reset_all(void);
96         
97     // Query functions
98     inline double get_aileron() const { return aileron; }
99     inline double get_aileron_trim() const { return aileron_trim; }
100     inline double get_elevator() const { return elevator; }
101     inline double get_elevator_trim() const { return elevator_trim; }
102     inline double get_rudder() const { return rudder; }
103     inline double get_rudder_trim() const { return rudder_trim; }
104     inline double get_flaps() const { return flaps; }
105     inline double get_throttle(int engine) const { return throttle[engine]; }
106     inline double get_mixture(int engine) const { return mixture[engine]; }
107     inline double get_prop_advance(int engine) const {
108         return prop_advance[engine];
109     }
110     inline double get_parking_brake() const { return parking_brake; }
111     inline double get_brake(int wheel) const { return brake[wheel]; }
112     inline int get_magnetos(int engine) const { return magnetos[engine]; }
113     inline bool get_starter(int engine) const { return starter[engine]; }
114     inline int get_fuel_selector() const { return fuel_selector; }
115     inline bool get_gear_down() const { return gear_down; }
116
117     // Update functions
118     void set_aileron( double pos );
119     void move_aileron( double amt );
120     void set_aileron_trim( double pos );
121     void move_aileron_trim( double amt );
122     void set_elevator( double pos );
123     void move_elevator( double amt );
124     void set_elevator_trim( double pos );
125     void move_elevator_trim( double amt );
126     void set_rudder( double pos );
127     void move_rudder( double amt );
128     void set_rudder_trim( double pos );
129     void move_rudder_trim( double amt );
130     void set_flaps( double pos );
131     void move_flaps( double amt );
132     void set_throttle( int engine, double pos );
133     void move_throttle( int engine, double amt );
134     void set_mixture( int engine, double pos );
135     void move_mixture( int engine, double amt );
136     void set_prop_advance( int engine, double pos );
137     void move_prop_advance( int engine, double amt );
138     void set_magnetos( int engine, int pos );
139     void move_magnetos( int engine, int amt );
140     void set_starter( int engine, bool flag );
141     void set_fuel_selector( int pos ) { fuel_selector = pos; }
142     void set_parking_brake( double pos );
143     void set_brake( int wheel, double pos );
144     void move_brake( int wheel, double amt );
145     void set_gear_down( bool gear );
146 };
147
148
149 #endif // _CONTROLS_HXX
150
151