FGInput::~FGInput ()
{
- // TODO: delete all FGBinding objects explicitly
+ // no op
}
void
}
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGInput::button.
+////////////////////////////////////////////////////////////////////////
+
+FGInput::button::button ()
+ : is_repeatable(false),
+ last_state(-1)
+{
+}
+
+FGInput::button::~button ()
+{
+ // FIXME: memory leak
+// for (int i = 0; i < FG_MOD_MAX; i++)
+// for (int j = 0; i < bindings[i].size(); j++)
+// delete bindings[i][j];
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGInput::axis.
+////////////////////////////////////////////////////////////////////////
+
+FGInput::axis::axis ()
+ : last_value(9999999),
+ tolerance(0.002),
+ low_threshold(-0.9),
+ high_threshold(0.9)
+{
+}
+
+FGInput::axis::~axis ()
+{
+ for (int i = 0; i < FG_MOD_MAX; i++)
+ for (unsigned int j = 0; i < bindings[i].size(); j++)
+ delete bindings[i][j];
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGInput::joystick.
+////////////////////////////////////////////////////////////////////////
+
+FGInput::joystick::joystick ()
+{
+}
+
+FGInput::joystick::~joystick ()
+{
+ delete js;
+ delete[] axes;
+ delete[] buttons;
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of GLUT callbacks.
+////////////////////////////////////////////////////////////////////////
+
+
/**
* Construct the modifiers.
*/
SG_USING_STD(map);
SG_USING_STD(vector);
+
+\f
+////////////////////////////////////////////////////////////////////////
+// General binding support.
+////////////////////////////////////////////////////////////////////////
+
+
/**
* An input binding of some sort.
*
};
+\f
+////////////////////////////////////////////////////////////////////////
+// General input mapping support.
+////////////////////////////////////////////////////////////////////////
+
+
/**
* Generic input module.
*
FG_MOD_MAX = 16 // enough to handle all combinations
};
- FGInput();
+
+ /**
+ * Default constructor.
+ */
+ FGInput ();
+
+
+ /**
+ * Destructor.
+ */
virtual ~FGInput();
//
private:
-
// Constants
enum
{
* Settings for a key or button.
*/
struct button {
- button ()
- : is_repeatable(false),
- last_state(-1)
- {}
- virtual ~button () {
- for (int i = 0; i < FG_MOD_MAX; i++)
- for (int j = 0; i < bindings[i].size(); j++)
- delete bindings[i][j];
- }
+ button ();
+ virtual ~button ();
bool is_repeatable;
int last_state;
binding_list_t bindings[FG_MOD_MAX];
* Settings for a single joystick axis.
*/
struct axis {
- axis ()
- : last_value(9999999),
- tolerance(0.002),
- low_threshold(-0.9),
- high_threshold(0.9)
- {}
- virtual ~axis () {
- for (int i = 0; i < FG_MOD_MAX; i++)
- for (int j = 0; i < bindings[i].size(); j++)
- delete bindings[i][j];
- }
+ axis ();
+ virtual ~axis ();
float last_value;
float tolerance;
binding_list_t bindings[FG_MOD_MAX];
* 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;
};
};
+
+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