summaryrefslogtreecommitdiffstats
path: root/src/input
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
parent812bc78ce4b88f612b0d4880723547fe09181f93 (diff)
Update QLogicalDevice to use direct sync
Change-Id: I6e176c19ceda3ca1c0bf03da4d78fe92ec3344a7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r--src/input/backend/logicaldevice.cpp42
-rw-r--r--src/input/backend/logicaldevice_p.h8
-rw-r--r--src/input/frontend/qinputaspect.cpp2
-rw-r--r--src/input/frontend/qlogicaldevice.cpp25
4 files changed, 17 insertions, 60 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;
};
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index 110d9877f..6985e71c8 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -158,7 +158,7 @@ QInputAspect::QInputAspect(QInputAspectPrivate &dd, QObject *parent)
registerBackendType<QActionInput, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::ActionInput, Input::ActionInputManager>(d_func()->m_inputHandler->actionInputManager())));
registerBackendType<QInputChord, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::InputChord, Input::InputChordManager>(d_func()->m_inputHandler->inputChordManager())));
registerBackendType<QInputSequence, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::InputSequence, Input::InputSequenceManager>(d_func()->m_inputHandler->inputSequenceManager())));
- registerBackendType<QLogicalDevice>(QBackendNodeMapperPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager())));
+ registerBackendType<QLogicalDevice, true>(QBackendNodeMapperPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager())));
registerBackendType<QGenericInputDevice, true>(QBackendNodeMapperPtr(new Input::GenericDeviceBackendFunctor(this, d_func()->m_inputHandler.data())));
registerBackendType<QInputSettings>(QBackendNodeMapperPtr(new Input::InputSettingsFunctor(d_func()->m_inputHandler.data())));
registerBackendType<QAbstractPhysicalDeviceProxy>(QBackendNodeMapperPtr(new Input::PhysicalDeviceProxyNodeFunctor(d_func()->m_inputHandler->physicalDeviceProxyManager())));
diff --git a/src/input/frontend/qlogicaldevice.cpp b/src/input/frontend/qlogicaldevice.cpp
index 1e7033962..8869d2116 100644
--- a/src/input/frontend/qlogicaldevice.cpp
+++ b/src/input/frontend/qlogicaldevice.cpp
@@ -176,11 +176,7 @@ void QLogicalDevice::addAction(QAction *action)
// Ensures proper bookkeeping
d->registerDestructionHelper(action, &QLogicalDevice::removeAction, d->m_actions);
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), action);
- change->setPropertyName("action");
- d->notifyObservers(change);
- }
+ d->update();
}
}
@@ -191,12 +187,7 @@ void QLogicalDevice::removeAction(QAction *action)
{
Q_D(QLogicalDevice);
if (d->m_actions.contains(action)) {
-
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), action);
- change->setPropertyName("action");
- d->notifyObservers(change);
- }
+ d->update();
d->m_actions.removeOne(action);
@@ -236,11 +227,7 @@ void QLogicalDevice::addAxis(QAxis *axis)
// Ensures proper bookkeeping
d->registerDestructionHelper(axis, &QLogicalDevice::removeAxis, d->m_axes);
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), axis);
- change->setPropertyName("axis");
- d->notifyObservers(change);
- }
+ d->update();
}
}
@@ -251,11 +238,7 @@ void QLogicalDevice::removeAxis(QAxis *axis)
{
Q_D(QLogicalDevice);
if (d->m_axes.contains(axis)) {
- if (d->m_changeArbiter != nullptr) {
- const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), axis);
- change->setPropertyName("axis");
- d->notifyObservers(change);
- }
+ d->update();
d->m_axes.removeOne(axis);