1
0
Fork 0

move the other parts of _init_keyboard() to _postinit_keyboard(), too.

This is still before anything else than the splash screen is displayed,
and it's cleaner that way. (The Nasal processing parts *must* be there.)
This commit is contained in:
mfranz 2007-07-13 10:15:48 +00:00
parent 5246e69b5a
commit cbcc7af5d0
2 changed files with 22 additions and 33 deletions

View file

@ -123,7 +123,6 @@ FGInput::~FGInput ()
void
FGInput::init ()
{
_init_keyboard();
_init_joystick();
_init_mouse();
@ -142,6 +141,7 @@ void
FGInput::postinit ()
{
_postinit_joystick();
_postinit_keyboard();
}
void
@ -383,29 +383,6 @@ FGInput::doMouseMotion (int x, int y)
fgSetInt("/devices/status/mice/mouse/y", m.y = y);
}
void
FGInput::_init_keyboard ()
{
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing key bindings");
_module = "__kbd";
SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
if (key_nodes == 0) {
SG_LOG(SG_INPUT, SG_WARN, "No key bindings (/input/keyboard)!!");
key_nodes = fgGetNode("/input/keyboard", true);
}
vector<SGPropertyNode_ptr> keys = key_nodes->getChildren("key");
for (unsigned int i = 0; i < keys.size(); i++) {
int index = keys[i]->getIndex();
SG_LOG(SG_INPUT, SG_DEBUG, "Binding key " << index);
_key_bindings[index].bindings->clear();
_key_bindings[index].is_repeatable = keys[i]->getBoolValue("repeatable");
_key_bindings[index].last_state = 0;
_read_bindings(keys[i], _key_bindings[index].bindings, KEYMOD_NONE);
}
}
void
FGInput::_scan_joystick_dir(SGPath *path, SGPropertyNode* node, int *index)
@ -506,13 +483,31 @@ FGInput::_init_joystick ()
void
FGInput::_postinit_keyboard()
{
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing key bindings");
_module = "__kbd";
SGPropertyNode * key_nodes = fgGetNode("/input/keyboard");
if (key_nodes == 0) {
SG_LOG(SG_INPUT, SG_WARN, "No key bindings (/input/keyboard)!!");
key_nodes = fgGetNode("/input/keyboard", true);
}
FGNasalSys *nasalsys = (FGNasalSys *)globals->get_subsystem("nasal");
SGPropertyNode *key_nodes = fgGetNode("/input/keyboard", true);
vector<SGPropertyNode_ptr> nasal = key_nodes->getChildren("nasal");
for (unsigned int j = 0; j < nasal.size(); j++) {
nasal[j]->setStringValue("module", _module.c_str());
nasalsys->handleCommand(nasal[j]);
}
vector<SGPropertyNode_ptr> keys = key_nodes->getChildren("key");
for (unsigned int i = 0; i < keys.size(); i++) {
int index = keys[i]->getIndex();
SG_LOG(SG_INPUT, SG_DEBUG, "Binding key " << index);
_key_bindings[index].bindings->clear();
_key_bindings[index].is_repeatable = keys[i]->getBoolValue("repeatable");
_key_bindings[index].last_state = 0;
_read_bindings(keys[i], _key_bindings[index].bindings, KEYMOD_NONE);
}
}

View file

@ -244,12 +244,6 @@ private:
};
/**
* Initialize key bindings.
*/
void _init_keyboard ();
/**
* Initialize joystick bindings.
*/
@ -277,8 +271,8 @@ private:
const string name);
/**
* Initialize nasal parts that had to wait for the nasal to get
* functional.
* Initialize key bindings, as well as those joystick parts that
* depend on a working Nasal subsystem.
*/
void _postinit_keyboard ();
void _postinit_joystick ();