numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9';
numlockKeyMap[GUIEventAdapter::KEY_KP_Delete] = '.';
+ // The comment above is incorrect on Mac osgViewer, at least. So we
+ // need to map the 'num-locked' key codes to real values.
+ numlockKeyMap[GUIEventAdapter::KEY_KP_0] = '0';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_1] = '1';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_2] = '2';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_3] = '3';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_4] = '4';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_5] = '5';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_6] = '6';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_7] = '7';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_8] = '8';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_9] = '9';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Decimal] = '.';
+
+
// mapping when NumLock is off
noNumlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = PU_KEY_INSERT;
noNumlockKeyMap[GUIEventAdapter::KEY_KP_End] = PU_KEY_END;
_print = fgGetNode("/sim/rendering/print-statistics", true);
}
+void FGEventHandler::reset()
+{
+ _display = fgGetNode("/sim/rendering/on-screen-statistics", true);
+ _print = fgGetNode("/sim/rendering/print-statistics", true);
+ statsHandler->reset();
+}
+
namespace
{
// Translate OSG modifier mask to FG modifier mask.
y = -1;
const osg::GraphicsContext* eventGC = ea.getGraphicsContext();
+ if( !eventGC )
+ return false; // TODO how can this happen?
const osg::GraphicsContext::Traits* traits = eventGC->getTraits();
osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
if (!guiCamera)
// Event handlers seem to be called even if the according event has already
// been handled. Already handled events shouldn't be handled multiple times
// so we need to exit here manually.
- if( ea.getHandled() )
+ if( ea.getHandled()
+ // Let mouse move events pass to correctly handle mouse cursor hide
+ // timeout while moving just on the canvas gui.
+ // TODO We should clean up the whole mouse input and make hide
+ // timeout independent of the event handler which consumed the
+ // event.
+ && ea.getEventType() != osgGA::GUIEventAdapter::MOVE
+ && ea.getEventType() != osgGA::GUIEventAdapter::DRAG )
return false;
int x = 0;
button = 4;
else
button = -1;
+
+#if defined(SG_MAC)
+ // bug https://code.google.com/p/flightgear-bugs/issues/detail?id=1286
+ // Mac (Cocoa) interprets shuft+wheel as horizontal scroll
+ if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT) {
+ if (ea.getScrollingDeltaX() > 0)
+ button = 3;
+ else if (ea.getScrollingDeltaX() < 0)
+ button = 4;
+ }
+#endif
+
} else if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP)
button = 3;
else
if (mouseWarped)
return true;
if (eventToViewport(ea, us, x, y) && mouseMotionHandler)
- (*mouseMotionHandler)(x, y);
+ (*mouseMotionHandler)(x, y, &ea);
return true;
case osgGA::GUIEventAdapter::RESIZE:
SG_LOG(SG_VIEW, SG_DEBUG, "FGEventHandler::handle: RESIZE event " << ea.getWindowHeight() << " x " << ea.getWindowWidth() << ", resizable: " << resizable);
y = (double)traits->height - y;
}
+#if 0
void eventToWindowCoordsYDown(const osgGA::GUIEventAdapter* ea,
double& x, double& y)
{
if (ea->getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS)
y = (double)traits->height - y;
}
+#endif
+
}