Files
OpenSceneGraph/include/osgProducer/KeyboardMouseCallback
Robert Osfield 13aa469628 Updated the KeyboardMouseCallback so this it takes into account the the new
passiveMouseMotion support in Producer.
2003-01-18 10:17:28 +00:00

73 lines
2.0 KiB
Plaintext

//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 <Producer/RenderSurface> // For definition of KeySymbol
#include <Producer/KeyboardMouse>
#include <Producer/Mutex>
#include <osgProducer/EventAdapter>
#include <osg/ref_ptr>
#include <osg/Timer>
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<EventAdapter> > 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