summaryrefslogtreecommitdiffstats
path: root/src/input/frontend
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-11-25 14:56:11 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-11-28 08:14:12 +0000
commit4519e46f38df25dd61eb566ab2080896e775a531 (patch)
treeea2c714f4d7341ecdc293380ff179f6995b9d795 /src/input/frontend
parentc6d56b613164e506562b6a537aef499ffb4fb649 (diff)
Reorganize Input aspect sources into backend/frontend
Change-Id: I7cb9137a6f108d557e3028dc0b72a0053d3f01d4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input/frontend')
-rw-r--r--src/input/frontend/frontend.pri39
-rw-r--r--src/input/frontend/q3dkeyevent.cpp152
-rw-r--r--src/input/frontend/q3dkeyevent.h87
-rw-r--r--src/input/frontend/q3dmouseevent.cpp263
-rw-r--r--src/input/frontend/q3dmouseevent.h156
-rw-r--r--src/input/frontend/qabstractinputdevice.h66
-rw-r--r--src/input/frontend/qaction.cpp113
-rw-r--r--src/input/frontend/qaction.h80
-rw-r--r--src/input/frontend/qactioninput.cpp122
-rw-r--r--src/input/frontend/qactioninput.h82
-rw-r--r--src/input/frontend/qaxis.cpp113
-rw-r--r--src/input/frontend/qaxis.h79
-rw-r--r--src/input/frontend/qaxisinput.cpp160
-rw-r--r--src/input/frontend/qaxisinput.h94
-rw-r--r--src/input/frontend/qinputaspect.cpp191
-rw-r--r--src/input/frontend/qinputaspect.h88
-rw-r--r--src/input/frontend/qinputaspect_p.h80
-rw-r--r--src/input/frontend/qinputdevicefactory.cpp93
-rw-r--r--src/input/frontend/qinputdevicefactory_p.h71
-rw-r--r--src/input/frontend/qinputdeviceplugin.cpp61
-rw-r--r--src/input/frontend/qinputdeviceplugin.h68
-rw-r--r--src/input/frontend/qkeyboardcontroller.cpp119
-rw-r--r--src/input/frontend/qkeyboardcontroller.h78
-rw-r--r--src/input/frontend/qkeyboardcontroller_p.h73
-rw-r--r--src/input/frontend/qkeyboardinput.cpp414
-rw-r--r--src/input/frontend/qkeyboardinput.h128
-rw-r--r--src/input/frontend/qkeyboardinput_p.h74
-rw-r--r--src/input/frontend/qlogicaldevice.cpp124
-rw-r--r--src/input/frontend/qlogicaldevice.h78
-rw-r--r--src/input/frontend/qmousecontroller.cpp91
-rw-r--r--src/input/frontend/qmousecontroller.h74
-rw-r--r--src/input/frontend/qmousecontroller_p.h72
-rw-r--r--src/input/frontend/qmouseinput.cpp195
-rw-r--r--src/input/frontend/qmouseinput.h99
-rw-r--r--src/input/frontend/qmouseinput_p.h76
35 files changed, 3953 insertions, 0 deletions
diff --git a/src/input/frontend/frontend.pri b/src/input/frontend/frontend.pri
new file mode 100644
index 000000000..4758d9c35
--- /dev/null
+++ b/src/input/frontend/frontend.pri
@@ -0,0 +1,39 @@
+HEADERS += \
+ $$PWD/qinputaspect.h \
+ $$PWD/qkeyboardcontroller.h \
+ $$PWD/qkeyboardcontroller_p.h \
+ $$PWD/qkeyboardinput.h \
+ $$PWD/qkeyboardinput_p.h \
+ $$PWD/qinputaspect_p.h \
+ $$PWD/q3dkeyevent.h \
+ $$PWD/qmousecontroller.h \
+ $$PWD/qmouseinput.h \
+ $$PWD/qmouseinput_p.h \
+ $$PWD/qmousecontroller_p.h \
+ $$PWD/q3dmouseevent.h \
+ $$PWD/qabstractinputdevice.h \
+ $$PWD/qinputdevicefactory_p.h \
+ $$PWD/qinputdeviceplugin.h \
+ $$PWD/qactioninput.h \
+ $$PWD/qaction.h \
+ $$PWD/qaxisinput.h \
+ $$PWD/qaxis.h \
+ $$PWD/qlogicaldevice.h
+
+SOURCES += \
+ $$PWD/qinputaspect.cpp \
+ $$PWD/qkeyboardcontroller.cpp \
+ $$PWD/qkeyboardinput.cpp \
+ $$PWD/q3dkeyevent.cpp \
+ $$PWD/qmouseinput.cpp \
+ $$PWD/qmousecontroller.cpp \
+ $$PWD/q3dmouseevent.cpp \
+ $$PWD/qinputdevicefactory.cpp \
+ $$PWD/qinputdeviceplugin.cpp \
+ $$PWD/qactioninput.cpp \
+ $$PWD/qaction.cpp \
+ $$PWD/qaxisinput.cpp \
+ $$PWD/qaxis.cpp \
+ $$PWD/qlogicaldevice.cpp
+
+INCLUDEPATH += $$PWD
diff --git a/src/input/frontend/q3dkeyevent.cpp b/src/input/frontend/q3dkeyevent.cpp
new file mode 100644
index 000000000..7c817967b
--- /dev/null
+++ b/src/input/frontend/q3dkeyevent.cpp
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "q3dkeyevent.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+//Qt6: Move this into a QtQmlGui module and merge it with QQuickKeyEvent
+
+/*!
+ \class Qt3DInput::Q3DKeyEvent
+ \inmodule Qt3DInput
+ \since 5.5
+*/
+
+/*!
+ \qmltype KeyEvent
+ \inqmlmodule Qt3D.Input
+ \instantiates Qt3DInput::Q3DKeyEvent
+ \since 5.5
+
+ The KeyEvent QML type cannot be directly created. Objects of this type
+ are used as signal parameters in KeyboardInput.
+*/
+
+Q3DKeyEvent::Q3DKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text, bool autorep, ushort count)
+ : QObject()
+ , m_event(type, key, modifiers, text, autorep, count)
+{
+ m_event.setAccepted(false);
+}
+
+Q3DKeyEvent::Q3DKeyEvent(const QKeyEvent &ke)
+ : QObject()
+ , m_event(ke)
+{
+ m_event.setAccepted(false);
+}
+
+/*!
+ \qmlproperty int Qt3D.Input::KeyEvent::key
+ \readonly
+
+ This property holds the code of the key that was pressed or released.
+
+ See \l [CPP] {Qt::Key}{Qt.Key} for the list of keyboard codes.
+
+ \sa {QtQuick::KeyEvent::key}{KeyEvent.key}
+*/
+
+/*!
+ \qmlproperty string Qt3D.Input::KeyEvent::text
+ \readonly
+
+ This property holds the Unicode text that the key generated. The text
+ returned can be an empty string in cases where modifier keys, such as
+ Shift, Control, Alt, and Meta, are being pressed or released. In such
+ cases \l key will contain a valid value.
+*/
+
+/*!
+ \qmlproperty int Qt3D.Input::KeyEvent::modifiers
+ \readonly
+
+ This property holds the keyboard modifier flags that existed immediately
+ before the event occurred.
+
+ \sa {QtQuick::KeyEvent::modifiers}{KeyEvent.modifiers}
+*/
+
+/*!
+ \qmlproperty bool Qt3D.Input::KeyEvent::isAutoRepeat
+ \readonly
+
+ Holds whether this event comes from an auto-repeating key.
+*/
+
+/*!
+ \qmlproperty int Qt3D.Input::KeyEvent::count
+ \readonly
+
+ Holds the number of keys involved in this event. If \l text is not empty,
+ this is simply the length of the string.
+*/
+
+/*!
+ \qmlproperty quint32 Qt3D.Input::KeyEvent::nativeScanCodei
+ \readonly
+
+ This property contains the native scan code of the key that was pressed.
+ It is passed through from QKeyEvent unchanged.
+
+ \sa QKeyEvent::nativeScanCode()
+*/
+
+/*!
+ \qmlproperty bool Qt3D.Input::KeyEvent::accepted
+
+ Setting \e accepted to \c true prevents the key event from being propagated
+ to the item's parent.
+
+ Generally, if the item acts on the key event then it should be accepted so
+ that ancestor items do not also respond to the same event.
+*/
+
+/*!
+ \qmlmethod bool Qt3D.Input::KeyEvent::matches(StandardKey key)
+
+ Returns \c true if the key event matches the given standard key; otherwise
+ returns \c false.
+
+ \sa QKeySequence::StandardKey
+*/
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/q3dkeyevent.h b/src/input/frontend/q3dkeyevent.h
new file mode 100644
index 000000000..e48071858
--- /dev/null
+++ b/src/input/frontend/q3dkeyevent.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_Q3DKEYEVENT_H
+#define QT3DINPUT_Q3DKEYEVENT_H
+
+#include <QObject>
+#include <QKeyEvent>
+#include <Qt3DInput/qt3dinput_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class Q3DKeyEventPrivate;
+class Q3DKeyEvent;
+
+typedef QSharedPointer<Q3DKeyEvent> Q3DKeyEventPtr;
+
+class QT3DINPUTSHARED_EXPORT Q3DKeyEvent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int key READ key CONSTANT)
+ Q_PROPERTY(QString text READ text CONSTANT)
+ Q_PROPERTY(int modifiers READ modifiers CONSTANT)
+ Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat CONSTANT)
+ Q_PROPERTY(int count READ count CONSTANT)
+ Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+
+public:
+ Q3DKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1);
+ Q3DKeyEvent(const QKeyEvent &ke);
+
+ inline int key() const { return m_event.key(); }
+ inline QString text() const { return m_event.text(); }
+ inline int modifiers() const { return m_event.modifiers(); }
+ inline bool isAutoRepeat() const { return m_event.isAutoRepeat(); }
+ inline int count() const { return m_event.count(); }
+ inline quint32 nativeScanCode() const { return m_event.nativeScanCode(); }
+ inline bool isAccepted() const { return m_event.isAccepted(); }
+ inline void setAccepted(bool accepted) { m_event.setAccepted(accepted); }
+ inline QEvent::Type type() const { return m_event.type(); }
+ Q_INVOKABLE bool matches(QKeySequence::StandardKey key_) const { return m_event.matches(key_); }
+
+private:
+ QKeyEvent m_event;
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_Q3DKEYEVENT_H
diff --git a/src/input/frontend/q3dmouseevent.cpp b/src/input/frontend/q3dmouseevent.cpp
new file mode 100644
index 000000000..8446a0a5a
--- /dev/null
+++ b/src/input/frontend/q3dmouseevent.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "q3dmouseevent.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+// Notes:
+// Maybe we should provide the world pos of the intersection
+// The distance t along the segment line at which the intersection occurs
+// Screen Pos / Mouse Pos / Viewport Pos
+// The intersection Ray
+// These can always be added in follow up commits once the input API takes shape
+
+/*!
+ * \class Qt3DInput::Q3DMouseEvent
+ * \inmodule Qt3DInput
+ *
+ * \brief The Qt3DCore::Q3DMouseEvent contains parameters that describe a mouse event.
+ *
+ * Mouse events occur when a mouse button is pressed and the ray
+ * traversing the view, originating from the mouse position intersects with one
+ * or more elements of the scene.
+ *
+ * \since 5.5
+ *
+ * \sa Q3DKeyEvent, Q3DWheelEvent, QMouseInput
+ *
+ */
+
+/*!
+ * \fn int Qt3DInput::Q3DMouseEvent::x() const
+ *
+ * Returns the x position of the mouse event.
+ */
+
+/*!
+ * \fn int Qt3DInput::Q3DMouseEvent::y() const
+ *
+ * Returns the y position of the mouse event.
+ */
+
+/*!
+ * \fn bool Qt3DInput::Q3DMouseEvent::isAccepted() const
+ *
+ * Returns whether the event was accepted.
+ */
+
+/*!
+ * \fn void Qt3DInput::Q3DMouseEvent::setAccepted(bool accepted)
+ *
+ * Sets the event as accepted if \a accepted is true.
+ *
+ * \note When an event is accepted, it will prevent further propagation to other
+ * listeners.
+ */
+
+/*!
+ * \fn QEvent::Type Qt3DInput::Q3DMouseEvent::type() const
+ *
+ * Returns the QEvent::Type of the event.
+ */
+
+/*!
+ * Constructs a new Q3DMouseEvent instance for the QMouseEvent \a e.
+ */
+Q3DMouseEvent::Q3DMouseEvent(const QMouseEvent &e)
+ : QObject()
+ , m_event(e)
+{
+}
+
+Q3DMouseEvent::~Q3DMouseEvent()
+{
+}
+
+/*!
+ * Returns the mouse button of the mouse event.
+ */
+Q3DMouseEvent::Buttons Q3DMouseEvent::button() const
+{
+ switch (m_event.button()) {
+ case Qt::MouseButton::LeftButton:
+ return Q3DMouseEvent::Buttons::LeftButton;
+ case Qt::MouseButton::RightButton:
+ return Q3DMouseEvent::Buttons::RightButton;
+ case Qt::MouseButton::MiddleButton:
+ return Q3DMouseEvent::Buttons::MiddleButton;
+ case Qt::MouseButton::BackButton:
+ return Q3DMouseEvent::Buttons::BackButton;
+ default:
+ return Q3DMouseEvent::Buttons::NoButton;
+ }
+}
+
+/*!
+ * Returns a bitfield to be used to check for mouse buttons that may be
+ * accompanying the mouse event.
+ */
+int Q3DMouseEvent::buttons() const
+{
+ return m_event.buttons();
+}
+
+/*!
+ * Returns the keyboard modifier that may be accompanying the mouse event.
+ */
+Q3DMouseEvent::Modifiers Q3DMouseEvent::modifier() const
+{
+ switch (m_event.modifiers()) {
+ case Qt::ShiftModifier:
+ return Q3DMouseEvent::Modifiers::ShiftModifier;
+ case Qt::ControlModifier:
+ return Q3DMouseEvent::Modifiers::ControlModifier;
+ case Qt::AltModifier:
+ return Q3DMouseEvent::Modifiers::AltModifier;
+ case Qt::MetaModifier:
+ return Q3DMouseEvent::Modifiers::MetaModifier;
+ case Qt::KeypadModifier:
+ return Q3DMouseEvent::Modifiers::KeypadModifier;
+ default:
+ return Q3DMouseEvent::Modifiers::NoModifier;
+ }
+}
+
+
+/*!
+ * \class Qt3DInput::Q3DWheelEvent
+ * \inmodule Qt3DInput
+ *
+ * \brief The Q3DWheelEvent class contains parameters that describe a mouse wheel event.
+ *
+ * Mouse wheel events occur when the mouse is rotated.
+ *
+ * \since 5.5
+ *
+ * \sa Q3DKeyEvent, Q3DMouseEvent, QMouseInput
+ *
+ */
+
+/*!
+ * \fn int Qt3DInput::Q3DWheelEvent::x() const
+ *
+ * Returns the x position of the mouse event.
+ */
+
+/*!
+ * \fn int Qt3DInput::Q3DWheelEvent::y() const
+ *
+ * Returns the x position of the mouse event.
+ */
+
+/*!
+ * \fn QPoint Qt3DInput::Q3DWheelEvent::angleDelta() const
+ *
+ * Returns the distance that the wheel is rotated, in eighths of a degree. A
+ * positive value indicates that the wheel was rotated forward (away from the
+ * user), a negative value indicates the wheel was rotated backward (toward the
+ * user).
+ */
+
+/*!
+ * \fn bool Qt3DInput::Q3DWheelEvent::isAccepted() const
+ *
+ * Returns whether the event was accepted.
+ */
+
+/*!
+ * \fn void Qt3DInput::Q3DWheelEvent::setAccepted(bool accepted)
+ *
+ * Sets the event as accepted if \a accepted is true.
+ *
+ * \note When an event is accepted, it will prevent further propagation to other
+ * listeners.
+ */
+
+/*!
+ * \fn QEvent::Type Qt3DInput::Q3DWheelEvent::type() const
+ *
+ * Returns the QEvent::Type of the event.
+ */
+
+/*!
+ * Constructs a new Q3DWheelEvent instance from the QWheelEvent \a e.
+ */
+Q3DWheelEvent::Q3DWheelEvent(const QWheelEvent &e)
+ : QObject()
+ , m_event(e)
+{
+}
+
+Q3DWheelEvent::~Q3DWheelEvent()
+{
+}
+
+/*!
+ * Returns a bitfield to be used to check for mouse buttons that may be
+ * accompanying the wheel event.
+ */
+int Q3DWheelEvent::buttons() const
+{
+ return m_event.buttons();
+}
+
+/*!
+ * Returns the keyboard modifier that may be accompanying the wheel event.
+ */
+Q3DWheelEvent::Modifiers Q3DWheelEvent::modifier() const
+{
+ switch (m_event.modifiers()) {
+ case Qt::ShiftModifier:
+ return Q3DWheelEvent::Modifiers::ShiftModifier;
+ case Qt::ControlModifier:
+ return Q3DWheelEvent::Modifiers::ControlModifier;
+ case Qt::AltModifier:
+ return Q3DWheelEvent::Modifiers::AltModifier;
+ case Qt::MetaModifier:
+ return Q3DWheelEvent::Modifiers::MetaModifier;
+ case Qt::KeypadModifier:
+ return Q3DWheelEvent::Modifiers::KeypadModifier;
+ default:
+ return Q3DWheelEvent::Modifiers::NoModifier;
+ }
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/q3dmouseevent.h b/src/input/frontend/q3dmouseevent.h
new file mode 100644
index 000000000..ef1a74bb0
--- /dev/null
+++ b/src/input/frontend/q3dmouseevent.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_Q3DMOUSEEVENT_H
+#define QT3DINPUT_Q3DMOUSEEVENT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <QObject>
+#include <QMouseEvent>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QT3DINPUTSHARED_EXPORT Q3DMouseEvent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int x READ x CONSTANT)
+ Q_PROPERTY(int y READ y CONSTANT)
+ Q_PROPERTY(bool wasHeld READ wasHeld CONSTANT)
+ Q_PROPERTY(Qt3DInput::Q3DMouseEvent::Buttons button READ button CONSTANT)
+ Q_PROPERTY(int buttons READ buttons CONSTANT)
+ Q_PROPERTY(Qt3DInput::Q3DMouseEvent::Modifiers modifier READ modifier CONSTANT)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+
+public:
+ enum Buttons {
+ LeftButton = Qt::MouseButton::LeftButton,
+ RightButton = Qt::MouseButton::RightButton,
+ MiddleButton = Qt::MouseButton::MiddleButton,
+ BackButton = Qt::MouseButton::BackButton,
+ NoButton = Qt::MouseButton::NoButton
+ };
+ Q_ENUM(Buttons)
+
+ enum Modifiers {
+ NoModifier = Qt::NoModifier,
+ ShiftModifier = Qt::ShiftModifier,
+ ControlModifier = Qt::ControlModifier,
+ AltModifier = Qt::AltModifier,
+ MetaModifier = Qt::MetaModifier,
+ KeypadModifier = Qt::KeypadModifier
+ };
+ Q_ENUM(Modifiers)
+
+ explicit Q3DMouseEvent(const QMouseEvent &e);
+ ~Q3DMouseEvent();
+
+ inline int x() const { return m_event.x(); }
+ inline int y() const { return m_event.y(); }
+ inline bool wasHeld() const { return static_cast<Qt::GestureType>(m_event.type()) == Qt::TapAndHoldGesture; }
+ Buttons button() const;
+ int buttons() const;
+ Modifiers modifier() const;
+
+ inline bool isAccepted() const { return m_event.isAccepted(); }
+ inline void setAccepted(bool accepted) { m_event.setAccepted(accepted); }
+ inline QEvent::Type type() const { return m_event.type(); }
+
+private:
+ QMouseEvent m_event;
+};
+
+typedef QSharedPointer<Q3DMouseEvent> Q3DMouseEventPtr;
+
+class QT3DINPUTSHARED_EXPORT Q3DWheelEvent : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int x READ x CONSTANT)
+ Q_PROPERTY(int y READ y CONSTANT)
+ Q_PROPERTY(QPoint angleDelta READ angleDelta CONSTANT)
+ Q_PROPERTY(int buttons READ buttons CONSTANT)
+ Q_PROPERTY(Qt3DInput::Q3DWheelEvent::Modifiers modifier READ modifier CONSTANT)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+
+public:
+ enum Buttons {
+ LeftButton = Qt::MouseButton::LeftButton,
+ RightButton = Qt::MouseButton::RightButton,
+ MiddleButton = Qt::MouseButton::MiddleButton,
+ BackButton = Qt::MouseButton::BackButton,
+ NoButton = Qt::MouseButton::NoButton
+ };
+ Q_ENUM(Buttons)
+
+ enum Modifiers {
+ NoModifier = Qt::NoModifier,
+ ShiftModifier = Qt::ShiftModifier,
+ ControlModifier = Qt::ControlModifier,
+ AltModifier = Qt::AltModifier,
+ MetaModifier = Qt::MetaModifier,
+ KeypadModifier = Qt::KeypadModifier
+ };
+ Q_ENUM(Modifiers)
+
+ explicit Q3DWheelEvent(const QWheelEvent &e);
+ ~Q3DWheelEvent();
+
+ inline int x() const { return m_event.x(); }
+ inline int y() const { return m_event.y(); }
+ inline QPoint angleDelta() const { return m_event.angleDelta(); }
+ int buttons() const;
+ Modifiers modifier() const;
+
+ inline bool isAccepted() const { return m_event.isAccepted(); }
+ inline void setAccepted(bool accepted) { m_event.setAccepted(accepted); }
+ inline QEvent::Type type() const { return m_event.type(); }
+
+private:
+ QWheelEvent m_event;
+};
+
+typedef QSharedPointer<Q3DWheelEvent> Q3DWheelEventPtr;
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DInput::Q3DMouseEvent*)
+Q_DECLARE_METATYPE(Qt3DInput::Q3DWheelEvent*)
+
+#endif // QT3DINPUT_Q3DMOUSEEVENT_H
diff --git a/src/input/frontend/qabstractinputdevice.h b/src/input/frontend/qabstractinputdevice.h
new file mode 100644
index 000000000..ea0231e93
--- /dev/null
+++ b/src/input/frontend/qabstractinputdevice.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QABSTRACTINPUTDEVICE
+#define QT3DINPUT_QABSTRACTINPUTDEVICE
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qaspectjob.h>
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QInputAspect;
+
+class QT3DINPUTSHARED_EXPORT QAbstractInputDevice
+{
+public:
+ virtual ~QAbstractInputDevice() {}
+ virtual void initialize(Qt3DInput::QInputAspect *aspect) = 0;
+ virtual QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time) = 0;
+};
+
+} // Qt3DInput
+
+Q_DECLARE_INTERFACE(Qt3DInput::QAbstractInputDevice, "Qt3DInput.QAbstractInputDevice/1.0")
+
+QT_END_NAMESPACE
+
+
+#endif // QT3DINPUT_QABSTRACTINPUTDEVICE
+
diff --git a/src/input/frontend/qaction.cpp b/src/input/frontend/qaction.cpp
new file mode 100644
index 000000000..f5e68932d
--- /dev/null
+++ b/src/input/frontend/qaction.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaction.h"
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DInput/qactioninput.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QActionPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QActionPrivate()
+ : Qt3DCore::QNodePrivate()
+ {}
+
+ QString m_name;
+ QVector<QActionInput *> m_inputs;
+};
+
+QAction::QAction(Qt3DCore::QNode *parent)
+ : Qt3DCore::QNode(*new QActionPrivate(), parent)
+{
+}
+
+QAction::~QAction()
+{
+ QNode::cleanup();
+}
+
+void QAction::setName(const QString &name)
+{
+ Q_D(QAction);
+ if (d->m_name != name) {
+ d->m_name = name;
+ emit nameChanged();
+ }
+}
+
+QString QAction::name() const
+{
+ Q_D(const QAction);
+ return d->m_name;
+}
+
+void QAction::addInput(QActionInput *input)
+{
+ Q_D(QAction);
+ if (!d->m_inputs.contains(input))
+ d->m_inputs.push_back(input);
+ // TO DO: needs to be completed to set the parent and send a proper notification
+}
+
+void QAction::removeInput(QActionInput *input)
+{
+ Q_D(QAction);
+ d->m_inputs.removeOne(input);
+ // TO DO: needs to be completed to set the parent and send a proper notification
+}
+
+QVector<QActionInput *> QAction::inputs() const
+{
+ Q_D(const QAction);
+ return d->m_inputs;
+}
+
+void QAction::copy(const Qt3DCore::QNode *ref)
+{
+ QNode::copy(ref);
+ const QAction *action = static_cast<const QAction *>(ref);
+ d_func()->m_name = action->d_func()->m_name;
+ Q_FOREACH (QActionInput *input, action->inputs())
+ d_func()->m_inputs.append(qobject_cast<QActionInput *>(QNode::clone(input)));
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qaction.h b/src/input/frontend/qaction.h
new file mode 100644
index 000000000..3eb18653c
--- /dev/null
+++ b/src/input/frontend/qaction.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QACTION_H
+#define QT3DINPUT_QACTION_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QActionPrivate;
+class QActionInput;
+
+class QT3DINPUTSHARED_EXPORT QAction : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+public:
+ explicit QAction(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QAction();
+
+ void setName(const QString &name);
+ QString name() const;
+
+ void addInput(QActionInput *input);
+ void removeInput(QActionInput *input);
+ QVector<QActionInput *> inputs() const;
+
+Q_SIGNALS:
+ void nameChanged();
+
+protected:
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QAction)
+ QT3D_CLONEABLE(QAction)
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QACTION_H
diff --git a/src/input/frontend/qactioninput.cpp b/src/input/frontend/qactioninput.cpp
new file mode 100644
index 000000000..5577e3e9c
--- /dev/null
+++ b/src/input/frontend/qactioninput.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+****************************************************************************/
+
+#include "qactioninput.h"
+#include <Qt3DCore/private/qnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QActionInputPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QActionInputPrivate()
+ : Qt3DCore::QNodePrivate()
+ , m_sourceDevice(Q_NULLPTR)
+ {}
+
+ QVector<int> m_keys;
+ QAbstractInputDevice *m_sourceDevice;
+};
+
+QActionInput::QActionInput(Qt3DCore::QNode *parent)
+ : Qt3DCore::QNode(*new QActionInputPrivate(), parent)
+{
+}
+
+QActionInput::~QActionInput()
+{
+ QNode::cleanup();
+}
+
+void QActionInput::addKey(int key)
+{
+ Q_D(QActionInput);
+ if (!d->m_keys.contains(key))
+ d->m_keys.push_back(key);
+ // TO DO: add notifications
+}
+
+void QActionInput::removeKey(int key)
+{
+ Q_D(QActionInput);
+ d->m_keys.removeOne(key);
+ // TO DO: add notifications
+}
+
+QVector<int> QActionInput::keys() const
+{
+ Q_D(const QActionInput);
+ return d->m_keys;
+}
+
+QBitArray QActionInput::keysBitArray() const
+{
+ // TO DO: complete
+ return QBitArray();
+}
+
+void QActionInput::setSourceDevice(QAbstractInputDevice *sourceDevice)
+{
+ Q_D(QActionInput);
+ if (d->m_sourceDevice != sourceDevice) {
+
+ // TO DO: check and set parent if needed once QAbstactInputDevice is a QNode subclass
+
+ d->m_sourceDevice = sourceDevice;
+ emit sourceDeviceChanged();
+ }
+}
+
+QAbstractInputDevice *QActionInput::sourceDevice() const
+{
+ Q_D(const QActionInput);
+ return d->m_sourceDevice;
+}
+
+void QActionInput::copy(const Qt3DCore::QNode *ref)
+{
+ QNode::copy(ref);
+ const QActionInput *input = static_cast<const QActionInput *>(ref);
+ // TO DO: Convert QAbstractInputDevice to a QNode
+ // d_func()->m_sourceDevice = qobject_cast<QAbstractInputDevice *>(QNode::clone(input->d_func()->m_sourceDevice));
+ d_func()->m_keys = input->d_func()->m_keys;
+
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qactioninput.h b/src/input/frontend/qactioninput.h
new file mode 100644
index 000000000..faa44d448
--- /dev/null
+++ b/src/input/frontend/qactioninput.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QACTIONINPUT_H
+#define QT3DINPUT_QACTIONINPUT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAbstractInputDevice;
+class QActionInputPrivate;
+
+class QT3DINPUTSHARED_EXPORT QActionInput : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QAbstractInputDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged)
+
+public:
+ explicit QActionInput(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QActionInput();
+
+ void addKey(int key);
+ void removeKey(int key);
+ QVector<int> keys() const;
+ QBitArray keysBitArray() const;
+
+ void setSourceDevice(QAbstractInputDevice *sourceDevice);
+ QAbstractInputDevice *sourceDevice() const;
+
+Q_SIGNALS:
+ void sourceDeviceChanged();
+
+protected:
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QActionInput)
+ QT3D_CLONEABLE(QActionInput)
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QACTIONINPUT_H
diff --git a/src/input/frontend/qaxis.cpp b/src/input/frontend/qaxis.cpp
new file mode 100644
index 000000000..df765d1ee
--- /dev/null
+++ b/src/input/frontend/qaxis.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+****************************************************************************/
+
+#include "qaxis.h"
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DInput/qaxisinput.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAxisPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QAxisPrivate()
+ : Qt3DCore::QNodePrivate()
+ {}
+
+ QString m_name;
+ QVector<QAxisInput *> m_inputs;
+};
+
+QAxis::QAxis(Qt3DCore::QNode *parent)
+ : Qt3DCore::QNode(*new QAxisPrivate(), parent)
+{
+}
+
+QAxis::~QAxis()
+{
+ QNode::cleanup();
+}
+
+void QAxis::setName(const QString &name)
+{
+ Q_D(QAxis);
+ if (d->m_name != name) {
+ d->m_name = name;
+ emit nameChanged();
+ }
+}
+
+QString QAxis::name() const
+{
+ Q_D(const QAxis);
+ return d->m_name;
+}
+
+void QAxis::addInput(QAxisInput *input)
+{
+ Q_D(QAxis);
+ if (!d->m_inputs.contains(input))
+ d->m_inputs.push_back(input);
+ // TO DO: needs to be completed to set the parent and send a proper notification
+}
+
+void QAxis::removeInput(QAxisInput *input)
+{
+ Q_D(QAxis);
+ d->m_inputs.removeOne(input);
+ // TO DO: needs to be completed to send a proper notification
+}
+
+QVector<QAxisInput *> QAxis::inputs() const
+{
+ Q_D(const QAxis);
+ return d->m_inputs;
+}
+
+void QAxis::copy(const Qt3DCore::QNode *ref)
+{
+ QNode::copy(ref);
+ const QAxis *axis = static_cast<const QAxis *>(ref);
+ d_func()->m_name = axis->d_func()->m_name;
+ Q_FOREACH (QAxisInput *input, axis->inputs())
+ d_func()->m_inputs.append(qobject_cast<QAxisInput *>(QNode::clone(input)));
+
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qaxis.h b/src/input/frontend/qaxis.h
new file mode 100644
index 000000000..ca6594e6e
--- /dev/null
+++ b/src/input/frontend/qaxis.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+****************************************************************************/
+
+#ifndef QT3DINPUT_QAXIS_H
+#define QT3DINPUT_QAXIS_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAxisPrivate;
+class QAxisInput;
+
+class QT3DINPUTSHARED_EXPORT QAxis : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+public:
+ explicit QAxis(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QAxis();
+
+ void setName(const QString &name);
+ QString name() const;
+
+ void addInput(QAxisInput *input);
+ void removeInput(QAxisInput *input);
+ QVector<QAxisInput *> inputs() const;
+
+Q_SIGNALS:
+ void nameChanged();
+
+protected:
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QAxis)
+ QT3D_CLONEABLE(QAxis)
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QAXIS_H
diff --git a/src/input/frontend/qaxisinput.cpp b/src/input/frontend/qaxisinput.cpp
new file mode 100644
index 000000000..5b3989fbf
--- /dev/null
+++ b/src/input/frontend/qaxisinput.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaxisinput.h"
+#include <Qt3DCore/private/qnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAxisInputPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QAxisInputPrivate()
+ : Qt3DCore::QNodePrivate()
+ , m_sourceDevice(Q_NULLPTR)
+ , m_scale(0.0f)
+ , m_axis(-1)
+ {}
+
+ QVector<int> m_keys;
+ QAbstractInputDevice *m_sourceDevice;
+ float m_scale;
+ int m_axis;
+};
+
+
+QAxisInput::QAxisInput(Qt3DCore::QNode *parent)
+ : QNode(*new QAxisInputPrivate(), parent)
+{
+}
+
+QAxisInput::~QAxisInput()
+{
+ QNode::cleanup();
+}
+
+void QAxisInput::setSourceDevice(QAbstractInputDevice *sourceDevice)
+{
+ Q_D(QAxisInput);
+ if (d->m_sourceDevice != sourceDevice) {
+
+ // TO DO: check and set parent if needed once QAbstactInputDevice is a QNode subclass
+
+ d->m_sourceDevice = sourceDevice;
+ emit sourceDeviceChanged();
+ }
+}
+
+QAbstractInputDevice *QAxisInput::sourceDevice() const
+{
+ Q_D(const QAxisInput);
+ return d->m_sourceDevice;
+}
+
+void QAxisInput::setScale(float scale)
+{
+ Q_D(QAxisInput);
+ if (d->m_scale != scale) {
+ d->m_scale = scale;
+ emit scaleChanged();
+ }
+}
+
+float QAxisInput::scale() const
+{
+ Q_D(const QAxisInput);
+ return d->m_scale;
+}
+
+void QAxisInput::setAxis(int axis)
+{
+ Q_D(QAxisInput);
+ if (d->m_axis != axis) {
+ d->m_axis = axis;
+ emit axisChanged();
+ }
+}
+
+int QAxisInput::axis() const
+{
+ Q_D(const QAxisInput);
+ return d->m_axis;
+}
+
+void QAxisInput::addKey(int key)
+{
+ Q_D(QAxisInput);
+ if (!d->m_keys.contains(key))
+ d->m_keys.push_back(key);
+ // TO DO: add notifications
+}
+
+void QAxisInput::removeKey(int key)
+{
+ Q_D(QAxisInput);
+ if (!d->m_keys.contains(key))
+ d->m_keys.removeOne(key);
+ // TO DO: add notifications
+}
+
+QVector<int> QAxisInput::keys() const
+{
+ Q_D(const QAxisInput);
+ return d->m_keys;
+}
+
+QBitArray QAxisInput::keysBitArray() const
+{
+ return QBitArray();
+ // TO DO: complete
+}
+
+void QAxisInput::copy(const Qt3DCore::QNode *ref)
+{
+ QNode::copy(ref);
+ const QAxisInput *input = static_cast<const QAxisInput *>(ref);
+ // TO DO: Convert QAbstractInputDevice to a QNode
+ // d_func()->m_sourceDevice = qobject_cast<QAbstractInputDevice *>(QNode::clone(input->d_func()->m_sourceDevice));
+ d_func()->m_keys = input->d_func()->m_keys;
+ d_func()->m_scale = input->d_func()->m_scale;
+ d_func()->m_axis = input->d_func()->m_axis;
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qaxisinput.h b/src/input/frontend/qaxisinput.h
new file mode 100644
index 000000000..40284edb7
--- /dev/null
+++ b/src/input/frontend/qaxisinput.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QAXISINPUT_H
+#define QT3DINPUT_QAXISINPUT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+#include <QVector3D>
+#include <QBitArray>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAbstractInputDevice;
+class QAxisInputPrivate;
+
+class QAxisInput : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QAbstractInputDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged)
+ Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(int axis READ axis WRITE setAxis NOTIFY axisChanged)
+
+public:
+ explicit QAxisInput(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QAxisInput();
+
+ void setSourceDevice(QAbstractInputDevice *sourceDevice);
+ QAbstractInputDevice *sourceDevice() const;
+
+ void setScale(float scale);
+ float scale() const;
+
+ void setAxis(int axis);
+ int axis() const;
+
+ void addKey(int key);
+ void removeKey(int key);
+ QVector<int> keys() const;
+ QBitArray keysBitArray() const;
+
+Q_SIGNALS:
+ void sourceDeviceChanged();
+ void scaleChanged();
+ void axisChanged();
+
+protected:
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QAxisInput)
+ QT3D_CLONEABLE(QAxisInput)
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QQT3DINPUT_AXISINPUT_H
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
new file mode 100644
index 000000000..ee6f851a6
--- /dev/null
+++ b/src/input/frontend/qinputaspect.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qinputaspect.h"
+#include "qinputaspect_p.h"
+#include "cameracontroller_p.h"
+#include "inputhandler_p.h"
+#include "keyboardcontroller_p.h"
+#include "keyboardinput_p.h"
+#include "mousecontroller_p.h"
+#include "mouseinput_p.h"
+#include <Qt3DCore/qaspectfactory.h>
+#include <Qt3DCore/qnodevisitor.h>
+#include <Qt3DCore/qscenepropertychange.h>
+#include <Qt3DInput/qkeyboardcontroller.h>
+#include <Qt3DInput/qkeyboardinput.h>
+#include <Qt3DInput/qmousecontroller.h>
+#include <Qt3DInput/qmouseinput.h>
+#include <Qt3DInput/qabstractinputdevice.h>
+#include <Qt3DInput/private/qinputdevicefactory_p.h>
+#include <Qt3DCore/qservicelocator.h>
+#include <Qt3DCore/qeventfilterservice.h>
+#include <QDir>
+#include <QLibrary>
+#include <QLibraryInfo>
+#include <QPluginLoader>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+namespace Qt3DInput {
+
+/*!
+ \class Qt3DInput::QInputAspectPrivate
+ \internal
+*/
+QInputAspectPrivate::QInputAspectPrivate()
+ : QAbstractAspectPrivate()
+ , m_inputHandler(new Input::InputHandler())
+ , m_cameraController(new Input::CameraController())
+{
+}
+
+/*!
+ \class Qt3DInput::QInputAspect
+ \inmodule Qt3DInput
+ \since 5.5
+*/
+
+QInputAspect::QInputAspect(QObject *parent)
+ : QAbstractAspect(*new QInputAspectPrivate, parent)
+{
+ registerBackendType<QKeyboardController>(QBackendNodeFunctorPtr(new Input::KeyboardControllerFunctor(d_func()->m_inputHandler.data())));
+ registerBackendType<QKeyboardInput>(QBackendNodeFunctorPtr(new Input::KeyboardInputFunctor(d_func()->m_inputHandler.data())));
+ registerBackendType<QMouseController>(QBackendNodeFunctorPtr(new Input::MouseControllerFunctor(d_func()->m_inputHandler.data())));
+ registerBackendType<QMouseInput>(QBackendNodeFunctorPtr(new Input::MouseInputFunctor(d_func()->m_inputHandler.data())));
+
+ loadInputDevicePlugins();
+}
+
+void QInputAspect::loadInputDevicePlugins()
+{
+ Q_D(QInputAspect);
+ QStringList keys = QInputDeviceFactory::keys();
+ Q_FOREACH (QString key, keys) {
+ Qt3DInput::QAbstractInputDevice *inputDevice = QInputDeviceFactory::create(key, QStringList());
+ if (inputDevice != Q_NULLPTR) {
+ d->m_inputDevices.push_back(inputDevice);
+ inputDevice->initialize(this);
+ }
+ }
+}
+
+Qt3DCore::QCamera *QInputAspect::camera() const
+{
+ Q_D(const QInputAspect);
+ return d->m_cameraController->camera();
+}
+
+void QInputAspect::setCamera(Qt3DCore::QCamera *camera)
+{
+ Q_D(QInputAspect);
+ d->m_cameraController->setCamera(camera);
+}
+
+QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
+{
+ Q_UNUSED(time);
+ Q_D(QInputAspect);
+ QVector<QAspectJobPtr> jobs;
+
+ jobs.append(d->m_inputHandler->keyboardJobs());
+ jobs.append(d->m_inputHandler->mouseJobs());
+
+ Q_FOREACH (QAbstractInputDevice *inputDevice, d->m_inputDevices)
+ jobs += inputDevice->jobsToExecute(time);
+
+ return jobs;
+}
+
+void QInputAspect::sceneNodeAdded(Qt3DCore::QSceneChangePtr &e)
+{
+ QScenePropertyChangePtr propertyChange = e.staticCast<QScenePropertyChange>();
+ QNodePtr nodePtr = propertyChange->value().value<QNodePtr>();
+ QNode *n = nodePtr.data();
+ QNodeVisitor visitor;
+ visitor.traverse(n, this, &QInputAspect::visitNode);
+}
+
+void QInputAspect::sceneNodeRemoved(Qt3DCore::QSceneChangePtr &e)
+{
+ QScenePropertyChangePtr propertyChange = e.staticCast<QScenePropertyChange>();
+ QNodePtr nodePtr = propertyChange->value().value<QNodePtr>();
+ QNode *n = nodePtr.data();
+ QAbstractAspect::clearBackendNode(n);
+}
+
+void QInputAspect::setRootEntity(Qt3DCore::QEntity *rootObject)
+{
+ QNodeVisitor visitor;
+ visitor.traverse(rootObject, this, &QInputAspect::visitNode);
+}
+
+void QInputAspect::onInitialize(const QVariantMap &)
+{
+ Q_D(QInputAspect);
+ Qt3DCore::QEventFilterService *eventService = services()->eventFilterService();
+ eventService->registerEventFilter(d->m_cameraController.data(), 128);
+ d->m_inputHandler->registerEventFilters(eventService);
+}
+
+void QInputAspect::onStartup()
+{
+}
+
+void QInputAspect::onShutdown()
+{
+}
+
+void QInputAspect::onCleanup()
+{
+ Q_D(QInputAspect);
+ // At this point it is too late to call removeEventFilter as the eventSource (Window)
+ // may already be destroyed
+ d->m_inputHandler.reset(Q_NULLPTR);
+}
+
+void QInputAspect::visitNode(Qt3DCore::QNode *node)
+{
+ QAbstractAspect::createBackendNode(node);
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+QT3D_REGISTER_NAMESPACED_ASPECT("input", QT_PREPEND_NAMESPACE(Qt3DInput), QInputAspect)
diff --git a/src/input/frontend/qinputaspect.h b/src/input/frontend/qinputaspect.h
new file mode 100644
index 000000000..41d5ae82d
--- /dev/null
+++ b/src/input/frontend/qinputaspect.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QINPUTASPECT_H
+#define QT3DINPUT_QINPUTASPECT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qabstractaspect.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QCamera;
+}
+
+namespace Qt3DInput {
+
+class QInputAspectPrivate;
+
+class QT3DINPUTSHARED_EXPORT QInputAspect : public Qt3DCore::QAbstractAspect
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DCore::QCamera* camera READ camera WRITE setCamera)
+public:
+ explicit QInputAspect(QObject *parent = 0);
+
+ Qt3DCore::QCamera *camera() const;
+
+public Q_SLOTS:
+ void setCamera(Qt3DCore::QCamera *camera);
+
+public:
+ QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time) Q_DECL_OVERRIDE;
+
+ void sceneNodeAdded(Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
+ void sceneNodeRemoved(Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
+
+private:
+ void setRootEntity(Qt3DCore::QEntity *rootObject) Q_DECL_OVERRIDE;
+ void onInitialize(const QVariantMap &data) Q_DECL_OVERRIDE;
+ void onStartup() Q_DECL_OVERRIDE;
+ void onShutdown() Q_DECL_OVERRIDE;
+ void onCleanup() Q_DECL_OVERRIDE;
+
+ void visitNode(Qt3DCore::QNode *node);
+ void loadInputDevicePlugins();
+
+ Q_DECLARE_PRIVATE(QInputAspect)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QINPUTASPECT_H
diff --git a/src/input/frontend/qinputaspect_p.h b/src/input/frontend/qinputaspect_p.h
new file mode 100644
index 000000000..3f2f96155
--- /dev/null
+++ b/src/input/frontend/qinputaspect_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QINPUTASPECT_P_H
+#define QT3DINPUT_QINPUTASPECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qabstractaspect_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QInputAspect;
+class QAbstractInputDevice;
+
+namespace Input {
+class CameraController;
+class InputHandler;
+}
+
+class QInputAspectPrivate : public Qt3DCore::QAbstractAspectPrivate
+{
+public:
+ QInputAspectPrivate();
+
+ Q_DECLARE_PUBLIC(QInputAspect)
+ QScopedPointer<Input::InputHandler> m_inputHandler;
+ QScopedPointer<Input::CameraController> m_cameraController;
+ QVector<Qt3DInput::QAbstractInputDevice *> m_inputDevices;
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QINPUTASPECT_P_H
diff --git a/src/input/frontend/qinputdevicefactory.cpp b/src/input/frontend/qinputdevicefactory.cpp
new file mode 100644
index 000000000..e5896b4ff
--- /dev/null
+++ b/src/input/frontend/qinputdevicefactory.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qinputdevicefactory_p.h"
+#include <Qt3DInput/qabstractinputdevice.h>
+#include <Qt3DInput/qinputdeviceplugin.h>
+#include <QtCore/private/qfactoryloader_p.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QInputDevice_iid, QLatin1String("/inputdevices"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QInputDevice_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QStringList QInputDeviceFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QStringLiteral(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QAbstractInputDevice *QInputDeviceFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ if (QAbstractInputDevice *ret = qLoadPlugin1<QAbstractInputDevice, QInputDevicePlugin>(directLoader(), name, args))
+ return ret;
+ }
+ if (QAbstractInputDevice *ret = qLoadPlugin1<QAbstractInputDevice, QInputDevicePlugin>(loader(), name, args))
+ return ret;
+#endif
+ return Q_NULLPTR;
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
diff --git a/src/input/frontend/qinputdevicefactory_p.h b/src/input/frontend/qinputdevicefactory_p.h
new file mode 100644
index 000000000..62eef0d18
--- /dev/null
+++ b/src/input/frontend/qinputdevicefactory_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QINPUTDEVICEFACTORY_P_H
+#define QT3DINPUT_QINPUTDEVICEFACTORY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <QtCore/QStringList>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAbstractInputDevice;
+
+class QInputDeviceFactory
+{
+public:
+ static QStringList keys(const QString &pluginPath = QString());
+ static QAbstractInputDevice *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QINPUTDEVICEFACTORY_P_H
diff --git a/src/input/frontend/qinputdeviceplugin.cpp b/src/input/frontend/qinputdeviceplugin.cpp
new file mode 100644
index 000000000..7afdb848e
--- /dev/null
+++ b/src/input/frontend/qinputdeviceplugin.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qinputdeviceplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+QInputDevicePlugin::QInputDevicePlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QInputDevicePlugin::~QInputDevicePlugin()
+{
+}
+
+QAbstractInputDevice *QInputDevicePlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(paramList)
+ return Q_NULLPTR;
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qinputdeviceplugin.h b/src/input/frontend/qinputdeviceplugin.h
new file mode 100644
index 000000000..ea73eb312
--- /dev/null
+++ b/src/input/frontend/qinputdeviceplugin.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QINPUTDEVICEPLUGIN_H
+#define QT3DINPUT_QINPUTDEVICEPLUGIN_H
+
+#include <QtCore/QObject>
+#include <QtCore/QtPlugin>
+#include <QtCore/QFactoryInterface>
+
+#include <Qt3DInput/qt3dinput_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+#define QInputDevice_iid "org.qt-project.Qt3DInput.QAbstractInputDevice 5.6"
+
+class QAbstractInputDevice;
+
+class QT3DINPUTSHARED_EXPORT QInputDevicePlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QInputDevicePlugin(QObject *parent = Q_NULLPTR);
+ ~QInputDevicePlugin();
+
+ virtual QAbstractInputDevice *create(const QString &key, const QStringList &paramList);
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QINPUTDEVICEPLUGIN_H
diff --git a/src/input/frontend/qkeyboardcontroller.cpp b/src/input/frontend/qkeyboardcontroller.cpp
new file mode 100644
index 000000000..17345c6c2
--- /dev/null
+++ b/src/input/frontend/qkeyboardcontroller.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qkeyboardcontroller.h"
+#include "qkeyboardcontroller_p.h"
+#include "qkeyboardinput.h"
+#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/qbackendscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+namespace Qt3DInput {
+
+/*!
+ \class Qt3DInput::QKeyboardControllerPrivate
+ \internal
+*/
+QKeyboardControllerPrivate::QKeyboardControllerPrivate()
+ : QNodePrivate()
+{
+}
+
+/*!
+ \class Qt3DInput::QKeyboardController
+ \inmodule Qt3DInput
+ \since 5.5
+*/
+
+/*!
+ \qmltype KeyboardController
+ \inqmlmodule Qt3D.Input
+ \since 5.5
+ \instantiates Qt3DInput::QKeyboardController
+ \inherits Node
+*/
+
+QKeyboardController::QKeyboardController(QNode *parent)
+ : QNode(*new QKeyboardControllerPrivate, parent)
+{
+}
+
+QKeyboardController::~QKeyboardController()
+{
+ QNode::cleanup();
+}
+
+/*!
+ \qmlproperty KeyboardInput Qt3D.Input::KeyboardController::activeInput
+ \readonly
+*/
+QKeyboardInput *QKeyboardController::activeInput() const
+{
+ Q_D(const QKeyboardController);
+ return d->m_activeInput;
+}
+
+/*! \internal */
+QKeyboardController::QKeyboardController(QKeyboardControllerPrivate &dd, QNode *parent)
+ : QNode(dd, parent)
+{
+}
+
+void QKeyboardController::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QKeyboardController);
+ QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
+ if (e->type() == NodeUpdated && e->propertyName() == QByteArrayLiteral("activeInput")) {
+ QNodeId activeInputId = e->value().value<QNodeId>();
+ setActiveInput(qobject_cast<QKeyboardInput *>(d->scene()->lookupNode(activeInputId)));
+ }
+}
+
+void QKeyboardController::setActiveInput(QKeyboardInput *activeInput)
+{
+ Q_D(QKeyboardController);
+ if (d->m_activeInput != activeInput) {
+ d->m_activeInput = activeInput;
+ emit activeInputChanged();
+ }
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qkeyboardcontroller.h b/src/input/frontend/qkeyboardcontroller.h
new file mode 100644
index 000000000..1f57b856c
--- /dev/null
+++ b/src/input/frontend/qkeyboardcontroller.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_H
+#define QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QKeyboardControllerPrivate;
+class QKeyboardInput;
+
+class QT3DINPUTSHARED_EXPORT QKeyboardController : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QKeyboardInput *activeInput READ activeInput NOTIFY activeInputChanged)
+
+public:
+ explicit QKeyboardController(QNode *parent = 0);
+ ~QKeyboardController();
+
+ QKeyboardInput *activeInput() const;
+
+protected:
+ QKeyboardController(QKeyboardControllerPrivate &dd, QNode *parent = 0);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void activeInputChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QKeyboardController)
+ QT3D_CLONEABLE(QKeyboardController)
+ void setActiveInput(QKeyboardInput *activeInput);
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_H
diff --git a/src/input/frontend/qkeyboardcontroller_p.h b/src/input/frontend/qkeyboardcontroller_p.h
new file mode 100644
index 000000000..8d1ce7bb1
--- /dev/null
+++ b/src/input/frontend/qkeyboardcontroller_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_P_H
+#define QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QKeyboardController;
+class QKeyboardInput;
+
+class QKeyboardControllerPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QKeyboardControllerPrivate();
+
+ Q_DECLARE_PUBLIC(QKeyboardController)
+ QKeyboardInput *m_activeInput;
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_INPUT_QKEYBOARDCONTROLLER_P_H
diff --git a/src/input/frontend/qkeyboardinput.cpp b/src/input/frontend/qkeyboardinput.cpp
new file mode 100644
index 000000000..a36f306ea
--- /dev/null
+++ b/src/input/frontend/qkeyboardinput.cpp
@@ -0,0 +1,414 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qkeyboardinput.h"
+#include "qkeyboardinput_p.h"
+#include "qkeyboardcontroller.h"
+#include <Qt3DCore/qbackendscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+namespace Qt3DInput {
+
+/*!
+ \class Qt3DInput::QKeyboardInputPrivate
+ \internal
+*/
+QKeyboardInputPrivate::QKeyboardInputPrivate()
+ : QComponentPrivate()
+ , m_controller(Q_NULLPTR)
+ , m_focus(false)
+{
+ m_shareable = false;
+}
+
+/*!
+ \class Qt3DInput::QKeyboardInput
+ \inmodule Qt3DInput
+ \since 5.5
+*/
+
+/*!
+ \qmltype KeyboardInput
+ \inqmlmodule Qt3D.Input
+ \instantiates Qt3DInput::QKeyboardInput
+ \inherits Component3D
+ \since 5.5
+*/
+
+/*!
+ Constructs a new QKeyboardInput instance with parent \a parent.
+ */
+QKeyboardInput::QKeyboardInput(QNode *parent)
+ : QComponent(*new QKeyboardInputPrivate, parent)
+{
+}
+
+QKeyboardInput::~QKeyboardInput()
+{
+ QNode::cleanup();
+}
+
+/*! \internal */
+QKeyboardInput::QKeyboardInput(QKeyboardInputPrivate &dd, QNode *parent)
+ : QComponent(dd, parent)
+{
+}
+
+void QKeyboardInput::copy(const QNode *ref)
+{
+ QComponent::copy(ref);
+ const QKeyboardInput *input = static_cast<const QKeyboardInput *>(ref);
+
+ // TO DO: We may want to store the controller id and only send a clone when we are the parent
+ // of the controller
+ if (input->d_func()->m_controller != Q_NULLPTR && input->d_func()->m_controller->parent() == ref)
+ setController(qobject_cast<QKeyboardController *>(QNode::clone(input->d_func()->m_controller)));
+}
+
+// SigMap and the sigMap table are taken from QQ2 QQuickKeysAttached
+struct SigMap {
+ int key;
+ const char *sig;
+};
+
+const SigMap sigMap[] = {
+ { Qt::Key_Left, "leftPressed" },
+ { Qt::Key_Right, "rightPressed" },
+ { Qt::Key_Up, "upPressed" },
+ { Qt::Key_Down, "downPressed" },
+ { Qt::Key_Tab, "tabPressed" },
+ { Qt::Key_Backtab, "backtabPressed" },
+ { Qt::Key_Asterisk, "asteriskPressed" },
+ { Qt::Key_NumberSign, "numberSignPressed" },
+ { Qt::Key_Escape, "escapePressed" },
+ { Qt::Key_Return, "returnPressed" },
+ { Qt::Key_Enter, "enterPressed" },
+ { Qt::Key_Delete, "deletePressed" },
+ { Qt::Key_Space, "spacePressed" },
+ { Qt::Key_Back, "backPressed" },
+ { Qt::Key_Cancel, "cancelPressed" },
+ { Qt::Key_Select, "selectPressed" },
+ { Qt::Key_Yes, "yesPressed" },
+ { Qt::Key_No, "noPressed" },
+ { Qt::Key_Context1, "context1Pressed" },
+ { Qt::Key_Context2, "context2Pressed" },
+ { Qt::Key_Context3, "context3Pressed" },
+ { Qt::Key_Context4, "context4Pressed" },
+ { Qt::Key_Call, "callPressed" },
+ { Qt::Key_Hangup, "hangupPressed" },
+ { Qt::Key_Flip, "flipPressed" },
+ { Qt::Key_Menu, "menuPressed" },
+ { Qt::Key_VolumeUp, "volumeUpPressed" },
+ { Qt::Key_VolumeDown, "volumeDownPressed" },
+ { 0, 0 }
+};
+
+const QByteArray keyToSignal(int key)
+{
+ QByteArray keySignal;
+ if (key >= Qt::Key_0 && key <= Qt::Key_9) {
+ keySignal = "digit0Pressed";
+ keySignal[5] = '0' + (key - Qt::Key_0);
+ } else {
+ int i = 0;
+ while (sigMap[i].key && sigMap[i].key != key)
+ ++i;
+ keySignal = sigMap[i].sig;
+ }
+ return keySignal;
+}
+
+void QKeyboardInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
+ if (e->type() == NodeUpdated) {
+ if (e->propertyName() == QByteArrayLiteral("focus")) {
+ bool block = blockNotifications(true);
+ setFocus(e->value().toBool());
+ blockNotifications(block);
+ } else if (e->propertyName() == QByteArrayLiteral("event")) {
+ Q3DKeyEventPtr ev = e->value().value<Q3DKeyEventPtr>();
+ keyEvent(ev.data());
+ }
+ }
+}
+
+void QKeyboardInput::keyEvent(Q3DKeyEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ emit pressed(event);
+
+ QByteArray keySignal = keyToSignal(event->key());
+ if (!keySignal.isEmpty()) {
+ keySignal += "(Qt3DInput::Q3DKeyEvent*)";
+ // TO DO: Finding if the signal is connected to anything before doing the invocation
+ // could be an improvement
+ // That's what QQ2 does but since it accesses QML private classes to do so, that may not be
+ // applicable in our case
+ int idx = QKeyboardInput::staticMetaObject.indexOfSignal(keySignal);
+ metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(Q3DKeyEvent *, event));
+ }
+ } else if (event->type() == QEvent::KeyRelease) {
+ emit released(event);
+ }
+}
+
+/*!
+ \qmlproperty KeyboardController Qt3D.Input::KeyboardInput::controller
+*/
+
+/*!
+ Sets the keyboard controller to \a controller. Without a valid controller,
+ the QKeyboardInput won't receive any event.
+ */
+void QKeyboardInput::setController(QKeyboardController *controller)
+{
+ Q_D(QKeyboardInput);
+ if (d->m_controller != controller) {
+
+ if (controller && !controller->parent())
+ controller->setParent(this);
+
+ d->m_controller = controller;
+ emit controllerChanged();
+ }
+}
+
+/*!
+ Returns the current keyboard controller.
+ */
+QKeyboardController *QKeyboardInput::controller() const
+{
+ Q_D(const QKeyboardInput);
+ return d->m_controller;
+}
+
+/*!
+ \qmlproperty bool Qt3D.Input::KeyboardInput::focus
+*/
+
+/*!
+ Returns the current focus.
+ */
+bool QKeyboardInput::focus() const
+{
+ Q_D(const QKeyboardInput);
+ return d->m_focus;
+}
+
+/*!
+ Sets the focus to \a focus. If focus is not currently set to \c true,
+ this component will receive keyboard focus.
+ */
+void QKeyboardInput::setFocus(bool focus)
+{
+ Q_D(QKeyboardInput);
+ if (d->m_focus != focus) {
+ d->m_focus = focus;
+ emit focusChanged();
+ }
+}
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit0Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit1Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit2Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit3Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit4Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit5Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit6Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit7Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit8Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::digit9Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::leftPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::rightPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::upPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::downPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::tabPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::backtabPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::asteriskPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::numberSignPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::backtabPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::escapePressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::returnPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::enterPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::deletePressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::spacePressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::backPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::cancelPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::selectPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::yesPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::noPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::context1Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::context2Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::context3Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::context4Pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::callPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::hangupPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::flipPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::menuPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::volumeUpPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::volumeDownPressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::pressed(KeyEvent event)
+*/
+
+/*!
+ \qmlsignal Qt3D.Input::KeyboardInput::released(KeyEvent event)
+*/
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qkeyboardinput.h b/src/input/frontend/qkeyboardinput.h
new file mode 100644
index 000000000..592361a4a
--- /dev/null
+++ b/src/input/frontend/qkeyboardinput.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_INPUT_QKEYBOARDINPUT_H
+#define QT3DINPUT_INPUT_QKEYBOARDINPUT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DInput/q3dkeyevent.h>
+#include <Qt3DCore/qcomponent.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QKeyboardController;
+class QKeyboardInputPrivate;
+
+class QT3DINPUTSHARED_EXPORT QKeyboardInput : public Qt3DCore::QComponent
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QKeyboardController *controller READ controller WRITE setController NOTIFY controllerChanged)
+ Q_PROPERTY(bool focus READ focus WRITE setFocus NOTIFY focusChanged)
+public:
+ explicit QKeyboardInput(QNode *parent = 0);
+ ~QKeyboardInput();
+
+ void setController(QKeyboardController *controller);
+ QKeyboardController *controller() const;
+ bool focus() const;
+ void setFocus(bool focus);
+
+Q_SIGNALS:
+ void controllerChanged();
+ void focusChanged();
+
+ void digit0Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit1Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit2Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit3Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit4Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit5Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit6Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit7Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit8Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void digit9Pressed(Qt3DInput::Q3DKeyEvent *event);
+
+ void leftPressed(Qt3DInput::Q3DKeyEvent *event);
+ void rightPressed(Qt3DInput::Q3DKeyEvent *event);
+ void upPressed(Qt3DInput::Q3DKeyEvent *event);
+ void downPressed(Qt3DInput::Q3DKeyEvent *event);
+ void tabPressed(Qt3DInput::Q3DKeyEvent *event);
+ void backtabPressed(Qt3DInput::Q3DKeyEvent *event);
+
+ void asteriskPressed(Qt3DInput::Q3DKeyEvent *event);
+ void numberSignPressed(Qt3DInput::Q3DKeyEvent *event);
+ void escapePressed(Qt3DInput::Q3DKeyEvent *event);
+ void returnPressed(Qt3DInput::Q3DKeyEvent *event);
+ void enterPressed(Qt3DInput::Q3DKeyEvent *event);
+ void deletePressed(Qt3DInput::Q3DKeyEvent *event);
+ void spacePressed(Qt3DInput::Q3DKeyEvent *event);
+ void backPressed(Qt3DInput::Q3DKeyEvent *event);
+ void cancelPressed(Qt3DInput::Q3DKeyEvent *event);
+ void selectPressed(Qt3DInput::Q3DKeyEvent *event);
+ void yesPressed(Qt3DInput::Q3DKeyEvent *event);
+ void noPressed(Qt3DInput::Q3DKeyEvent *event);
+ void context1Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void context2Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void context3Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void context4Pressed(Qt3DInput::Q3DKeyEvent *event);
+ void callPressed(Qt3DInput::Q3DKeyEvent *event);
+ void hangupPressed(Qt3DInput::Q3DKeyEvent *event);
+ void flipPressed(Qt3DInput::Q3DKeyEvent *event);
+ void menuPressed(Qt3DInput::Q3DKeyEvent *event);
+ void volumeUpPressed(Qt3DInput::Q3DKeyEvent *event);
+ void volumeDownPressed(Qt3DInput::Q3DKeyEvent *event);
+
+ void pressed(Qt3DInput::Q3DKeyEvent *event);
+ void released(Qt3DInput::Q3DKeyEvent *event);
+
+protected:
+ QKeyboardInput(QKeyboardInputPrivate &dd, QNode *parent = 0);
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
+ void keyEvent(Q3DKeyEvent *event);
+
+private:
+ Q_DECLARE_PRIVATE(QKeyboardInput)
+ QT3D_CLONEABLE(QKeyboardInput)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_INPUT_QKEYBOARDINPUT_H
diff --git a/src/input/frontend/qkeyboardinput_p.h b/src/input/frontend/qkeyboardinput_p.h
new file mode 100644
index 000000000..7ee0560b6
--- /dev/null
+++ b/src/input/frontend/qkeyboardinput_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
+#define QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qcomponent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QKeyboardInput;
+class QKeyboardController;
+
+class QKeyboardInputPrivate : public Qt3DCore::QComponentPrivate
+{
+public:
+ QKeyboardInputPrivate();
+
+ Q_DECLARE_PUBLIC(QKeyboardInput)
+ QKeyboardController *m_controller;
+ bool m_focus;
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
diff --git a/src/input/frontend/qlogicaldevice.cpp b/src/input/frontend/qlogicaldevice.cpp
new file mode 100644
index 000000000..939583b44
--- /dev/null
+++ b/src/input/frontend/qlogicaldevice.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlogicaldevice.h"
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DInput/qaction.h>
+#include <Qt3DInput/qaxis.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QLogicalDevicePrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QLogicalDevicePrivate()
+ : Qt3DCore::QNodePrivate()
+ {}
+
+ QVector<QAction *> m_actions;
+ QVector<QAxis *> m_axes;
+};
+
+QLogicalDevice::QLogicalDevice(Qt3DCore::QNode *parent)
+ : Qt3DCore::QNode(*new QLogicalDevicePrivate(), parent)
+{
+}
+
+QLogicalDevice::~QLogicalDevice()
+{
+ QNode::cleanup();
+}
+
+void QLogicalDevice::addAction(QAction *action)
+{
+ Q_D(QLogicalDevice);
+ if (!d->m_actions.contains(action))
+ d->m_actions.push_back(action);
+ // TO DO: needs to be completed to set the parent and send a proper notification
+}
+
+void QLogicalDevice::removeAction(QAction *action)
+{
+ Q_D(QLogicalDevice);
+ if (d->m_actions.contains(action)) {
+ d->m_actions.removeOne(action);
+ // TO DO: needs to be completed to send a proper notification
+ }
+}
+
+QVector<QAction *> QLogicalDevice::actions() const
+{
+ Q_D(const QLogicalDevice);
+ return d->m_actions;
+}
+
+void QLogicalDevice::addAxis(QAxis *axis)
+{
+ Q_D(QLogicalDevice);
+ if (!d->m_axes.contains(axis)) {
+ d->m_axes.push_back(axis);
+ // TO DO: needs to be completed to set the parent and send a proper notification
+ }
+}
+
+void QLogicalDevice::removeAxis(QAxis *axis)
+{
+ Q_D(QLogicalDevice);
+ if (d->m_axes.contains(axis)) {
+ d->m_axes.removeOne(axis);
+ // TO DO: needs to be completed to send a proper notification
+ }
+}
+
+QVector<QAxis *> QLogicalDevice::axes() const
+{
+ Q_D(const QLogicalDevice);
+ return d->m_axes;
+}
+
+void QLogicalDevice::copy(const Qt3DCore::QNode *ref)
+{
+ QNode::copy(ref);
+ const QLogicalDevice *device = static_cast<const QLogicalDevice *>(ref);
+ Q_FOREACH (QAction *action, device->actions())
+ d_func()->m_actions.push_back(qobject_cast<QAction *>(QNode::clone(action)));
+}
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qlogicaldevice.h b/src/input/frontend/qlogicaldevice.h
new file mode 100644
index 000000000..6950e3cce
--- /dev/null
+++ b/src/input/frontend/qlogicaldevice.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QLOGICALDEVICE_H
+#define QT3DINPUT_QLOGICALDEVICE_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QLogicalDevicePrivate;
+class QAction;
+class QAxis;
+
+class QLogicalDevice : public Qt3DCore::QNode
+{
+ Q_OBJECT
+public:
+ explicit QLogicalDevice(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QLogicalDevice();
+
+ void addAction(QAction *action);
+ void removeAction(QAction *action);
+ QVector<QAction *> actions() const;
+
+ void addAxis(QAxis *axis);
+ void removeAxis(QAxis *axis);
+ QVector<QAxis *> axes() const;
+
+protected:
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QLogicalDevice)
+ QT3D_CLONEABLE(QLogicalDevice)
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QLOGICALDEVICE_H
diff --git a/src/input/frontend/qmousecontroller.cpp b/src/input/frontend/qmousecontroller.cpp
new file mode 100644
index 000000000..461296056
--- /dev/null
+++ b/src/input/frontend/qmousecontroller.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmousecontroller.h"
+#include "qmousecontroller_p.h"
+
+#include <Qt3DCore/qentity.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+QMouseControllerPrivate::QMouseControllerPrivate()
+ : QNodePrivate()
+{
+}
+
+/*!
+ * \class Qt3DInput::QMouseController
+ * \inmodule Qt3DInput
+ *
+ * \brief QMouseController is in charge of dispatching mouse events to
+ * attached QMouseInput objects.
+ *
+ * \since 5.5
+ * \sa QMouseInput
+ */
+QMouseController::QMouseController(QNode *parent)
+ : QNode(*new QMouseControllerPrivate, parent)
+{
+}
+
+/*!
+ \internal
+*/
+QMouseController::QMouseController(QMouseControllerPrivate &dd, QNode *parent)
+ : QNode(dd, parent)
+{
+}
+
+/*!
+ Destroys this QMouseController object.
+*/
+QMouseController::~QMouseController()
+{
+ QNode::cleanup();
+}
+
+void QMouseController::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_UNUSED(change);
+ // TODO: To be completed as the mouse input aspect takes shape
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qmousecontroller.h b/src/input/frontend/qmousecontroller.h
new file mode 100644
index 000000000..a0de94db1
--- /dev/null
+++ b/src/input/frontend/qmousecontroller.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QMOUSECONTROLLER_H
+#define QT3DINPUT_QMOUSECONTROLLER_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QMouseControllerPrivate;
+class QMouseInput;
+
+class QT3DINPUTSHARED_EXPORT QMouseController : public Qt3DCore::QNode
+{
+ Q_OBJECT
+
+public:
+ explicit QMouseController(Qt3DCore::QNode *parent = 0);
+
+protected:
+ QMouseController(QMouseControllerPrivate &dd, Qt3DCore::QNode *parent = 0);
+ ~QMouseController();
+
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QMouseController)
+ QT3D_CLONEABLE(QMouseController)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DInput::QMouseController*)
+
+#endif // QT3DINPUT_QMOUSECONTROLLER_H
diff --git a/src/input/frontend/qmousecontroller_p.h b/src/input/frontend/qmousecontroller_p.h
new file mode 100644
index 000000000..c04971af3
--- /dev/null
+++ b/src/input/frontend/qmousecontroller_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QMOUSECONTROLLER_P_H
+#define QT3DINPUT_QMOUSECONTROLLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QMouseController;
+
+class QMouseControllerPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QMouseControllerPrivate();
+
+ Q_DECLARE_PUBLIC(QMouseController)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QMOUSECONTROLLER_P_H
+
diff --git a/src/input/frontend/qmouseinput.cpp b/src/input/frontend/qmouseinput.cpp
new file mode 100644
index 000000000..3fbafda47
--- /dev/null
+++ b/src/input/frontend/qmouseinput.cpp
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmouseinput.h"
+#include "qmouseinput_p.h"
+#include "qmousecontroller.h"
+#include "q3dmouseevent.h"
+#include <Qt3DCore/qbackendscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+namespace Qt3DInput {
+
+QMouseInputPrivate::QMouseInputPrivate()
+ : QComponentPrivate()
+ , m_controller(Q_NULLPTR)
+ , m_containsMouse(false)
+{
+ m_shareable = false;
+}
+
+/*!
+ * \class Qt3DInput::QMouseInput
+ * \inmodule Qt3DInput
+ *
+ * \brief Provides a mean of being notified about mouse events when attached to
+ * a QMouseController instance.
+ *
+ * \since 5.5
+ *
+ * \note QMouseInput components shouldn't be shared, not respecting that
+ * condition will most likely result in undefined behaviors.
+ *
+ * \sa QMouseController
+ */
+
+/*!
+ * Constructs a new QMouseInput instance with parent \a parent.
+ */
+QMouseInput::QMouseInput(QNode *parent)
+ : QComponent(*new QMouseInputPrivate, parent)
+{
+}
+
+/*!
+ \internal
+*/
+QMouseInput::QMouseInput(QMouseInputPrivate &dd, QNode *parent)
+ : QComponent(dd, parent)
+{
+}
+
+/*!
+ Destroys this QMouseInput object
+*/
+QMouseInput::~QMouseInput()
+{
+ QNode::cleanup();
+}
+
+/*!
+ * Sets the mouse controller of the QMouseInput instance to \a controller.
+ */
+void QMouseInput::setController(QMouseController *controller)
+{
+ Q_D(QMouseInput);
+ if (d->m_controller != controller) {
+ d->m_controller = controller;
+ emit controllerChanged();
+ }
+}
+
+/*!
+ * Returns the current mouse controller of the QMouseInput instance.
+ */
+QMouseController *QMouseInput::controller() const
+{
+ Q_D(const QMouseInput);
+ return d->m_controller;
+}
+
+/*!
+ * Returns \c true if the QMouseInput currently contains the mouse.
+ *
+ * \note In this context, contains mean that the ray originating from the
+ * mouse is intersecting with the Qt3DCore::QEntity that aggregates the current
+ * QMouseInput instance component.
+ */
+bool QMouseInput::containsMouse() const
+{
+ Q_D(const QMouseInput);
+ return d->m_containsMouse;
+}
+
+void QMouseInput::copy(const QNode *ref)
+{
+ Q_D(QMouseInput);
+ const QMouseInput *refInput = static_cast<const QMouseInput *>(ref);
+ d->m_containsMouse = refInput->containsMouse();
+
+ // TODO: We may want to store the controller id and only send a clone when we are the parent
+ // of the controller.
+ // Perhaps it's time to investigate sending a "kernel" or "seed" over to the backend rather
+ // than a complete clone.
+ if (refInput && refInput->controller()->parent() == ref)
+ d->m_controller = static_cast<QMouseController *>(QNode::clone(refInput->controller()));
+}
+
+void QMouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
+ if (e->type() == NodeUpdated) {
+ if (e->propertyName() == QByteArrayLiteral("mouse")) {
+ Q3DMouseEventPtr ev = e->value().value<Q3DMouseEventPtr>();
+ mouseEvent(ev.data());
+ } else if (e->propertyName() == QByteArrayLiteral("wheel")) {
+ Q3DWheelEventPtr ev = e->value().value<Q3DWheelEventPtr>();
+ emit wheel(ev.data());
+ }
+ }
+}
+
+void QMouseInput::mouseEvent(Q3DMouseEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ if (event->wasHeld())
+ emit pressAndHold(event);
+ else
+ emit pressed(event);
+ break;
+ case QEvent::MouseButtonRelease:
+ emit released(event);
+ break;
+ case Qt::TapGesture:
+ emit clicked(event);
+ break;
+ case QEvent::MouseButtonDblClick:
+ emit doubleClicked(event);
+ break;
+ case QEvent::MouseMove:
+ emit positionChanged(event);
+ break;
+ default:
+ break;
+ }
+}
+
+void QMouseInput::setContainsMouse(bool contains)
+{
+ Q_D(QMouseInput);
+ if (contains != d->m_containsMouse) {
+ d->m_containsMouse = contains;
+ emit containsMouseChanged();
+ }
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qmouseinput.h b/src/input/frontend/qmouseinput.h
new file mode 100644
index 000000000..5eca4dd4f
--- /dev/null
+++ b/src/input/frontend/qmouseinput.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QMOUSEINPUT_H
+#define QT3DINPUT_QMOUSEINPUT_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DInput/q3dmouseevent.h>
+#include <Qt3DCore/qcomponent.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QMouseController;
+class QMouseInputPrivate;
+
+class QT3DINPUTSHARED_EXPORT QMouseInput : public Qt3DCore::QComponent
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QMouseController *controller READ controller WRITE setController NOTIFY controllerChanged)
+ Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
+
+public:
+ explicit QMouseInput(QNode *parent = 0);
+ ~QMouseInput();
+
+ void setController(QMouseController *controller);
+ QMouseController *controller() const;
+
+ bool containsMouse() const;
+
+Q_SIGNALS:
+ void controllerChanged();
+ void containsMouseChanged();
+
+ void clicked(Qt3DInput::Q3DMouseEvent *mouse);
+ void doubleClicked(Qt3DInput::Q3DMouseEvent *mouse);
+
+ void entered();
+ void exited();
+
+ void pressed(Qt3DInput::Q3DMouseEvent *mouse);
+ void released(Qt3DInput::Q3DMouseEvent *mouse);
+ void pressAndHold(Qt3DInput::Q3DMouseEvent *mouse);
+ void positionChanged(Qt3DInput::Q3DMouseEvent *mouse);
+
+ void wheel(Qt3DInput::Q3DWheelEvent *wheel);
+
+protected:
+ QMouseInput(QMouseInputPrivate &dd, Qt3DCore::QNode *parent = 0);
+ void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
+ void mouseEvent(Q3DMouseEvent *event);
+ void setContainsMouse(bool contains);
+
+private:
+ Q_DECLARE_PRIVATE(QMouseInput)
+ QT3D_CLONEABLE(QMouseInput)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QMOUSEINPUT_H
diff --git a/src/input/frontend/qmouseinput_p.h b/src/input/frontend/qmouseinput_p.h
new file mode 100644
index 000000000..d8f7c3fff
--- /dev/null
+++ b/src/input/frontend/qmouseinput_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QMOUSEINPUT_P_H
+#define QT3DINPUT_QMOUSEINPUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qcomponent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QMouseInput;
+class QMouseController;
+
+class QMouseInputPrivate : public Qt3DCore::QComponentPrivate
+{
+public:
+ QMouseInputPrivate();
+
+ QMouseController *m_controller;
+ bool m_containsMouse;
+
+ Q_DECLARE_PUBLIC(QMouseInput)
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QMOUSEINPUT_P_H
+