glutKeyboardUpFunc(GLUTkeyup);
glutSpecialFunc(GLUTspecialkey);
glutSpecialUpFunc(GLUTspecialkeyup);
-#ifndef FG_OLD_MOUSE
glutMouseFunc (GLUTmouse);
glutMotionFunc (GLUTmotion);
glutPassiveMotionFunc (GLUTmotion);
-#endif
}
void
}
void
-FGInput::update (int dt)
+FGInput::update (double dt)
{
_update_keyboard();
_update_joystick();
// so we can play with it.
if (x != m.x) {
int delta = x - m.x;
- for (int i = 0; i < mode.x_bindings[modifiers].size(); i++)
+ for (unsigned int i = 0; i < mode.x_bindings[modifiers].size(); i++)
mode.x_bindings[modifiers][i]->fire(double(delta), double(xsize));
}
if (y != m.y) {
int delta = y - m.y;
- for (int i = 0; i < mode.y_bindings[modifiers].size(); i++)
+ for (unsigned int i = 0; i < mode.y_bindings[modifiers].size(); i++)
mode.y_bindings[modifiers][i]->fire(double(delta), double(ysize));
}
key_nodes = fgGetNode("/input/keyboard", true);
}
- vector<SGPropertyNode *> keys = key_nodes->getChildren("key");
+ 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);
}
for (int i = 0; i < MAX_JOYSTICKS; i++) {
- SGPropertyNode * js_node = js_nodes->getChild("js", i);
+ SGPropertyNode_ptr js_node = js_nodes->getChild("js", i);
if (js_node == 0) {
SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for joystick " << i);
js_node = js_nodes->getChild("js", i, true);
continue;
} else {
#ifdef FG_PLIB_JOYSTICK_GETNAME
- SG_LOG(SG_INPUT, SG_INFO, "");
- SG_LOG(SG_INPUT, SG_INFO, "Found joystick " << js->getName());
+ bool found_js = false;
+ const char * name = js->getName();
+ SG_LOG(SG_INPUT, SG_INFO, "Looking for bindings for joystick \""
+ << name << '"');
+ vector<SGPropertyNode_ptr> nodes = js_nodes->getChildren("js-named");
+ for (unsigned int i = 0; i < nodes.size(); i++) {
+ SGPropertyNode_ptr node = nodes[i];
+ vector<SGPropertyNode_ptr> name_nodes = node->getChildren("name");
+ for (unsigned int j = 0; j < name_nodes.size(); j++) {
+ const char * js_name = name_nodes[j]->getStringValue();
+ SG_LOG(SG_INPUT, SG_INFO, " Trying \"" << js_name << '"');
+ if (!strcmp(js_name, name)) {
+ SG_LOG(SG_INPUT, SG_INFO, " Found bindings");
+ js_node = node;
+ found_js = true;
+ break;
+ }
+ }
+ if (found_js)
+ break;
+ }
#endif
}
#ifdef WIN32
int modifiers)
{
SG_LOG(SG_INPUT, SG_DEBUG, "Reading all bindings");
- vector<const SGPropertyNode *> bindings = node->getChildren("binding");
+ vector<SGPropertyNode_ptr> bindings = node->getChildren("binding");
for (unsigned int i = 0; i < bindings.size(); i++) {
SG_LOG(SG_INPUT, SG_DEBUG, "Reading binding "
<< bindings[i]->getStringValue("command"));
////////////////////////////////////////////////////////////////////////
FGInput::mouse::mouse ()
- : nModes(1),
- current_mode(0),
- x(-1),
+ : x(-1),
y(-1),
+ nModes(1),
+ current_mode(0),
modes(0)
{
}