root/OpenSceneGraph/trunk/src/osgGA/GUIEventAdapter.cpp @ 12125

Revision 12125, 3.4 kB (checked in by robert, 3 years ago)

From Alexander Sinditskiy, "reason of this changes described in http://forum.openscenegraph.org/viewtopic.php?t=7596

and another problem is:
example osgkeyboard is not work (keys not highlight) if user have 2 keyboard layout native and english and current user layout is native

I try to explain my changes

we need something that is identify key without modifier keys and layout -> this is UnmodifedKey?

I think osg must have its own UnmodifiedKeys? table. Code must be run same on different platforms. This can de guaranteed by UnmodifiedKeys? table.

Mikhail Izmestev helped me. He implemented VirtualKey? changes in GraphicsWindowX11"

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#include <osgGA/GUIEventAdapter>
15
16using namespace osgGA;
17
18
19osg::ref_ptr<GUIEventAdapter>& GUIEventAdapter::getAccumulatedEventState()
20{
21    static osg::ref_ptr<GUIEventAdapter> s_eventState = new GUIEventAdapter;
22    return s_eventState;
23}
24
25GUIEventAdapter::GUIEventAdapter():
26    _handled(false),
27    _eventType(NONE),
28    _time(0.0),
29    _windowX(0),
30    _windowY(0),
31    _windowWidth(1280),
32    _windowHeight(1024),
33    _key(0),
34    _unmodifiedKey(0),
35    _button(0),
36    _Xmin(-1.0),
37    _Xmax(1.0),
38    _Ymin(-1.0),
39    _Ymax(1.0),
40    _mx(0.0),
41    _my(0.0),
42    _buttonMask(0),
43    _modKeyMask(0),
44    _mouseYOrientation(Y_INCREASING_DOWNWARDS),
45    _scrolling(),
46    _tabletPen(),
47    _touchData(NULL)
48{}
49
50GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs,const osg::CopyOp& copyop):
51    osg::Object(rhs,copyop),
52    _handled(rhs._handled),
53    _eventType(rhs._eventType),
54    _time(rhs._time),
55    _context(rhs._context),
56    _windowX(rhs._windowX),
57    _windowY(rhs._windowY),
58    _windowWidth(rhs._windowWidth),
59    _windowHeight(rhs._windowHeight),
60    _key(rhs._key),
61    _unmodifiedKey(rhs._unmodifiedKey),
62    _button(rhs._button),
63    _Xmin(rhs._Xmin),
64    _Xmax(rhs._Xmax),
65    _Ymin(rhs._Ymin),
66    _Ymax(rhs._Ymax),
67    _mx(rhs._mx),
68    _my(rhs._my),
69    _buttonMask(rhs._buttonMask),
70    _modKeyMask(rhs._modKeyMask),
71    _mouseYOrientation(rhs._mouseYOrientation),
72    _scrolling(rhs._scrolling),
73    _tabletPen(rhs._tabletPen),
74    _touchData(rhs._touchData)
75{}
76
77GUIEventAdapter::~GUIEventAdapter()
78{
79}
80
81void GUIEventAdapter::setWindowRectangle(int x, int y, int width, int height, bool updateMouseRange)
82{
83    _windowX = x;
84    _windowY = y;
85    _windowWidth = width;
86    _windowHeight = height;
87   
88    if (updateMouseRange)
89    {
90        setInputRange(0, 0, width, height);
91    }
92   
93}
94
95void GUIEventAdapter::setInputRange(float Xmin, float Ymin, float Xmax, float Ymax)
96{
97    _Xmin = Xmin;
98    _Ymin = Ymin;
99    _Xmax = Xmax;
100    _Ymax = Ymax;
101}
102
103const osg::Matrix GUIEventAdapter::getPenOrientation() const
104{
105    float xRad = osg::DegreesToRadians ( getPenTiltY() );
106    float yRad = osg::DegreesToRadians ( getPenTiltX() );
107    float zRad = osg::DegreesToRadians ( getPenRotation() );
108    osg::Matrix xrot = osg::Matrix::rotate ( xRad, osg::Vec3f(1.0f, 0.0f, 0.0f) );
109    osg::Matrix yrot = osg::Matrix::rotate ( yRad, osg::Vec3f(0.0f, 0.0f, 1.0f) );
110    osg::Matrix zrot = osg::Matrix::rotate ( zRad, osg::Vec3f(0.0f, 1.0f, 0.0f) );
111   
112    return ( zrot * yrot * xrot );
113}
114
115void GUIEventAdapter::addTouchPoint(unsigned int id, TouchPhase phase, float x, float y, unsigned int tapCount)
116{
117    if (!_touchData.valid()) {
118        _touchData = new TouchData();
119        setX(x);
120        setY(y);
121    }
122   
123    _touchData->addTouchPoint(id, phase, x, y, tapCount);
124}
Note: See TracBrowser for help on using the browser.