]> git.mxchange.org Git - flightgear.git/blob - src/Controls/controls.hxx
Added support for additional animated, dynamic 3D models configured in
[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     {
46         ALL_ENGINES = -1,
47         MAX_ENGINES = 10
48     };
49
50     enum
51     {
52         ALL_WHEELS = -1,
53         MAX_WHEELS = 3
54     };
55
56 private:
57
58     double aileron;
59     double aileron_trim;
60     double elevator;
61     double elevator_trim;
62     double rudder;
63     double rudder_trim;
64     double flaps;
65     double throttle[MAX_ENGINES];
66     double mixture[MAX_ENGINES];
67     double prop_advance[MAX_ENGINES];
68     double parking_brake;
69     double brake[MAX_WHEELS];
70     int magnetos[MAX_ENGINES];
71     bool throttle_idle;
72     bool starter[MAX_ENGINES];
73     bool gear_down;
74
75     SGPropertyNode * auto_coordination;
76
77 public:
78
79     FGControls();
80     ~FGControls();
81
82     // Implementation of FGSubsystem.
83     void init ();
84     void bind ();
85     void unbind ();
86     void update (int dt);
87
88     // Reset function
89     void reset_all(void);
90         
91     // Query functions
92     inline double get_aileron() const { return aileron; }
93     inline double get_aileron_trim() const { return aileron_trim; }
94     inline double get_elevator() const { return elevator; }
95     inline double get_elevator_trim() const { return elevator_trim; }
96     inline double get_rudder() const { return rudder; }
97     inline double get_rudder_trim() const { return rudder_trim; }
98     inline double get_flaps() const { return flaps; }
99     inline double get_throttle(int engine) const { return throttle[engine]; }
100     inline double get_mixture(int engine) const { return mixture[engine]; }
101     inline double get_prop_advance(int engine) const {
102         return prop_advance[engine];
103     }
104     inline double get_parking_brake() const { return parking_brake; }
105     inline double get_brake(int wheel) const { return brake[wheel]; }
106     inline int get_magnetos(int engine) const { return magnetos[engine]; }
107     inline bool get_starter(int engine) const { return starter[engine]; }
108     inline bool get_gear_down() const { return gear_down; }
109
110     // Update functions
111     void set_aileron( double pos );
112     void move_aileron( double amt );
113     void set_aileron_trim( double pos );
114     void move_aileron_trim( double amt );
115     void set_elevator( double pos );
116     void move_elevator( double amt );
117     void set_elevator_trim( double pos );
118     void move_elevator_trim( double amt );
119     void set_rudder( double pos );
120     void move_rudder( double amt );
121     void set_rudder_trim( double pos );
122     void move_rudder_trim( double amt );
123     void set_flaps( double pos );
124     void move_flaps( double amt );
125     void set_throttle( int engine, double pos );
126     void move_throttle( int engine, double amt );
127     void set_mixture( int engine, double pos );
128     void move_mixture( int engine, double amt );
129     void set_prop_advance( int engine, double pos );
130     void move_prop_advance( int engine, double amt );
131     void set_magnetos( int engine, int pos );
132     void move_magnetos( int engine, int amt );
133     void set_starter( int engine, bool flag );
134     void set_parking_brake( double pos );
135     void set_brake( int wheel, double pos );
136     void move_brake( int wheel, double amt );
137     void set_gear_down( bool gear );
138 };
139
140
141 #endif // _CONTROLS_HXX
142
143