summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-03-29 15:55:23 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-03-31 07:35:01 +0000
commitcb0dc5d1a650e7269a6debac8db6953a577c8d2c (patch)
treeb914b77bdb768e7aa5e57fa7c6c31c29d2e4d4f8
parentfc2fda9c78fd3b8c698b7cc15774d81f49fceeb9 (diff)
Add protected overload of initializeFromPeer() for backend devices
Subclasses should call this from their overloads to set up the base device properties. Since we do not yet know if all AxisSettings objects will exist by this time, just store the id's of them and we will add a job to extract the settings in the next frame once we know they will all have backend objects. Change-Id: I207db9d2be165f8fb64668c4a890ad931eb0081e Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode.cpp12
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode.h3
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode_p.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.cpp b/src/input/backend/qabstractphysicaldevicebackendnode.cpp
index bd8aea92b..324eacda0 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode.cpp
+++ b/src/input/backend/qabstractphysicaldevicebackendnode.cpp
@@ -45,6 +45,7 @@
#include "inputmanagers_p.h"
#include <Qt3DInput/qinputaspect.h>
+#include <Qt3DInput/qphysicaldevicecreatedchange.h>
#include <Qt3DInput/private/qinputaspect_p.h>
#include <Qt3DCore/qscenepropertychange.h>
@@ -161,6 +162,17 @@ void QAbstractPhysicalDeviceBackendNode::updateFromPeer(Qt3DCore::QNode *peer)
}
}
+void QAbstractPhysicalDeviceBackendNode::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+{
+ const auto deviceChange = qSharedPointerCast<QPhysicalDeviceCreatedChangeBase>(change);
+ Q_D(QAbstractPhysicalDeviceBackendNode);
+ d->m_enabled = change->isNodeEnabled();
+ // Store the axis setting Ids. We will update the settings themselves from
+ // a job scheduled on the next frame.
+ // TODO: Create such a job once all types can be created this way.
+ d->m_pendingAxisSettingIds = deviceChange->axisSettingIds();
+}
+
void QAbstractPhysicalDeviceBackendNode::cleanup()
{
Q_D(QAbstractPhysicalDeviceBackendNode);
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.h b/src/input/backend/qabstractphysicaldevicebackendnode.h
index c4694c30a..44498be9d 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode.h
+++ b/src/input/backend/qabstractphysicaldevicebackendnode.h
@@ -71,6 +71,9 @@ public:
protected:
QAbstractPhysicalDeviceBackendNode(QAbstractPhysicalDeviceBackendNodePrivate &dd);
+
+ void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_OVERRIDE;
+
Q_DECLARE_PRIVATE(QAbstractPhysicalDeviceBackendNode)
};
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode_p.h b/src/input/backend/qabstractphysicaldevicebackendnode_p.h
index 49a48cba2..5418f748b 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode_p.h
+++ b/src/input/backend/qabstractphysicaldevicebackendnode_p.h
@@ -96,6 +96,7 @@ public:
Input::AxisSetting *getAxisSetting(Qt3DCore::QNodeId axisSettingId) const;
+ Qt3DCore::QNodeIdVector m_pendingAxisSettingIds;
QVector<Input::AxisIdSetting> m_axisSettings;
QVector<Input::AxisIdFilter> m_axisFilters;
QInputAspect *m_inputAspect;