summaryrefslogtreecommitdiffstats
path: root/src/input/backend
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-09-30 16:38:32 +0100
committerMike Krus <mike.krus@kdab.com>2019-10-01 09:17:52 +0100
commitf06e898718851914bcb4c1d2410e7fd0bc776874 (patch)
tree3e5c5223ba90b9f598a920540a1290702a80d69a /src/input/backend
parent812bc78ce4b88f612b0d4880723547fe09181f93 (diff)
Update QLogicalDevice to use direct sync
Change-Id: I6e176c19ceda3ca1c0bf03da4d78fe92ec3344a7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/backend')
-rw-r--r--src/input/backend/logicaldevice.cpp42
-rw-r--r--src/input/backend/logicaldevice_p.h8
2 files changed, 12 insertions, 38 deletions
diff --git a/src/input/backend/logicaldevice.cpp b/src/input/backend/logicaldevice.cpp
index 5fcfb07bb..6bea0d85d 100644
--- a/src/input/backend/logicaldevice.cpp
+++ b/src/input/backend/logicaldevice.cpp
@@ -56,18 +56,10 @@ namespace Qt3DInput {
namespace Input {
LogicalDevice::LogicalDevice()
- : QBackendNode()
+ : BackendNode()
{
}
-void LogicalDevice::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QLogicalDeviceData>>(change);
- const auto &data = typedChange->data;
- m_actions = data.actionIds;
- m_axes = data.axisIds;
-}
-
void LogicalDevice::cleanup()
{
QBackendNode::setEnabled(false);
@@ -75,31 +67,15 @@ void LogicalDevice::cleanup()
m_axes.clear();
}
-void LogicalDevice::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void LogicalDevice::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- switch (e->type()) {
- case Qt3DCore::PropertyValueAdded: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("axis"))
- m_axes.push_back(change->addedNodeId());
- else if (change->propertyName() == QByteArrayLiteral("action"))
- m_actions.push_back(change->addedNodeId());
- break;
- }
-
- case Qt3DCore::PropertyValueRemoved: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("axis"))
- m_axes.removeOne(change->removedNodeId());
- else if (change->propertyName() == QByteArrayLiteral("action"))
- m_actions.removeOne(change->removedNodeId());
- break;
- }
-
- default:
- break;
- }
- QBackendNode::sceneChangeEvent(e);
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QLogicalDevice *node = qobject_cast<const QLogicalDevice *>(frontEnd);
+ if (!node)
+ return;
+
+ m_actions = Qt3DCore::qIdsForNodes(node->actions());
+ m_axes = Qt3DCore::qIdsForNodes(node->axes());
}
LogicalDeviceNodeFunctor::LogicalDeviceNodeFunctor(LogicalDeviceManager *manager)
diff --git a/src/input/backend/logicaldevice_p.h b/src/input/backend/logicaldevice_p.h
index 138a54777..292f2a5c3 100644
--- a/src/input/backend/logicaldevice_p.h
+++ b/src/input/backend/logicaldevice_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <Qt3DCore/qbackendnode.h>
+#include <Qt3DInput/private/backendnode_p.h>
#include <Qt3DCore/qnodeid.h>
QT_BEGIN_NAMESPACE
@@ -62,7 +62,7 @@ namespace Input {
class LogicalDeviceManager;
-class Q_AUTOTEST_EXPORT LogicalDevice : public Qt3DCore::QBackendNode
+class Q_AUTOTEST_EXPORT LogicalDevice : public BackendNode
{
public:
LogicalDevice();
@@ -71,11 +71,9 @@ public:
inline QVector<Qt3DCore::QNodeId> axes() const { return m_axes; }
inline QVector<Qt3DCore::QNodeId> actions() const { return m_actions; }
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
QVector<Qt3DCore::QNodeId> m_axes;
QVector<Qt3DCore::QNodeId> m_actions;
};