]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/input.cxx
adapt to changes in sg_exception interface
[flightgear.git] / src / Input / input.cxx
index 3ecf5142f8c796faf6064a88076a1eb48cd41d60..d281c3593985dd1f0cf895863ae2ad8120533cb8 100644 (file)
 #  include <config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
 #include <simgear/compiler.h>
 
 #include <math.h>
 #include <ctype.h>
 #include <sstream>
 
-#include STL_FSTREAM
-#include STL_STRING
+#include <fstream>
+#include <string>
 #include <vector>
 
 #include <simgear/compiler.h>
 #include <Scenery/scenery.hxx>
 #include <Main/renderer.hxx>
 
-SG_USING_STD(ifstream);
-SG_USING_STD(ostringstream);
-SG_USING_STD(string);
-SG_USING_STD(vector);
+using std::ifstream;
+using std::ostringstream;
+using std::string;
+using std::vector;
 
 void mouseClickHandler(int button, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter*);
 void mouseMotionHandler(int x, int y);
@@ -327,8 +323,6 @@ FGInput::doMouseClick (int b, int updown, int x, int y, bool mainWindow, const o
   }
 
   if (mode.pass_through) {
-    // The pu stuff seems to need that. May be it does opengl picking ...
-    fgMakeCurrent();
     if (0 <= x && 0 <= y && puMouse(b, updown, x, y))
       return;
     else if (0 <= x && 0 <= y && (globals->get_current_panel() != 0) &&
@@ -348,7 +342,7 @@ FGInput::doMouseClick (int b, int updown, int x, int y, bool mainWindow, const o
         // The nearest one is the first one and the deepest
         // (the most specialized one in the scenegraph) is the first.
         std::vector<SGSceneryPick> pickList;
-        if (FGRenderer::pick(x, y, pickList, ea)) {
+        if (FGRenderer::pick(pickList, ea)) {
           std::vector<SGSceneryPick>::const_iterator i;
           for (i = pickList.begin(); i != pickList.end(); ++i) {
             if (i->callback->buttonPressed(b, i->info)) {
@@ -518,8 +512,8 @@ FGInput::_init_joystick ()
             << "\"\nUsing default: \"" << source << '"');
 
       } else {
-        throw sg_throwable(string("No joystick configuration file with "
-            "<name>default</name> entry found!"));
+        throw sg_exception(string("No joystick configuration file with <name>")
+                           + name + "</name> entry found!");
       }
 
       js_node = js_nodes->getChild("js", i, true);
@@ -827,15 +821,11 @@ FGInput::_update_keyboard ()
 void
 FGInput::_update_joystick (double dt)
 {
-  int modifiers = KEYMOD_NONE;  // FIXME: any way to get the real ones?
-  int buttons;
-  // float js_val, diff;
   float axis_values[MAX_JOYSTICK_AXES];
+  int modifiers = fgGetKeyModifiers();
+  int buttons;
 
-  int i;
-  int j;
-
-  for ( i = 0; i < MAX_JOYSTICKS; i++) {
+  for (int i = 0; i < MAX_JOYSTICKS; i++) {
 
     jsJoystick * js = _joystick_bindings[i].js;
     if (js == 0 || js->notWorking())
@@ -844,21 +834,18 @@ FGInput::_update_joystick (double dt)
     js->read(&buttons, axis_values);
 
                                 // Fire bindings for the axes.
-    for ( j = 0; j < _joystick_bindings[i].naxes; j++) {
+    for (int j = 0; j < _joystick_bindings[i].naxes; j++) {
       axis &a = _joystick_bindings[i].axes[j];
-      
+
                                 // Do nothing if the axis position
                                 // is unchanged; only a change in
                                 // position fires the bindings.
       if (fabs(axis_values[j] - a.last_value) > a.tolerance) {
-//      SG_LOG(SG_INPUT, SG_DEBUG, "Axis " << j << " has moved");
         a.last_value = axis_values[j];
-//      SG_LOG(SG_INPUT, SG_DEBUG, "There are "
-//             << a.bindings[modifiers].size() << " bindings");
-        for (unsigned int k = 0; k < a.bindings[modifiers].size(); k++)
-          a.bindings[modifiers][k]->fire(axis_values[j]);
+        for (unsigned int k = 0; k < a.bindings[KEYMOD_NONE].size(); k++)
+          a.bindings[KEYMOD_NONE][k]->fire(axis_values[j]);
       }
-     
+
                                 // do we have to emulate axis buttons?
       a.last_dt += dt;
       if(a.last_dt >= a.interval_sec) {
@@ -867,7 +854,7 @@ FGInput::_update_joystick (double dt)
                          modifiers,
                          axis_values[j] < a.low_threshold,
                          -1, -1);
-      
+
         if (a.high.bindings[modifiers].size())
           _update_button(_joystick_bindings[i].axes[j].high,
                          modifiers,
@@ -878,7 +865,7 @@ FGInput::_update_joystick (double dt)
     }
 
                                 // Fire bindings for the buttons.
-    for (j = 0; j < _joystick_bindings[i].nbuttons; j++) {
+    for (int j = 0; j < _joystick_bindings[i].nbuttons; j++) {
       button &b = _joystick_bindings[i].buttons[j];
       b.last_dt += dt;
       if(b.last_dt >= b.interval_sec) {
@@ -914,7 +901,8 @@ FGInput::_update_mouse ( double dt )
   if ( fgGetBool( "/sim/mouse/hide-cursor", true ) ) {
       if ( m.x != m.save_x || m.y != m.save_y ) {
           m.timeout = fgGetDouble( "/sim/mouse/cursor-timeout-sec", 10.0 );
-          fgSetMouseCursor(m.modes[mode].cursor);
+          if (fgGetMouseCursor() == MOUSE_CURSOR_NONE)
+              fgSetMouseCursor(m.modes[mode].cursor);
       } else {
           m.timeout -= dt;
           if ( m.timeout <= 0.0 ) {