]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/input.hxx
throw an exception if not even a default joystick could be found;
[flightgear.git] / src / Input / input.hxx
index 9e043a7bba9fb4ad145af092539deed87ee9729e..faad8acdc2462eef1cbeffd87325306118055b87 100644 (file)
 #endif
 
 #include <plib/js.h>
+#include <plib/ul.h>
 
 #include <simgear/compiler.h>
 
+#include <simgear/misc/sg_path.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/structure/commands.hxx>
 #include <simgear/props/condition.hxx>
 #include <simgear/props/props.hxx>
 
+#include <Main/fg_os.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 
@@ -47,6 +50,15 @@ SG_USING_STD(map);
 SG_USING_STD(vector);
 
 
+\f
+
+#if defined( UL_WIN32 )
+#define TGT_PLATFORM   "windows"
+#elif defined ( UL_MAC_OSX )
+#define TGT_PLATFORM    "mac"
+#else
+#define TGT_PLATFORM   "unix"
+#endif
 
 
 \f
@@ -169,23 +181,11 @@ private:
 class FGInput : public SGSubsystem
 {
 public:
-
-  enum {
-    FG_MOD_NONE = 0,
-    FG_MOD_UP = 1,             // key- or button-up
-    FG_MOD_SHIFT = 2,
-    FG_MOD_CTRL = 4,
-    FG_MOD_ALT = 8,
-    FG_MOD_MAX = 16            // enough to handle all combinations
-  };
-
-
   /**
    * Default constructor.
    */
   FGInput ();
 
-
   /**
    * Destructor.
    */
@@ -195,6 +195,8 @@ public:
   // Implementation of SGSubsystem.
   //
   virtual void init ();
+  virtual void reinit ();
+  virtual void postinit ();
   virtual void update (double dt);
   virtual void suspend ();
   virtual void resume ();
@@ -216,16 +218,10 @@ public:
   /**
    * Handle a single keystroke.
    *
-   * <p>Note: for special keys, the integer key code will be the Glut
-   * code + 256.</p>
-   *
-   * @param k The integer key code, as returned by glut.
+   * @param k The integer key code, see Main/fg_os.hxx
    * @param modifiers Modifier keys pressed (bitfield).
    * @param x The mouse x position at the time of keypress.
    * @param y The mouse y position at the time of keypress.
-   * @see #FG_MOD_SHIFT
-   * @see #FG_MOD_CTRL
-   * @see #FG_MOD_ALT
    */
   virtual void doKey (int k, int modifiers, int x, int y);
 
@@ -282,7 +278,7 @@ private:
     float interval_sec;
     float last_dt;
     int last_state;
-    binding_list_t bindings[FG_MOD_MAX];
+    binding_list_t bindings[KEYMOD_MAX];
   };
 
 
@@ -294,7 +290,7 @@ private:
     virtual ~axis ();
     float last_value;
     float tolerance;
-    binding_list_t bindings[FG_MOD_MAX];
+    binding_list_t bindings[KEYMOD_MAX];
     float low_threshold;
     float high_threshold;
     struct button low;
@@ -329,8 +325,8 @@ private:
     bool constrained;
     bool pass_through;
     button * buttons;
-    binding_list_t x_bindings[FG_MOD_MAX];
-    binding_list_t y_bindings[FG_MOD_MAX];
+    binding_list_t x_bindings[KEYMOD_MAX];
+    binding_list_t y_bindings[KEYMOD_MAX];
   };
 
 
@@ -346,6 +342,9 @@ private:
     SGPropertyNode * mouse_button_nodes[MAX_MOUSE_BUTTONS];
     int nModes;
     int current_mode;
+    double timeout;
+    int save_x;
+    int save_y;
     mouse_mode * modes;
   };
 
@@ -362,6 +361,13 @@ private:
   void _init_joystick ();
 
 
+  /**
+   * Scan directory recursively for "named joystick" configuration files,
+   * and read them into /input/joysticks/js-named[index]++.
+   */
+  void _scan_joystick_dir (SGPath *path, SGPropertyNode* node, int *index);
+
+
   /**
    * Initialize mouse bindings.
    */
@@ -375,6 +381,11 @@ private:
                            button &b,
                            const string name);
 
+  /**
+   * Initialize nasal parts that had to wait for the nasal to get
+   * functional.
+   */
+  void _postinit_joystick ();
 
   /**
    * Update the keyboard.
@@ -391,7 +402,7 @@ private:
   /**
    * Update the mouse.
    */
-  void _update_mouse ();
+  void _update_mouse (double dt);
 
 
   /**
@@ -420,83 +431,4 @@ private:
 
 };
 
-
-\f
-////////////////////////////////////////////////////////////////////////
-// GLUT callbacks.
-////////////////////////////////////////////////////////////////////////
-
-// Handle GLUT events.
-extern "C" {
-
-/**
- * Key-down event handler for Glut.
- *
- * <p>Pass the value on to the FGInput module unless PUI wants it.</p>
- *
- * @param k The integer value for the key pressed.
- * @param x (unused)
- * @param y (unused)
- */
-void GLUTkey (unsigned char k, int x, int y);
-
-
-/**
- * Key-up event handler for GLUT.
- *
- * <p>PUI doesn't use this, so always pass it to the input manager.</p>
- *
- * @param k The integer value for the key pressed.
- * @param x (unused)
- * @param y (unused)
- */
-void GLUTkeyup (unsigned char k, int x, int y);
-
-
-/**
- * Special key-down handler for Glut.
- *
- * <p>Pass the value on to the FGInput module unless PUI wants it.
- * The key value will have 256 added to it.</p>
- *
- * @param k The integer value for the key pressed (will have 256 added
- * to it).
- * @param x (unused)
- * @param y (unused)
- */
-void GLUTspecialkey (int k, int x, int y);
-
-
-/**
- * Special key-up handler for Glut.
- *
- * @param k The integer value for the key pressed (will have 256 added
- * to it).
- * @param x (unused)
- * @param y (unused)
- */
-void GLUTspecialkeyup (int k, int x, int y);
-
-
-/**
- * Mouse click handler for Glut.
- *
- * @param button The mouse button pressed.
- * @param updown Press or release flag.
- * @param x The x-location of the click.
- * @param y The y-location of the click.
- */
-void GLUTmouse (int button, int updown, int x, int y);
-
-
-/**
- * Mouse motion handler for Glut.
- *
- * @param x The new x-location of the mouse.
- * @param y The new y-location of the mouse.
- */
-void GLUTmotion (int x, int y);
-
-} // extern "C"
-
 #endif // _INPUT_HXX