From cbcc7af5d0efb8a5d18d527bf10b0085acb253c6 Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 13 Jul 2007 10:15:48 +0000 Subject: [PATCH] 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.) --- src/Input/input.cxx | 45 ++++++++++++++++++++------------------------- src/Input/input.hxx | 10 ++-------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 2dd6f1c48..ca38a2d37 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -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 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 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 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); + } } diff --git a/src/Input/input.hxx b/src/Input/input.hxx index 83527590b..a9dd5303f 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -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 (); -- 2.39.5