diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-11-30 16:10:30 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-11-30 21:34:38 +0000 |
commit | b048a71652dfd0d63658a33f7b6c75e5a7c5453c (patch) | |
tree | a2973ddc3d34e9105bca5756ed2aa0c816a5867b /src/input | |
parent | c80eed85ee8250f1dbbf1565f2f8ff01b6fa6d0b (diff) |
LogicalDeviceManager: store vector of active LogicalDevice instances
Will make it easier to find all the logical devices and update
the axis/actions for them.
Change-Id: I839da4a87f650a429957c0fcecf196e02bad2f13
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/backend/inputmanagers_p.h | 7 | ||||
-rw-r--r-- | src/input/backend/logicaldevice.cpp | 27 | ||||
-rw-r--r-- | src/input/backend/logicaldevice_p.h | 17 | ||||
-rw-r--r-- | src/input/frontend/qinputaspect.cpp | 7 |
4 files changed, 57 insertions, 1 deletions
diff --git a/src/input/backend/inputmanagers_p.h b/src/input/backend/inputmanagers_p.h index 8ffde58da..60c0237cd 100644 --- a/src/input/backend/inputmanagers_p.h +++ b/src/input/backend/inputmanagers_p.h @@ -165,6 +165,13 @@ class LogicalDeviceManager : public Qt3DCore::QResourceManager< { public: LogicalDeviceManager() {} + + QVector<HLogicalDevice> activeDevices() const { return m_activeDevices; } + void addActiveDevice(HLogicalDevice device) { m_activeDevices.push_back(device); } + void removeActiveDevice(HLogicalDevice device) { m_activeDevices.removeOne(device); } + +private: + QVector<HLogicalDevice> m_activeDevices; }; } // namespace Input diff --git a/src/input/backend/logicaldevice.cpp b/src/input/backend/logicaldevice.cpp index b9b116488..32e81f8a6 100644 --- a/src/input/backend/logicaldevice.cpp +++ b/src/input/backend/logicaldevice.cpp @@ -39,6 +39,7 @@ #include <Qt3DInput/qaxis.h> #include <Qt3DInput/qaction.h> #include <Qt3DCore/qscenepropertychange.h> +#include <Qt3DInput/private/inputmanagers_p.h> QT_BEGIN_NAMESPACE @@ -89,6 +90,32 @@ void LogicalDevice::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) } } +LogicalDeviceNodeFunctor::LogicalDeviceNodeFunctor(LogicalDeviceManager *manager) + : m_manager(manager) +{ +} + +Qt3DCore::QBackendNode *LogicalDeviceNodeFunctor::create(Qt3DCore::QNode *frontend, const Qt3DCore::QBackendNodeFactory *factory) const +{ + HLogicalDevice handle = m_manager->getOrAcquireHandle(frontend->id()); + LogicalDevice *backend = m_manager->data(handle); + m_manager->addActiveDevice(handle); + backend->setFactory(factory); + backend->setPeer(frontend); + return backend; +} + +Qt3DCore::QBackendNode *LogicalDeviceNodeFunctor::get(const Qt3DCore::QNodeId &id) const +{ + return m_manager->lookupResource(id); +} + +void LogicalDeviceNodeFunctor::destroy(const Qt3DCore::QNodeId &id) const +{ + HLogicalDevice handle = m_manager->lookupHandle(id); + m_manager->releaseResource(id); + m_manager->removeActiveDevice(handle); +} } // namespace Input diff --git a/src/input/backend/logicaldevice_p.h b/src/input/backend/logicaldevice_p.h index d58af1fe9..f65527dbc 100644 --- a/src/input/backend/logicaldevice_p.h +++ b/src/input/backend/logicaldevice_p.h @@ -57,6 +57,8 @@ namespace Qt3DInput { namespace Input { +class LogicalDeviceManager; + class LogicalDevice : public Qt3DCore::QBackendNode { public: @@ -76,6 +78,21 @@ private: bool m_enabled; }; + +class LogicalDeviceNodeFunctor : public Qt3DCore::QBackendNodeFunctor +{ +public: + explicit LogicalDeviceNodeFunctor(LogicalDeviceManager *manager); + + Qt3DCore::QBackendNode *create(Qt3DCore::QNode *frontend, const Qt3DCore::QBackendNodeFactory *factory) const Q_DECL_FINAL; + Qt3DCore::QBackendNode *get(const Qt3DCore::QNodeId &id) const Q_DECL_FINAL; + void destroy(const Qt3DCore::QNodeId &id) const Q_DECL_FINAL; + +private: + LogicalDeviceManager *m_manager; +}; + + } // namespace Input } // namespace Qt3DInput diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index 4c2b0e4de..b9277774d 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -109,7 +109,7 @@ QInputAspect::QInputAspect(QObject *parent) registerBackendType<QAxisSetting>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::AxisSetting, Input::AxisSettingManager>(d_func()->m_inputHandler->axisSettingManager()))); registerBackendType<Qt3DInput::QAction>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::Action, Input::ActionManager>(d_func()->m_inputHandler->actionManager()))); registerBackendType<QActionInput>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::ActionInput, Input::ActionInputManager>(d_func()->m_inputHandler->actionInputManager()))); - registerBackendType<QLogicalDevice>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::LogicalDevice, Input::LogicalDeviceManager>(d_func()->m_inputHandler->logicalDeviceManager()))); + registerBackendType<QLogicalDevice>(QBackendNodeFunctorPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager()))); loadInputDevicePlugins(); } @@ -167,6 +167,11 @@ QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time) Q_FOREACH (QInputDeviceIntegration *integration, d->m_inputDeviceIntegrations) jobs += integration->jobsToExecute(time); + // TO DO: + // Have Jobs that update Axis/Action (store combined axis/action value) + // Have Jobs that update the LogicalDevice + // Have Jobs that update the AxisHandlers/ActionHandlers + return jobs; } |