1
/**************************************************************************\
2
* Copyright (c) Kongsberg Oil & Gas Technologies AS
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
9
* Redistributions of source code must retain the above copyright notice,
10
* this list of conditions and the following disclaimer.
12
* Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
16
* Neither the name of the copyright holder nor the names of its
17
* contributors may be used to endorse or promote products derived from
18
* this software without specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
\**************************************************************************/
34
#pragma warning(disable : 4267)
38
#include <Inventor/events/SoEvents.h>
40
#include "devices/InputDevice.h"
43
using namespace SIM::Coin3D::Quarter;
46
\class SIM::Coin3D::Quarter::InputDevice InputDevice.h Quarter/devices/InputDevice.h
48
\brief The InputDevice class is the base class for devices such as
49
the Keyboard and Mouse. It can be subclassed to support other
53
InputDevice::InputDevice() : quarter(nullptr)
55
this->mousepos = SbVec2s(0, 0);
58
InputDevice::InputDevice(QuarterWidget *quarter) : quarter(quarter)
60
this->mousepos = SbVec2s(0, 0);
64
Sets the mouseposition
66
\param[in] pos position of mouse in pixelcoordinates
70
InputDevice::setMousePosition(const SbVec2s & pos)
76
Sets the window size of the owning window
78
\param[in] size in pixels
81
InputDevice::setWindowSize(const SbVec2s & size)
83
this->windowsize = size;
87
Transforms a qevent into an soevent
89
\param[in,out] soevent the transformed event
90
\param[in] qevent incoming qevent
93
InputDevice::setModifiers(SoEvent * soevent, const QInputEvent * qevent)
95
// FIXME: How do we get the time from the qevent? (20070306 frodo)
96
soevent->setTime(SbTime::getTimeOfDay());
98
// Note: On Mac OS X, the ControlModifier value corresponds to the
99
// Command keys on the Macintosh keyboard, and the MetaModifier
100
// value corresponds to the Control keys.
101
soevent->setShiftDown(qevent->modifiers() & Qt::ShiftModifier);
102
soevent->setAltDown(qevent->modifiers() & Qt::AltModifier);
103
soevent->setCtrlDown(qevent->modifiers() & Qt::ControlModifier);
107
\var InputDevice::mousepos
109
Holds the last known position of the mouse. This should be set even
110
for a keyboard event.
114
\var InputDevice::windowsize
116
Holds the size of the owning window