diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-09-30 17:05:40 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-10-01 09:18:04 +0100 |
commit | 3234ae05f0d16886bda586585ed8e4c827349187 (patch) | |
tree | ae18a68ee56c777b08a567da73831b4f81422fd8 /src/input | |
parent | 90e7c5b5b4bfa4015b834adf7f0e744e48e25db3 (diff) |
Update QPhysicalDeviceProxy to use direct sync
Change-Id: I0126310365663ae1be1d1cb8ebd4a896a5712c4a
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/backend/physicaldeviceproxy.cpp | 21 | ||||
-rw-r--r-- | src/input/backend/physicaldeviceproxy_p.h | 8 | ||||
-rw-r--r-- | src/input/frontend/qinputaspect.cpp | 2 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/input/backend/physicaldeviceproxy.cpp b/src/input/backend/physicaldeviceproxy.cpp index 9512296b8..d0ed4356a 100644 --- a/src/input/backend/physicaldeviceproxy.cpp +++ b/src/input/backend/physicaldeviceproxy.cpp @@ -44,6 +44,7 @@ #include <QtCore/QCoreApplication> #include <Qt3DInput/private/inputmanagers_p.h> +#include <Qt3DInput/private/qabstractphysicaldeviceproxy_p.h> #include <Qt3DInput/private/qabstractphysicaldeviceproxy_p_p.h> QT_BEGIN_NAMESPACE @@ -53,7 +54,7 @@ namespace Qt3DInput { namespace Input { PhysicalDeviceProxy::PhysicalDeviceProxy() - : QBackendNode(QBackendNode::ReadWrite) + : BackendNode(QBackendNode::ReadWrite) , m_manager(nullptr) { } @@ -102,14 +103,20 @@ Qt3DCore::QNodeId PhysicalDeviceProxy::physicalDeviceId() const return m_physicalDeviceId; } -void PhysicalDeviceProxy::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) +void PhysicalDeviceProxy::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) { - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QAbstractPhysicalDeviceProxyData>>(change); - const QAbstractPhysicalDeviceProxyData &data = typedChange->data; - m_deviceName = data.deviceName; + BackendNode::syncFromFrontEnd(frontEnd, firstTime); - // Request to load the actual device - m_manager->addPendingProxyToLoad(peerId()); + if (firstTime) { + const QAbstractPhysicalDeviceProxy *node = qobject_cast<const QAbstractPhysicalDeviceProxy *>(frontEnd); + if (!node) + return; + + m_deviceName = node->deviceName(); + + // Request to load the actual device + m_manager->addPendingProxyToLoad(peerId()); + } } PhysicalDeviceProxyNodeFunctor::PhysicalDeviceProxyNodeFunctor(PhysicalDeviceProxyManager *manager) diff --git a/src/input/backend/physicaldeviceproxy_p.h b/src/input/backend/physicaldeviceproxy_p.h index 9500a4adb..6dd2a54be 100644 --- a/src/input/backend/physicaldeviceproxy_p.h +++ b/src/input/backend/physicaldeviceproxy_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 @@ -64,7 +64,7 @@ namespace Input { class PhysicalDeviceProxyManager; -class Q_AUTOTEST_EXPORT PhysicalDeviceProxy : public Qt3DCore::QBackendNode +class Q_AUTOTEST_EXPORT PhysicalDeviceProxy : public BackendNode { public: PhysicalDeviceProxy(); @@ -79,9 +79,9 @@ public: void setDevice(QAbstractPhysicalDevice *device); Qt3DCore::QNodeId physicalDeviceId() const; -private: - void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final; + void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; +private: QString m_deviceName; PhysicalDeviceProxyManager *m_manager; Qt3DCore::QNodeId m_physicalDeviceId; diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index a2db40b95..44f4ec0ea 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -161,7 +161,7 @@ QInputAspect::QInputAspect(QInputAspectPrivate &dd, QObject *parent) 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, true>(QBackendNodeMapperPtr(new Input::InputSettingsFunctor(d_func()->m_inputHandler.data()))); - registerBackendType<QAbstractPhysicalDeviceProxy>(QBackendNodeMapperPtr(new Input::PhysicalDeviceProxyNodeFunctor(d_func()->m_inputHandler->physicalDeviceProxyManager()))); + registerBackendType<QAbstractPhysicalDeviceProxy, true>(QBackendNodeMapperPtr(new Input::PhysicalDeviceProxyNodeFunctor(d_func()->m_inputHandler->physicalDeviceProxyManager()))); #ifdef HAVE_QGAMEPAD registerBackendType<QGamepadInput>(QBackendNodeMapperPtr(new Input::GenericDeviceBackendFunctor(this, d_func()->m_inputHandler.data()))); |