]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/input.hxx
Fix for a premature deletion bug. The _arg SGPropertyNode* is passed
[flightgear.git] / src / Input / input.hxx
index 4b9144f0860e756192bfd9bf1a1e82c8a13c4f3f..9e043a7bba9fb4ad145af092539deed87ee9729e 100644 (file)
 
 #include <simgear/compiler.h>
 
-#include <simgear/misc/commands.hxx>
-#include <simgear/misc/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/structure/commands.hxx>
+#include <simgear/props/condition.hxx>
+#include <simgear/props/props.hxx>
 
-#include <Main/fgfs.hxx>
+#include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 
 #include <map>
@@ -45,6 +47,8 @@ SG_USING_STD(map);
 SG_USING_STD(vector);
 
 
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // General binding support.
@@ -58,7 +62,7 @@ SG_USING_STD(vector);
  * keyboard key, a joystick button or axis, or even a panel
  * instrument.</p>
  */
-class FGBinding : public FGConditional
+class FGBinding : public SGConditional
 {
 public:
 
@@ -79,7 +83,7 @@ public:
   /**
    * Destructor.
    */
-  virtual ~FGBinding ();
+  virtual ~FGBinding () {}
 
 
   /**
@@ -139,11 +143,13 @@ public:
 
 
 private:
+                                // just to be safe.
+  FGBinding (const FGBinding &binding);
+
   string _command_name;
-  SGCommandMgr::command_t _command;
-  mutable SGPropertyNode * _arg;
-  mutable SGPropertyNode * _setting;
-  mutable SGCommandState * _command_state;
+  mutable SGCommandMgr::command_t _command;
+  mutable SGPropertyNode_ptr _arg;
+  mutable SGPropertyNode_ptr _setting;
 };
 
 
@@ -160,7 +166,7 @@ private:
  * keyboard, joystick, mouse, or even panel switches -- in a consistent
  * way, and to allow users to rebind any of the actions at runtime.</p>
  */
-class FGInput : public FGSubsystem
+class FGInput : public SGSubsystem
 {
 public:
 
@@ -186,12 +192,25 @@ public:
   virtual ~FGInput();
 
   //
-  // Implementation of FGSubsystem.
+  // Implementation of SGSubsystem.
   //
   virtual void init ();
-  virtual void bind ();
-  virtual void unbind ();
-  virtual void update (int dt);
+  virtual void update (double dt);
+  virtual void suspend ();
+  virtual void resume ();
+  virtual bool is_suspended () const;
+
+
+  /**
+   * Control whether this is the default module to receive events.
+   *
+   * The first input module created will set itself as the default
+   * automatically.
+   *
+   * @param status true if this should be the default module for
+   * events, false otherwise.
+   */
+  virtual void makeDefault (bool status = true);
 
 
   /**
@@ -248,6 +267,8 @@ private:
     MAX_MICE = 1,
     MAX_MOUSE_BUTTONS = 8
   };
+  struct mouse;
+  friend struct mouse;
 
   typedef vector<FGBinding *> binding_list_t;
 
@@ -258,6 +279,8 @@ private:
     button ();
     virtual ~button ();
     bool is_repeatable;
+    float interval_sec;
+    float last_dt;
     int last_state;
     binding_list_t bindings[FG_MOD_MAX];
   };
@@ -276,6 +299,8 @@ private:
     float high_threshold;
     struct button low;
     struct button high;
+    float interval_sec;
+    double last_dt;
   };
 
 
@@ -360,7 +385,7 @@ private:
   /**
    * Update the joystick.
    */
-  void _update_joystick ();
+  void _update_joystick (double dt);
 
 
   /**
@@ -396,9 +421,6 @@ private:
 };
 
 
-extern FGInput current_input;
-
-
 \f
 ////////////////////////////////////////////////////////////////////////
 // GLUT callbacks.