]> git.mxchange.org Git - flightgear.git/commitdiff
after OSG 2.4 upgrade, remove modifier workaround and comment out numpad
authormfranz <mfranz>
Fri, 25 Apr 2008 22:45:43 +0000 (22:45 +0000)
committermfranz <mfranz>
Fri, 25 Apr 2008 22:45:43 +0000 (22:45 +0000)
workaround (we have yet to verify if the latter is really obsolete)

src/Main/FGManipulator.cxx
src/Main/FGManipulator.hxx
src/Main/fg_os.cxx

index 226f3685e898bf3f6cb32c2bc8bdc061e7776180..a7b1c60bccb5204ba3d9a7a1c4f75f277882e66b 100644 (file)
@@ -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<int, int>::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;
index 6605f742636b43c9d35d133e053aa611ac9f5dd4..7e39fe855759c12dedf836e922480bb08bad01ac 100644 (file)
@@ -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<osg::Node> _node;
     fgIdleHandler idleHandler;
@@ -133,11 +131,9 @@ protected:
     osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
     int statsType;
     int currentModifiers;
-    // work-around for OSG bug
-    int osgModifiers;
-    typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
-    KeyMaskMap keyMaskMap;
+#if 0
     std::map<int, int> 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
index cb8d6c23de876da1e5e1fa73deaedbdff8d0e848..7cf55792aadad5606327f41ecce68c0c1d5edd50 100644 (file)
@@ -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);