/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #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