1 #ifndef FGEVENTHANDLER_H
2 #define FGEVENTHANDLER_H 1
6 #include <osgGA/GUIEventHandler>
7 #include <osgViewer/ViewerEventHandlers>
13 class FGEventHandler : public osgGA::GUIEventHandler {
17 virtual ~FGEventHandler() {}
19 virtual const char* className() const {return "FGEventHandler"; }
21 virtual void init(const osgGA::GUIEventAdapter& ea,
22 osgGA::GUIActionAdapter& us);
24 virtual bool handle(const osgGA::GUIEventAdapter& ea,
25 osgGA::GUIActionAdapter& us);
27 void setIdleHandler(fgIdleHandler idleHandler)
29 this->idleHandler = idleHandler;
32 fgIdleHandler getIdleHandler() const
37 void setKeyHandler(fgKeyHandler keyHandler)
39 this->keyHandler = keyHandler;
42 fgKeyHandler getKeyHandler() const
47 void setMouseClickHandler(fgMouseClickHandler mouseClickHandler)
49 this->mouseClickHandler = mouseClickHandler;
52 fgMouseClickHandler getMouseClickHandler()
54 return mouseClickHandler;
57 void setMouseMotionHandler(fgMouseMotionHandler mouseMotionHandler)
59 this->mouseMotionHandler = mouseMotionHandler;
62 fgMouseMotionHandler getMouseMotionHandler()
64 return mouseMotionHandler;
67 int getCurrentModifiers() const
69 return currentModifiers;
77 /** Whether or not resizing is supported. It might not be when
78 * using multiple displays.
80 bool getResizable() { return resizable; }
81 void setResizable(bool _resizable) { resizable = _resizable; }
84 osg::ref_ptr<osg::Node> _node;
85 fgIdleHandler idleHandler;
86 fgKeyHandler keyHandler;
87 fgMouseClickHandler mouseClickHandler;
88 fgMouseMotionHandler mouseMotionHandler;
89 osg::ref_ptr<osgViewer::StatsHandler> statsHandler;
90 osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
93 std::map<int, int> numlockKeyMap;
94 std::map<int, int> noNumlockKeyMap;
95 void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
98 // workaround for osgViewer double scroll events
99 bool scrollButtonPressed;
100 int release_keys[128];
101 void handleStats(osgGA::GUIActionAdapter& us);
104 void eventToWindowCoords(const osgGA::GUIEventAdapter* ea, double& x, double& y);
105 void eventToWindowCoordsYDown(const osgGA::GUIEventAdapter* ea,
106 double& x, double& y);