//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield //Distributed under the terms of the GNU Library General Public License (LGPL) //as published by the Free Software Foundation. #ifndef OSGPRODUCER_EVENTCALLBACK #define OSGPRODUCER_EVENTCALLBACK 1 #include // For definition of KeySymbol #include #include #include #include #include namespace osgProducer { class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseCallback { public: KeyboardMouseCallback(bool &done) : Producer::KeyboardMouseCallback(), _mx(0.0f),_my(0.0f),_mbutton(0), _done(done) {} virtual ~KeyboardMouseCallback() {} virtual void keyPress( Producer::KeySymbol key ); virtual void keyRelease( Producer::KeySymbol key ); virtual void mouseMotion( float mx, float my); virtual void passiveMouseMotion( float mx, float my); virtual void buttonPress( float mx, float my, unsigned int mbutton ); virtual void buttonRelease( float mx, float my, unsigned int mbutton ); typedef std::vector< osg::ref_ptr > EventQueue; void getEventQueue(EventQueue& queue); bool done() { return _done; } float mx() { return _mx; } float my() { return _my; } unsigned int mbutton() { return _mbutton; } void setStartTick(osg::Timer_t tick) { _startTick = tick; } double getTime() { return _timer.delta_s(_startTick,_timer.tick()); } private: float _mx, _my; unsigned int _mbutton; bool &_done; osg::Timer_t _startTick; osg::Timer _timer; Producer::Mutex _eventQueueMutex; EventQueue _eventQueue; }; } #endif