diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-08-29 12:58:44 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-11-19 18:32:27 +0000 |
commit | b4a680a587cbbbcc2e11e2da8d9acd08f5b56d7c (patch) | |
tree | 2d0f47a9cfaee43ede4ceaf2bc864eb08884d6a6 /src/input | |
parent | bb8e5a6d4d43b57ed7eefc35cd25f333dbc9e298 (diff) |
PhysicalDeviceProxy: store id of loaded device
Change-Id: I467129355475cdf114ff7003708023c029eb73bc
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/backend/physicaldeviceproxy.cpp | 11 | ||||
-rw-r--r-- | src/input/backend/physicaldeviceproxy_p.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/input/backend/physicaldeviceproxy.cpp b/src/input/backend/physicaldeviceproxy.cpp index 3fd159134..2e46309fd 100644 --- a/src/input/backend/physicaldeviceproxy.cpp +++ b/src/input/backend/physicaldeviceproxy.cpp @@ -61,6 +61,7 @@ void PhysicalDeviceProxy::cleanup() QBackendNode::setEnabled(false); m_deviceName.clear(); m_manager = nullptr; + m_physicalDeviceId = Qt3DCore::QNodeId(); } QString PhysicalDeviceProxy::deviceName() const @@ -80,9 +81,12 @@ PhysicalDeviceProxyManager *PhysicalDeviceProxy::manager() const void PhysicalDeviceProxy::setDevice(QAbstractPhysicalDevice *device) { + m_physicalDeviceId = Qt3DCore::QNodeId(); // Move the device to the main thread - if (device != nullptr) + if (device != nullptr) { + m_physicalDeviceId = device->id(); device->moveToThread(QCoreApplication::instance()->thread()); + } auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId()); e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); @@ -91,6 +95,11 @@ void PhysicalDeviceProxy::setDevice(QAbstractPhysicalDevice *device) notifyObservers(e); } +Qt3DCore::QNodeId PhysicalDeviceProxy::physicalDeviceId() const +{ + return m_physicalDeviceId; +} + void PhysicalDeviceProxy::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) { const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QAbstractPhysicalDeviceProxyData>>(change); diff --git a/src/input/backend/physicaldeviceproxy_p.h b/src/input/backend/physicaldeviceproxy_p.h index dc7651edf..0c714167e 100644 --- a/src/input/backend/physicaldeviceproxy_p.h +++ b/src/input/backend/physicaldeviceproxy_p.h @@ -77,12 +77,14 @@ public: // Called from a job to update the frontend void setDevice(QAbstractPhysicalDevice *device); + Qt3DCore::QNodeId physicalDeviceId() const; private: void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL; QString m_deviceName; PhysicalDeviceProxyManager *m_manager; + Qt3DCore::QNodeId m_physicalDeviceId; }; class PhysicalDeviceProxyNodeFunctor: public Qt3DCore::QBackendNodeMapper |