]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/ControlMap.hpp
Automatically generate "contact" points for collision detection. Implemented
[flightgear.git] / src / FDM / YASim / ControlMap.hpp
1 #ifndef _CONTROL_MAP_HPP
2 #define _CONTROL_MAP_HPP
3
4 #include "Vector.hpp"
5
6 namespace yasim {
7
8 class ControlMap {
9 public:
10     ~ControlMap();
11
12     enum OutputType { THROTTLE, MIXTURE, STARTER, MAGNETOS,
13                       ADVANCE, REHEAT, PROP,
14                       BRAKE, STEER, EXTEND,
15                       INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR,
16                       BOOST };
17
18     enum { OPT_SPLIT  = 0x01,
19            OPT_INVERT = 0x02,
20            OPT_SQUARE = 0x04 };
21
22     // Returns a new, not-yet-used "input handle" for addMapping and
23     // setInput.  This typically corresponds to one user axis.
24     int newInput();
25
26     // Adds a mapping to between input handle and a particular setting
27     // on an output object.  The value of output MUST match the type
28     // of object!
29     void addMapping(int input, int output, void* object, int options=0);
30
31     // An additional form to specify a mapping range.  Input values
32     // outside of [src0:src1] are clamped, and are then mapped to
33     // [dst0:dst1] before being set on the object.
34     void addMapping(int input, int output, void* object, int options,
35                     float src0, float src1, float dst0, float dst1);
36
37     // Resets our accumulated input values.  Call before any
38     // setInput() invokations.
39     void reset();
40
41     // Sets the specified input (as returned by newInput) to the
42     // specified value.
43     void setInput(int input, float value);
44
45     // Calculates and applies the settings received since the last reset().
46     void applyControls();
47
48 private:
49     struct OutRec { int type; void* object; Vector maps; };
50     struct MapRec  { OutRec* out; int idx; int opt; float val;
51                      float src0; float src1; float dst0; float dst1; };
52
53     // A list of (sub)Vectors containing a bunch of MapRec objects for
54     // each input handle.
55     Vector _inputs;
56
57     // An unordered list of output settings.
58     Vector _outputs;
59 };
60
61 }; // namespace yasim
62 #endif // _CONTROL_MAP_HPP