2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
2003-01-21 21:14:29 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
#ifndef OSGPRODUCER_EVENTCALLBACK
|
|
|
|
#define OSGPRODUCER_EVENTCALLBACK 1
|
|
|
|
|
2003-07-19 08:18:07 +08:00
|
|
|
#include <OpenThreads/Mutex>
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-09-17 03:56:19 +08:00
|
|
|
#include <osgProducer/Export> // To disable MSVC warnings
|
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
#include <Producer/RenderSurface> // For definition of KeySymbol
|
|
|
|
#include <Producer/KeyboardMouse>
|
2006-03-08 22:09:47 +08:00
|
|
|
#include <osgGA/EventQueue>
|
2003-01-18 02:34:35 +08:00
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Timer>
|
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
namespace osgProducer {
|
|
|
|
|
|
|
|
|
|
|
|
class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseCallback
|
2003-01-17 19:26:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2006-03-08 22:09:47 +08:00
|
|
|
KeyboardMouseCallback(Producer::KeyboardMouse* keyboardMouse, bool &done, bool escapeKeySetsDone=true);
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-01-18 02:34:35 +08:00
|
|
|
virtual ~KeyboardMouseCallback() {}
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-03-27 18:54:01 +08:00
|
|
|
// override KeyboardMouseCallback methods.
|
2003-05-07 19:13:49 +08:00
|
|
|
virtual void mouseScroll( Producer::KeyboardMouseCallback::ScrollingMotion sm );
|
2006-07-04 22:18:44 +08:00
|
|
|
virtual void mouseScroll2D( float, float);
|
|
|
|
virtual void penPressure(float pressure);
|
2006-07-04 22:37:56 +08:00
|
|
|
virtual void penProximity(Producer::KeyboardMouseCallback::TabletPointerType, bool);
|
2003-01-17 19:26:16 +08:00
|
|
|
virtual void mouseMotion( float mx, float my);
|
2003-01-18 18:17:28 +08:00
|
|
|
virtual void passiveMouseMotion( float mx, float my);
|
2003-11-12 18:13:31 +08:00
|
|
|
virtual void mouseWarp( float mx, float my);
|
2003-01-18 18:17:28 +08:00
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
virtual void buttonPress( float mx, float my, unsigned int mbutton );
|
2003-11-12 18:13:31 +08:00
|
|
|
virtual void doubleButtonPress( float mx, float my, unsigned int mbutton);
|
2003-01-17 19:26:16 +08:00
|
|
|
virtual void buttonRelease( float mx, float my, unsigned int mbutton );
|
|
|
|
|
2003-03-27 18:54:01 +08:00
|
|
|
virtual void keyPress( Producer::KeyCharacter key );
|
|
|
|
virtual void keyRelease( Producer::KeyCharacter key );
|
|
|
|
|
2003-11-12 18:13:31 +08:00
|
|
|
virtual void specialKeyPress( Producer::KeyCharacter key);
|
|
|
|
virtual void specialKeyRelease( Producer::KeyCharacter key);
|
2003-08-27 18:22:12 +08:00
|
|
|
|
2003-11-12 18:13:31 +08:00
|
|
|
virtual void windowConfig( int x, int y, unsigned int width, unsigned int height );
|
|
|
|
|
2003-08-27 18:22:12 +08:00
|
|
|
virtual void shutdown();
|
2003-03-27 18:54:01 +08:00
|
|
|
|
|
|
|
|
2003-03-28 18:04:58 +08:00
|
|
|
void setEscapeSetDone(bool esc) { _escapeKeySetsDone = esc; }
|
|
|
|
bool getEscapeSetDone() const { return _escapeKeySetsDone; }
|
|
|
|
|
|
|
|
|
2003-03-27 18:54:01 +08:00
|
|
|
// local methods and members
|
2006-03-08 22:09:47 +08:00
|
|
|
typedef osgGA::EventQueue::Events EventQueue;
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2006-03-13 21:19:37 +08:00
|
|
|
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
|
2006-03-08 22:09:47 +08:00
|
|
|
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
|
|
|
|
|
|
|
|
bool takeEventQueue(EventQueue& queue);
|
|
|
|
bool copyEventQueue(EventQueue& queue) const;
|
|
|
|
void setEventQueue(EventQueue& queue);
|
|
|
|
void appendEventQueue(EventQueue& queue);
|
2005-08-29 20:05:17 +08:00
|
|
|
|
|
|
|
bool done() const { return _done; }
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2006-03-08 22:09:47 +08:00
|
|
|
double getTime() const { return _eventQueue->getTime(); }
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-04-05 03:10:37 +08:00
|
|
|
Producer::KeyboardMouse* getKeyboardMouse() { return _keyboardMouse; }
|
|
|
|
const Producer::KeyboardMouse* getKeyboardMouse() const { return _keyboardMouse; }
|
|
|
|
|
2006-03-08 22:09:47 +08:00
|
|
|
osgGA::GUIEventAdapter* createEventAdapter();
|
2003-04-05 15:19:40 +08:00
|
|
|
|
2006-03-08 22:09:47 +08:00
|
|
|
void updateWindowSize();
|
|
|
|
|
2003-03-27 18:54:01 +08:00
|
|
|
protected:
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2003-04-05 03:10:37 +08:00
|
|
|
|
|
|
|
Producer::KeyboardMouse* _keyboardMouse;
|
2003-01-17 19:26:16 +08:00
|
|
|
float _mx, _my;
|
|
|
|
unsigned int _mbutton;
|
|
|
|
bool &_done;
|
2003-03-19 22:27:05 +08:00
|
|
|
bool _escapeKeySetsDone;
|
2003-01-17 19:26:16 +08:00
|
|
|
|
2006-03-08 22:09:47 +08:00
|
|
|
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
|
2003-01-17 19:26:16 +08:00
|
|
|
|
|
|
|
};
|
2003-01-18 02:34:35 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-01-17 19:26:16 +08:00
|
|
|
#endif
|