2003-01-17 19:26:16 +08:00
|
|
|
//C++
|
|
|
|
#ifndef PRODUCEREVENTCALLBACK
|
|
|
|
#define PRODUCEREVENTCALLBACK
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <Producer/RenderSurface> // For definition of KeySymbol
|
|
|
|
#include <Producer/KeyboardMouse>
|
|
|
|
#include <Producer/Mutex>
|
|
|
|
|
|
|
|
#include "ProducerEventAdapter.h"
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Timer>
|
|
|
|
|
|
|
|
class ProducerEventCallback : public Producer::KeyboardMouseCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProducerEventCallback(bool &done) :
|
|
|
|
Producer::KeyboardMouseCallback(),
|
|
|
|
_mx(0.0f),_my(0.0f),_mbutton(0),
|
|
|
|
_done(done)
|
|
|
|
{}
|
|
|
|
|
2003-01-17 21:34:03 +08:00
|
|
|
virtual ~ProducerEventCallback() {}
|
2003-01-17 19:26:16 +08:00
|
|
|
|
|
|
|
virtual void keyPress( Producer::KeySymbol key );
|
|
|
|
|
|
|
|
virtual void keyRelease( Producer::KeySymbol key );
|
|
|
|
|
|
|
|
virtual void mouseMotion( 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<ProducerEventAdapter> > EventQueue;
|
|
|
|
|
|
|
|
void getEventQueue(EventQueue& queue);
|
|
|
|
|
|
|
|
bool done() { return _done; }
|
|
|
|
float mx() { return _mx; }
|
|
|
|
float my() { return _my; }
|
|
|
|
unsigned int mbutton() { return _mbutton; }
|
|
|
|
|
2003-01-17 22:12:46 +08:00
|
|
|
void setStartTick(osg::Timer_t tick) { _startTick = tick; }
|
|
|
|
|
|
|
|
double getTime() { return _timer.delta_s(_startTick,_timer.tick()); }
|
2003-01-17 19:26:16 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
float _mx, _my;
|
|
|
|
unsigned int _mbutton;
|
|
|
|
bool &_done;
|
|
|
|
|
2003-01-17 22:12:46 +08:00
|
|
|
osg::Timer_t _startTick;
|
|
|
|
osg::Timer _timer;
|
2003-01-17 19:26:16 +08:00
|
|
|
Producer::Mutex _eventQueueMutex;
|
|
|
|
EventQueue _eventQueue;
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|