]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/input.hxx
Added a property output feature to ControlMap that allows arbitrary binding
[flightgear.git] / src / Input / input.hxx
index c046ba69d2e0bf284d46b63e1e4905441cfd7db2..a2899ab705549092dfd4e398f468b18ee6b16255 100644 (file)
 SG_USING_STD(map);
 SG_USING_STD(vector);
 
+
+\f
+////////////////////////////////////////////////////////////////////////
+// General binding support.
+////////////////////////////////////////////////////////////////////////
+
+
 /**
  * An input binding of some sort.
  *
@@ -51,7 +58,7 @@ SG_USING_STD(vector);
  * keyboard key, a joystick button or axis, or even a panel
  * instrument.</p>
  */
-class FGBinding
+class FGBinding : public FGConditional
 {
 public:
 
@@ -61,12 +68,6 @@ public:
   FGBinding ();
 
 
-  /**
-   * Copy constructor.
-   */
-  FGBinding (const FGBinding &binding);
-
-
   /**
    * Convenience constructor.
    *
@@ -140,6 +141,12 @@ private:
 };
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// General input mapping support.
+////////////////////////////////////////////////////////////////////////
+
+
 /**
  * Generic input module.
  *
@@ -160,7 +167,16 @@ public:
     FG_MOD_MAX = 16            // enough to handle all combinations
   };
 
-  FGInput();
+
+  /**
+   * Default constructor.
+   */
+  FGInput ();
+
+
+  /**
+   * Destructor.
+   */
   virtual ~FGInput();
 
   //
@@ -169,7 +185,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update ();
+  virtual void update (int dt);
 
 
   /**
@@ -190,7 +206,6 @@ public:
 
 
 private:
-
                                // Constants
   enum 
   {
@@ -206,16 +221,14 @@ private:
   };
 
 
-  typedef vector<FGBinding> binding_list_t;
+  typedef vector<FGBinding *> binding_list_t;
 
   /**
    * Settings for a key or button.
    */
   struct button {
-    button ()
-      : is_repeatable(false),
-       last_state(-1)
-    {}
+    button ();
+    virtual ~button ();
     bool is_repeatable;
     int last_state;
     binding_list_t bindings[FG_MOD_MAX];
@@ -226,12 +239,8 @@ private:
    * Settings for a single joystick axis.
    */
   struct axis {
-    axis ()
-      : last_value(9999999),
-       tolerance(0.002),
-       low_threshold(-0.9),
-       high_threshold(0.9)
-    {}
+    axis ();
+    virtual ~axis ();
     float last_value;
     float tolerance;
     binding_list_t bindings[FG_MOD_MAX];
@@ -246,14 +255,12 @@ private:
    * Settings for a joystick.
    */
   struct joystick {
-    virtual ~joystick () {
-      delete js;
-      delete[] axes;
-      delete[] buttons;
-    }
+    joystick ();
+    virtual ~joystick ();
+    int jsnum;
+    jsJoystick * js;
     int naxes;
     int nbuttons;
-    jsJoystick * js;
     axis * axes;
     button * buttons;
   };
@@ -307,19 +314,27 @@ private:
   /**
    * Look up the bindings for a key code.
    */
-  const vector<FGBinding> &_find_key_bindings (unsigned int k, int modifiers);
+  const vector<FGBinding *> &_find_key_bindings (unsigned int k,
+                                                int modifiers);
 
   button _key_bindings[MAX_KEYS];
   joystick _joystick_bindings[MAX_JOYSTICKS];
 
 };
 
+
+extern FGInput current_input;
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// GLUT callbacks.
+////////////////////////////////////////////////////////////////////////
+
 // Handle keyboard events
 void GLUTkey(unsigned char k, int x, int y);
 void GLUTkeyup(unsigned char k, int x, int y);
 void GLUTspecialkey(int k, int x, int y);
 void GLUTspecialkeyup(int k, int x, int y);
 
-extern FGInput current_input;
-
 #endif // _CONTROLS_HXX