]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/ControlMap.hpp
Initial revision of Andy Ross's YASim code. This is (Y)et (A)nother Flight
[flightgear.git] / src / FDM / YASim / ControlMap.hpp
1 #ifndef _CONTROL_MAP_HPP
2 #define _CONTROL_MAP_HPP
3
4 #include "util/Vector.hpp"
5
6 namespace yasim {
7
8 class ControlMap {
9 public:
10     ~ControlMap();
11
12     enum OutputType { THROTTLE, MIXTURE, REHEAT, PROP,
13                       BRAKE, STEER, EXTEND,
14                       INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER };
15
16     static const int OPT_SPLIT  = 0x01;
17     static const int OPT_INVERT = 0x02;
18     static const int OPT_SQUARE = 0x04;
19
20     // Returns a new, not-yet-used "input handle" for addMapping and
21     // setInput.  This typically corresponds to one user axis.
22     int newInput();
23
24     // Adds a mapping to between input handle and a particular setting
25     // on an output object.  The value of output MUST match the type
26     // of object!
27     void addMapping(int input, int output, void* object, int options=0);
28
29     // Resets our accumulated input values.  Call before any
30     // setInput() invokations.
31     void reset();
32
33     // Sets the specified input (as returned by newInput) to the
34     // specified value.
35     void setInput(int input, float value);
36
37     // Calculates and applies the settings received since the last reset().
38     void applyControls();
39
40 private:
41     struct OutRec { int type; void* object; int n;
42                     float* values; Vector options; };
43     struct MapRec  { OutRec* out; int idx; };
44
45     // A list of (sub)Vectors containing a bunch of MapRec objects for
46     // each input handle.
47     Vector _inputs;
48
49     // An unordered list of output settings.
50     Vector _outputs;
51 };
52
53 }; // namespace yasim
54 #endif // _CONTROL_MAP_HPP