#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>
SG_USING_STD(vector);
+
+
\f
////////////////////////////////////////////////////////////////////////
// General binding support.
* keyboard key, a joystick button or axis, or even a panel
* instrument.</p>
*/
-class FGBinding : public FGConditional
+class FGBinding : public SGConditional
{
public:
/**
- * Fire a binding with x and y positions.
+ * Fire a binding with a scaled movement (rather than absolute position).
*/
- virtual void fire (int x, int y) const;
+ virtual void fire (double offset, double max) const;
/**
private:
+ // just to be safe.
+ FGBinding (const FGBinding &binding);
+
string _command_name;
- SGCommandMgr::command_t _command;
+ mutable SGCommandMgr::command_t _command;
mutable SGPropertyNode * _arg;
- mutable SGPropertyNode * _setting;
- mutable SGCommandState * _command_state;
+ mutable SGPropertyNode_ptr _setting;
};
* 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:
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);
/**
MAX_JOYSTICK_BUTTONS = 32,
MAX_MICE = 1,
- MAX_MOUSE_BUTTONS
+ MAX_MOUSE_BUTTONS = 8
};
-
+ struct mouse;
+ friend struct mouse;
typedef vector<FGBinding *> binding_list_t;
button ();
virtual ~button ();
bool is_repeatable;
+ float interval_sec;
+ float last_dt;
int last_state;
binding_list_t bindings[FG_MOD_MAX];
};
float high_threshold;
struct button low;
struct button high;
+ float interval_sec;
+ double last_dt;
};
};
+ /**
+ * Settings for a mouse mode.
+ */
+ struct mouse_mode {
+ mouse_mode ();
+ virtual ~mouse_mode ();
+ int cursor;
+ bool constrained;
+ bool pass_through;
+ button * buttons;
+ binding_list_t x_bindings[FG_MOD_MAX];
+ binding_list_t y_bindings[FG_MOD_MAX];
+ };
+
+
/**
* Settings for a mouse.
*/
struct mouse {
mouse ();
virtual ~mouse ();
- button * buttons;
+ int x;
+ int y;
+ SGPropertyNode * mode_node;
+ SGPropertyNode * mouse_button_nodes[MAX_MOUSE_BUTTONS];
+ int nModes;
+ int current_mode;
+ mouse_mode * modes;
};
/**
* Update the joystick.
*/
- void _update_joystick ();
+ void _update_joystick (double dt);
/**
joystick _joystick_bindings[MAX_JOYSTICKS];
mouse _mouse_bindings[MAX_MICE];
- int _mouse_mode;
-
};
-extern FGInput current_input;
-
-
\f
////////////////////////////////////////////////////////////////////////
// GLUT callbacks.