14 #ifndef OSGGA_GUIEVENTADAPTER
15 #define OSGGA_GUIEVENTADAPTER 1
19 #include <osg/GraphicsContext>
21 #include <osgGA/Event>
57 if (&pd==
this)
return *
this;
86 LEFT_MOUSE_BUTTON = 1<<0,
87 MIDDLE_MOUSE_BUTTON = 1<<1,
88 RIGHT_MOUSE_BUTTON = 1<<2
103 PEN_PRESSURE = 1<<10,
104 PEN_ORIENTATION = 1<<11,
105 PEN_PROXIMITY_ENTER = 1<<12,
106 PEN_PROXIMITY_LEAVE = 1<<13,
107 CLOSE_WINDOW = 1<<14,
108 QUIT_APPLICATION = 1<<15,
157 KEY_Ampersand = 0x26,
159 KEY_Leftparen = 0x28,
160 KEY_Rightparen = 0x29,
168 KEY_Semicolon = 0x3B,
174 KEY_Leftbracket = 0x5B,
175 KEY_Backslash = 0x5C,
176 KEY_Rightbracket = 0x5D,
178 KEY_Underscore = 0x5F,
179 KEY_Backquote = 0x60,
181 KEY_BackSpace = 0xFF08,
183 KEY_Linefeed = 0xFF0A,
187 KEY_Scroll_Lock = 0xFF14,
188 KEY_Sys_Req = 0xFF15,
201 KEY_Page_Up = 0xFF55,
203 KEY_Page_Down = 0xFF56,
212 KEY_Execute = 0xFF62,
221 KEY_Mode_switch = 0xFF7E,
222 KEY_Script_switch = 0xFF7E,
223 KEY_Num_Lock = 0xFF7F,
227 KEY_KP_Space = 0xFF80,
229 KEY_KP_Enter = 0xFF8D,
234 KEY_KP_Home = 0xFF95,
235 KEY_KP_Left = 0xFF96,
237 KEY_KP_Right = 0xFF98,
238 KEY_KP_Down = 0xFF99,
239 KEY_KP_Prior = 0xFF9A,
240 KEY_KP_Page_Up = 0xFF9A,
241 KEY_KP_Next = 0xFF9B,
242 KEY_KP_Page_Down = 0xFF9B,
244 KEY_KP_Begin = 0xFF9D,
245 KEY_KP_Insert = 0xFF9E,
246 KEY_KP_Delete = 0xFF9F,
247 KEY_KP_Equal = 0xFFBD,
248 KEY_KP_Multiply = 0xFFAA,
250 KEY_KP_Separator = 0xFFAC,
251 KEY_KP_Subtract = 0xFFAD,
252 KEY_KP_Decimal = 0xFFAE,
253 KEY_KP_Divide = 0xFFAF,
311 KEY_Shift_L = 0xFFE1,
312 KEY_Shift_R = 0xFFE2,
313 KEY_Control_L = 0xFFE3,
314 KEY_Control_R = 0xFFE4,
315 KEY_Caps_Lock = 0xFFE5,
316 KEY_Shift_Lock = 0xFFE6,
322 KEY_Super_L = 0xFFEB,
323 KEY_Super_R = 0xFFEC,
324 KEY_Hyper_L = 0xFFED,
331 MODKEY_LEFT_SHIFT = 0x0001,
332 MODKEY_RIGHT_SHIFT = 0x0002,
333 MODKEY_LEFT_CTRL = 0x0004,
334 MODKEY_RIGHT_CTRL = 0x0008,
335 MODKEY_LEFT_ALT = 0x0010,
336 MODKEY_RIGHT_ALT = 0x0020,
337 MODKEY_LEFT_META = 0x0040,
338 MODKEY_RIGHT_META = 0x0080,
339 MODKEY_LEFT_SUPER = 0x0100,
340 MODKEY_RIGHT_SUPER = 0x0200,
341 MODKEY_LEFT_HYPER = 0x0400,
342 MODKEY_RIGHT_HYPER = 0x0800,
343 MODKEY_NUM_LOCK = 0x1000,
344 MODKEY_CAPS_LOCK = 0x2000,
345 MODKEY_CTRL = (MODKEY_LEFT_CTRL|MODKEY_RIGHT_CTRL),
346 MODKEY_SHIFT = (MODKEY_LEFT_SHIFT|MODKEY_RIGHT_SHIFT),
347 MODKEY_ALT = (MODKEY_LEFT_ALT|MODKEY_RIGHT_ALT),
348 MODKEY_META = (MODKEY_LEFT_META|MODKEY_RIGHT_META),
349 MODKEY_SUPER = (MODKEY_LEFT_SUPER|MODKEY_RIGHT_SUPER),
350 MODKEY_HYPER = (MODKEY_LEFT_HYPER|MODKEY_RIGHT_HYPER)
356 Y_INCREASING_DOWNWARDS
395 TouchPoint() : id(0), phase(TOUCH_UNKNOWN), x(0.0f), y(0.0f), tapCount(0) {}
401 tapCount(in_tap_count)
414 osg::Object(td,copyop),
415 _touches(td._touches) {}
423 iterator
begin() {
return _touches.begin(); }
424 const_iterator
begin()
const {
return _touches.begin(); }
426 iterator
end() {
return _touches.end(); }
427 const_iterator
end()
const {
return _touches.end(); }
429 const TouchPoint get(
unsigned int i)
const {
return _touches[i]; }
436 _touches.push_back(
TouchPoint(
id, phase, x, y, tap_count));
469 double time()
const {
return _time; }
478 void setWindowRectangle(
int x,
int y,
int width,
int height,
bool updateMouseRange =
true);
506 inline void setKey(
int key) { _key = key; }
509 virtual int getKey()
const {
return _key; }
525 void setInputRange(
float Xmin,
float Ymin,
float Xmax,
float Ymax);
552 void setX(
float x) { _mx = x; }
555 float getX()
const {
return _mx; }
558 void setY(
float y) { _my = y; }
561 float getY()
const {
return _my; }
566 return _pointerDataList.size()>=1 ?
567 _pointerDataList[_pointerDataList.size()-1]->getXnormalized():
568 2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f;
573 if (_pointerDataList.size()>=1)
return _pointerDataList[_pointerDataList.size()-1]->getYnormalized();
574 if (_mouseYOrientation==Y_INCREASING_UPWARDS)
return 2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f;
575 else return -(2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f);
584 inline float getXnormalized()
const {
return 2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f; }
592 inline float getYnormalized()
const
594 if (_mouseYOrientation==Y_INCREASING_UPWARDS)
return 2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f;
595 else return -(2.0f*(getY()-getYmin())/(getYmax()-getYmin())-1.0f);
606 void setMouseYOrientationAndUpdateCoords(MouseYOrientation myo);
628 _scrolling.motion = SCROLL_2D;
629 _scrolling.deltaX = x;
630 _scrolling.deltaY = y;
679 void addTouchPoint(
unsigned int id, TouchPhase phase,
float x,
float y,
unsigned int tapCount = 0);
686 return (getTouchData()->
get(ndx).x-_Xmin)/(_Xmax-_Xmin)*2.0f-1.0f;
690 if (_mouseYOrientation==Y_INCREASING_UPWARDS)
691 return (getTouchData()->
get(ndx).y-_Ymin)/(_Ymax-_Ymin)*2.0f-1.0f;
693 return -((getTouchData()->get(ndx).y-_Ymin)/(_Ymax-_Ymin)*2.0f-1.0f);
701 unsigned int getNumPointerData()
const {
return static_cast<unsigned int>(_pointerDataList.size()); }
706 const PointerData*
getPointerData(
osg::Object* obj)
const {
for(
unsigned int i=0;i<_pointerDataList.size(); ++i) {
if (_pointerDataList[i]->
object==obj)
return _pointerDataList[i].get(); }
return 0; }
739 Scrolling() : motion(SCROLL_NONE), deltaX(0), deltaY(0) {}
751 TabletPen() : pressure(0), tiltX(0), tiltY(0), rotation(0), tabletPointerType(UNKNOWN) {}
752 TabletPen(
const TabletPen& rhs) : pressure(rhs.pressure), tiltX(rhs.tiltX), tiltY(rhs.tiltY), rotation(rhs.rotation), tabletPointerType(rhs.tabletPointerType) {}
float getPenTiltX() const
get the tablet pen tiltX in degrees.
PointerData(osg::Object *obj, float in_x, float in_xMin, float in_xMax, float in_y, float in_yMin, float in_yMax)
float getTouchPointNormalizedX(unsigned int ndx) const
void addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tap_count)
int getWindowHeight() const
unsigned int getNumPointerData() const
float getYnormalized() const
PointerData(const PointerData &pd)
void setButtonMask(int mask)
set current mouse button state.
void setPenRotation(float rotation)
set the tablet pen rotation around the Z-axis in degrees.
PointerData * getPointerData(unsigned int i)
PointerDataList & getPointerDataList()
osg::observer_ptr< osg::Object > object
void setGraphicsContext(osg::GraphicsContext *context)
void setModKeyMask(int mask)
set modifier key mask.
float getScrollingDeltaX() const
get the scrolling x-delta.
void setPenTiltY(float tiltY)
set the tablet pen tiltY in degrees.
int getUnmodifiedKey() const
const_iterator begin() const
const PointerData * getPointerData(unsigned int i) const
TouchData * getTouchData() const
float getXnormalized() const
const TouchPoint get(unsigned int i) const
float getXnormalized() const
void setPenTiltX(float tiltX)
set the tablet pen tiltX in degrees.
void setScrollingDeltaY(float v)
set the scrolling y-delta.
float getPenRotation() const
get the tablet pen rotation around the Z-axis in degrees.
void setWindowWidth(int v)
TabletPen(const TabletPen &rhs)
virtual const GUIEventAdapter * asGUIEventAdapter() const
PointerDataList _pointerDataList
void setPointerDataList(const PointerDataList &pdl)
const_iterator end() const
void setTouchData(TouchData *td)
TouchSet::iterator iterator
float getPenTiltY() const
get the tablet pen tiltY in degrees.
void setScrollingMotionDelta(float x, float y)
set the scrolling delta to x,y and the scrolling motion to SCROLL_2D.
#define META_Object(library, name)
TouchPoint(unsigned int in_id, TouchPhase in_phase, float in_x, float in_y, unsigned int in_tap_count)
unsigned int getNumTouchPoints() const
GLint GLenum GLsizei width
PointerData & operator=(const PointerData &pd)
void setEventType(EventType Type)
void setButton(int button)
void setScrollingDeltaX(float v)
set the scrolling x-delta.
int getWindowWidth() const
const PointerDataList & getPointerDataList() const
TouchData(const TouchData &td, const osg::CopyOp ©op)
void setUnmodifiedKey(int key)
TouchSet::const_iterator const_iterator
virtual int getKey() const
void setMouseYOrientation(MouseYOrientation myo)
set mouse-Y orientation (mouse-Y increases upwards or downwards).
MouseYOrientation getMouseYOrientation() const
get mouse-Y orientation (mouse-Y increases upwards or downwards).
float getYnormalized() const
PointerData * getPointerData(osg::Object *obj)
void setTabletPointerType(TabletPointerType pt)
set the tablet pointer type.
osg::ref_ptr< TouchData > _touchData
float getScrollingDeltaY() const
get the scrolling y-delta.
GLint GLenum GLsizei GLsizei height
const osg::GraphicsContext * getGraphicsContext() const
int getModKeyMask() const
get modifier key mask.
void addPointerData(PointerData *pd)
void setWindowHeight(int v)
void setScrollingMotion(ScrollingMotion motion)
set scrolling motion (for EventType::SCROLL).
ScrollingMotion getScrollingMotion() const
get scrolling motion (for EventType::SCROLL).
virtual GUIEventAdapter * asGUIEventAdapter()
float getTouchPointNormalizedY(unsigned int ndx) const
MouseYOrientation _mouseYOrientation
bool isMultiTouchEvent() const
TabletPointerType getTabletPointerType() const
get the tablet pointer type.
float getPenPressure() const
get the tablet pen pressure (range 0..1).
osg::GraphicsContext * getGraphicsContext()
TabletPointerType tabletPointerType
void setPenPressure(float pressure)
set the tablet pen pressure (range 0..1).
virtual EventType getEventType() const
int getButtonMask() const
get current mouse button state.
const PointerData * getPointerData(osg::Object *obj) const
osg::observer_ptr< osg::GraphicsContext > _context
std::vector< TouchPoint > TouchSet
std::vector< osg::ref_ptr< PointerData > > PointerDataList