summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-09-27 15:45:54 +0100
committerMike Krus <mike.krus@kdab.com>2019-09-30 17:07:59 +0100
commit5c16cd7be2ba8bd6d98ee18305dd7d69a9f873ca (patch)
tree5c2f219a8e6530c4221682fa764e6798ee1935e9
parentfc668c2e895953d60a22e0a09071876f395f3e28 (diff)
Enable direct syncing on input aspect
Requires adding new intermediate base class. Will update classes as the functionality is introduced since the static casting is not called unless the class supports syncing. Change-Id: I157c76ae520c1c9e49d46e22f063b7738bbec707 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/input/backend/backend.pri2
-rw-r--r--src/input/backend/backendnode.cpp74
-rw-r--r--src/input/backend/backendnode_p.h79
-rw-r--r--src/input/frontend/qinputaspect.cpp8
-rw-r--r--src/input/frontend/qinputaspect_p.h1
5 files changed, 164 insertions, 0 deletions
diff --git a/src/input/backend/backend.pri b/src/input/backend/backend.pri
index 71c1a9a1c..e1ddee9c7 100644
--- a/src/input/backend/backend.pri
+++ b/src/input/backend/backend.pri
@@ -1,4 +1,5 @@
HEADERS += \
+ $$PWD/backendnode_p.h \
$$PWD/keyboarddevice_p.h \
$$PWD/keyboardhandler_p.h \
$$PWD/inputhandler_p.h \
@@ -39,6 +40,7 @@ HEADERS += \
$$PWD/axisaccumulatorjob_p.h
SOURCES += \
+ $$PWD/backendnode.cpp \
$$PWD/keyboarddevice.cpp \
$$PWD/keyboardhandler.cpp \
$$PWD/inputhandler.cpp \
diff --git a/src/input/backend/backendnode.cpp b/src/input/backend/backendnode.cpp
new file mode 100644
index 000000000..aa440ed51
--- /dev/null
+++ b/src/input/backend/backendnode.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "backendnode_p.h"
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/private/qbackendnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+namespace Input {
+
+BackendNode::BackendNode(Mode mode)
+ : Qt3DCore::QBackendNode(mode)
+{
+}
+
+BackendNode::BackendNode(Qt3DCore::QBackendNodePrivate &dd)
+ : Qt3DCore::QBackendNode(dd)
+{
+
+}
+
+BackendNode::~BackendNode()
+{
+}
+
+void BackendNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
+{
+ Q_UNUSED(firstTime)
+
+ d_ptr->setEnabled(frontEnd->isEnabled());
+}
+
+} // namespace Input
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/backend/backendnode_p.h b/src/input/backend/backendnode_p.h
new file mode 100644
index 000000000..a7749852b
--- /dev/null
+++ b/src/input/backend/backendnode_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_INPUT_BACKENDNODE_H
+#define QT3DINPUT_INPUT_BACKENDNODE_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/private/qt3dinput_global_p.h>
+#include <Qt3DCore/qbackendnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+namespace Input {
+
+class Q_3DINPUTSHARED_PRIVATE_EXPORT BackendNode : public Qt3DCore::QBackendNode
+{
+public:
+ BackendNode(Qt3DCore::QBackendNode::Mode mode = ReadOnly);
+ ~BackendNode();
+
+ virtual void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime);
+
+protected:
+ explicit BackendNode(Qt3DCore::QBackendNodePrivate &dd);
+};
+
+} // namespace Input
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_INPUT_BACKENDNODE_H
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index e7ff70326..e91e545bb 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -61,6 +61,7 @@
#include <QtCore/QLibraryInfo>
#include <QtCore/QPluginLoader>
+#include <Qt3DInput/private/backendnode_p.h>
#include <Qt3DInput/private/action_p.h>
#include <Qt3DInput/private/actioninput_p.h>
#include <Qt3DInput/private/axis_p.h>
@@ -109,6 +110,13 @@ QInputAspectPrivate::QInputAspectPrivate()
{
}
+void QInputAspectPrivate::syncDirtyFrontEndNode(QNode *node, QBackendNode *backend, bool firstTime) const
+{
+ Input::BackendNode *renderBackend = static_cast<Input::BackendNode *>(backend);
+ renderBackend->syncFromFrontEnd(node, firstTime);
+}
+
+
/*!
\class Qt3DInput::QInputAspect
\inherits Qt3DCore::QAbstractAspect
diff --git a/src/input/frontend/qinputaspect_p.h b/src/input/frontend/qinputaspect_p.h
index bcdd8d4ed..aee7e7909 100644
--- a/src/input/frontend/qinputaspect_p.h
+++ b/src/input/frontend/qinputaspect_p.h
@@ -69,6 +69,7 @@ class QInputAspectPrivate : public Qt3DCore::QAbstractAspectPrivate
public:
QInputAspectPrivate();
void loadInputDevicePlugins();
+ void syncDirtyFrontEndNode(Qt3DCore::QNode *node, Qt3DCore::QBackendNode *backend, bool firstTime) const override;
Q_DECLARE_PUBLIC(QInputAspect)
QScopedPointer<Input::InputHandler> m_inputHandler;