Eliminated current_input and added FGInput to the subsystems managed
by FGSubsystemMgr.
This commit is contained in:
parent
598db3d528
commit
29eb5f7f5d
4 changed files with 254 additions and 233 deletions
|
@ -69,9 +69,12 @@ SG_USING_STD(vector);
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Local data structures.
|
||||
// Local variables.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static FGInput * default_input = 0;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of FGBinding.
|
||||
|
@ -173,17 +176,17 @@ FGBinding::fire (double setting) const
|
|||
// From main.cxx
|
||||
extern void fgReshape( int width, int height );
|
||||
|
||||
FGInput current_input;
|
||||
|
||||
|
||||
FGInput::FGInput ()
|
||||
{
|
||||
// no op
|
||||
if (default_input == 0)
|
||||
default_input = this;
|
||||
}
|
||||
|
||||
FGInput::~FGInput ()
|
||||
{
|
||||
// no op
|
||||
if (default_input == this)
|
||||
default_input = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -222,6 +225,15 @@ FGInput::update (double dt)
|
|||
_update_mouse();
|
||||
}
|
||||
|
||||
void
|
||||
FGInput::makeDefault (bool status)
|
||||
{
|
||||
if (status)
|
||||
default_input = this;
|
||||
else if (default_input == this)
|
||||
default_input = 0;
|
||||
}
|
||||
|
||||
void
|
||||
FGInput::doKey (int k, int modifiers, int x, int y)
|
||||
{
|
||||
|
@ -1024,40 +1036,48 @@ void
|
|||
GLUTkey(unsigned char k, int x, int y)
|
||||
{
|
||||
// Give PUI a chance to grab it first.
|
||||
if (!puKeyboard(k, PU_DOWN))
|
||||
current_input.doKey(k, get_mods(), x, y);
|
||||
if (!puKeyboard(k, PU_DOWN)) {
|
||||
if (default_input != 0)
|
||||
default_input->doKey(k, get_mods(), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GLUTkeyup(unsigned char k, int x, int y)
|
||||
{
|
||||
current_input.doKey(k, get_mods()|FGInput::FG_MOD_UP, x, y);
|
||||
if (default_input != 0)
|
||||
default_input->doKey(k, get_mods()|FGInput::FG_MOD_UP, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
GLUTspecialkey(int k, int x, int y)
|
||||
{
|
||||
// Give PUI a chance to grab it first.
|
||||
if (!puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN))
|
||||
current_input.doKey(k + 256, get_mods(), x, y);
|
||||
if (!puKeyboard(k + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN)) {
|
||||
if (default_input != 0)
|
||||
default_input->doKey(k + 256, get_mods(), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GLUTspecialkeyup(int k, int x, int y)
|
||||
{
|
||||
current_input.doKey(k + 256, get_mods()|FGInput::FG_MOD_UP, x, y);
|
||||
if (default_input != 0)
|
||||
default_input->doKey(k + 256, get_mods()|FGInput::FG_MOD_UP, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
GLUTmouse (int button, int updown, int x, int y)
|
||||
{
|
||||
current_input.doMouseClick(button, updown, x, y);
|
||||
if (default_input != 0)
|
||||
default_input->doMouseClick(button, updown, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
GLUTmotion (int x, int y)
|
||||
{
|
||||
current_input.doMouseMotion(x, y);
|
||||
if (default_input != 0)
|
||||
default_input->doMouseMotion(x, y);
|
||||
}
|
||||
|
||||
// end of input.cxx
|
||||
|
|
|
@ -194,6 +194,18 @@ public:
|
|||
virtual void update (double dt);
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* Handle a single keystroke.
|
||||
*
|
||||
|
@ -398,9 +410,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
extern FGInput current_input;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GLUT callbacks.
|
||||
|
|
|
@ -1121,8 +1121,9 @@ bool fgInitSubsystems( void ) {
|
|||
// Initialize the input subsystem.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
current_input.init();
|
||||
current_input.bind();
|
||||
globals->get_subsystem_mgr()->add(FGSubsystemMgr::GENERAL,
|
||||
"input",
|
||||
new FGInput);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -126,8 +126,6 @@ SG_USING_STD(endl);
|
|||
#include <Time/sunpos.hxx>
|
||||
#include <Time/tmp.hxx>
|
||||
|
||||
#include <Input/input.hxx>
|
||||
|
||||
// ADA
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
#include <simgear/math/point3d.hxx>
|
||||
|
@ -796,9 +794,6 @@ void fgRenderFrame() {
|
|||
// glDisable( GL_CULL_FACE );
|
||||
// glDisable( GL_TEXTURE_2D );
|
||||
|
||||
// update the input subsystem
|
||||
current_input.update(delta_time_sec);
|
||||
|
||||
// update the controls subsystem
|
||||
globals->get_controls()->update(delta_time_sec);
|
||||
|
||||
|
@ -823,7 +818,6 @@ void fgRenderFrame() {
|
|||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_FOG );
|
||||
|
||||
// globals->get_logger()->update(delta_time_sec);
|
||||
}
|
||||
|
||||
glutSwapBuffers();
|
||||
|
@ -1138,13 +1132,10 @@ static void fgMainLoop( void ) {
|
|||
#ifdef ENABLE_AUDIO_SUPPORT
|
||||
if ( fgGetBool("/sim/sound/audible")
|
||||
&& globals->get_soundmgr()->is_working() ) {
|
||||
// globals->get_fx()->update( delta_time_sec );
|
||||
globals->get_soundmgr()->update( delta_time_sec );
|
||||
}
|
||||
#endif
|
||||
|
||||
// globals->get_systemmgr()->update( delta_time_sec );
|
||||
// globals->get_instrumentmgr()->update( delta_time_sec );
|
||||
globals->get_subsystem_mgr()->update(delta_time_sec);
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue