From dd3fbd50d80cb99bf683cc5f74bbb212f8c15926 Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 25 Apr 2008 22:45:43 +0000 Subject: [PATCH] after OSG 2.4 upgrade, remove modifier workaround and comment out numpad workaround (we have yet to verify if the latter is really obsolete) --- src/Main/FGManipulator.cxx | 37 +++++++------------------------------ src/Main/FGManipulator.hxx | 11 ++--------- src/Main/fg_os.cxx | 1 - 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/Main/FGManipulator.cxx b/src/Main/FGManipulator.cxx index 226f3685e..a7b1c60bc 100644 --- a/src/Main/FGManipulator.cxx +++ b/src/Main/FGManipulator.cxx @@ -30,31 +30,16 @@ FGManipulator::FGManipulator() : statsEvent(new osgGA::GUIEventAdapter), statsType(osgViewer::StatsHandler::NO_STATS), currentModifiers(0), - osgModifiers(0), resizable(true), mouseWarped(false), - scrollButtonPressed(false), - useEventModifiers(false) + scrollButtonPressed(false) { using namespace osgGA; statsHandler->setKeyEventTogglesOnScreenStats(displayStatsKey); statsHandler->setKeyEventPrintsOutStats(printStatsKey); statsEvent->setEventType(GUIEventAdapter::KEYDOWN); - keyMaskMap[GUIEventAdapter::KEY_Shift_L] - = GUIEventAdapter::MODKEY_LEFT_SHIFT; - keyMaskMap[GUIEventAdapter::KEY_Shift_R] - = GUIEventAdapter::MODKEY_RIGHT_SHIFT; - keyMaskMap[GUIEventAdapter::KEY_Control_L] - = GUIEventAdapter::MODKEY_LEFT_CTRL; - keyMaskMap[GUIEventAdapter::KEY_Control_R] - = GUIEventAdapter::MODKEY_RIGHT_CTRL; - keyMaskMap[GUIEventAdapter::KEY_Alt_L] = GUIEventAdapter::MODKEY_LEFT_ALT; - keyMaskMap[GUIEventAdapter::KEY_Alt_R] = GUIEventAdapter::MODKEY_RIGHT_ALT; - keyMaskMap[GUIEventAdapter::KEY_Meta_L] = GUIEventAdapter::MODKEY_LEFT_META; - keyMaskMap[GUIEventAdapter::KEY_Meta_R] = GUIEventAdapter::MODKEY_RIGHT_META; - keyMaskMap[GUIEventAdapter::KEY_Super_L] = GUIEventAdapter::MODKEY_LEFT_META; - keyMaskMap[GUIEventAdapter::KEY_Super_R] = GUIEventAdapter::MODKEY_RIGHT_META; +#if 0 // We have to implement numlock too. numlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = '0'; numlockKeyMap[GUIEventAdapter::KEY_KP_End] = '1'; @@ -66,6 +51,7 @@ FGManipulator::FGManipulator() : numlockKeyMap[GUIEventAdapter::KEY_KP_Home] = '7'; numlockKeyMap[GUIEventAdapter::KEY_KP_Up] = '8'; numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9'; +#endif for (int i = 0; i < 128; i++) release_keys[i] = i; @@ -286,26 +272,17 @@ void FGManipulator::handleKey(const osgGA::GUIEventAdapter& ea, int& key, case osgGA::GUIEventAdapter::KEY_KP_Subtract: key = '-'; break; } osgGA::GUIEventAdapter::EventType eventType = ea.getEventType(); + +#if 0 std::map::iterator numPadIter = numlockKeyMap.find(key); if (numPadIter != numlockKeyMap.end()) { if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_NUM_LOCK) { key = numPadIter->second; } - } else if (useEventModifiers) { - - }else { - // Track the modifiers because OSG is currently (2.0) broken - KeyMaskMap::iterator iter = keyMaskMap.find(key); - if (iter != keyMaskMap.end()) { - int mask = iter->second; - if (eventType == osgGA::GUIEventAdapter::KEYUP) - osgModifiers &= ~mask; - else - osgModifiers |= mask; - } } - modifiers = osgToFGModifiers(osgModifiers); +#endif + modifiers = osgToFGModifiers(ea.getModKeyMask()); currentModifiers = modifiers; if (eventType == osgGA::GUIEventAdapter::KEYUP) modifiers |= KEYMOD_RELEASED; diff --git a/src/Main/FGManipulator.hxx b/src/Main/FGManipulator.hxx index 6605f7426..7e39fe855 100644 --- a/src/Main/FGManipulator.hxx +++ b/src/Main/FGManipulator.hxx @@ -119,8 +119,6 @@ public: bool getResizable() { return resizable; } void setResizable(bool _resizable) { resizable = _resizable; } - bool getUseEventModifiers() { return useEventModifiers; } - void setUseEventModifiers(bool val) { useEventModifiers = val; } protected: osg::ref_ptr _node; fgIdleHandler idleHandler; @@ -133,11 +131,9 @@ protected: osg::ref_ptr statsEvent; int statsType; int currentModifiers; - // work-around for OSG bug - int osgModifiers; - typedef std::map KeyMaskMap; - KeyMaskMap keyMaskMap; +#if 0 std::map numlockKeyMap; +#endif osg::Vec3d position; osg::Quat attitude; void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers); @@ -146,9 +142,6 @@ protected: // workaround for osgViewer double scroll events bool scrollButtonPressed; int release_keys[128]; - // When the viewer is embedded, the host toolkit may deliver a - // valid event mask but not control keys. - bool useEventModifiers; void handleStats(osgGA::GUIActionAdapter& us); }; #endif diff --git a/src/Main/fg_os.cxx b/src/Main/fg_os.cxx index cb8d6c23d..7cf55792a 100644 --- a/src/Main/fg_os.cxx +++ b/src/Main/fg_os.cxx @@ -268,7 +268,6 @@ void fgOSOpenWindow(int w, int h, int bpp, bool alpha, camera->setViewport(new osg::Viewport(0, 0, realw, realh)); camera->setProjectionResizePolicy(rsp); //viewer->addSlave(camera.get()); - globals->get_renderer()->getManipulator()->setUseEventModifiers(true); viewer->setCameraManipulator(globals->get_renderer()->getManipulator()); // Let FG handle the escape key with a confirmation viewer->setKeyEventSetsDone(0); -- 2.39.5