diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-12-01 13:59:53 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-12-04 16:22:59 +0000 |
commit | 6f4985f77f0d502696f7deab2c0e45a3070824fd (patch) | |
tree | 5c3b81302210e117347d4d04990af5e58b8dc664 /src | |
parent | f01d9a60e9184a3595e5128e1af3c9b0be6a1d80 (diff) |
Add backend class for axis-action handler
And do usual registration.
Change-Id: I8d1ceadda1138e3bb298e95a6d0f8a635188595e
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/input/backend/axisactionhandler.cpp | 79 | ||||
-rw-r--r-- | src/input/backend/axisactionhandler_p.h | 78 | ||||
-rw-r--r-- | src/input/backend/backend.pri | 6 | ||||
-rw-r--r-- | src/input/backend/handle_types_p.h | 2 | ||||
-rw-r--r-- | src/input/backend/inputhandler.cpp | 1 | ||||
-rw-r--r-- | src/input/backend/inputhandler_p.h | 3 | ||||
-rw-r--r-- | src/input/backend/inputmanagers_p.h | 11 | ||||
-rw-r--r-- | src/input/frontend/qinputaspect.cpp | 3 |
8 files changed, 181 insertions, 2 deletions
diff --git a/src/input/backend/axisactionhandler.cpp b/src/input/backend/axisactionhandler.cpp new file mode 100644 index 000000000..df7282321 --- /dev/null +++ b/src/input/backend/axisactionhandler.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "axisactionhandler_p.h" +#include <Qt3DInput/qaxisactionhandler.h> +#include <Qt3DInput/qlogicaldevice.h> +#include <Qt3DCore/qscenepropertychange.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { +namespace Input { + +AxisActionHandler::AxisActionHandler() + : Qt3DCore::QBackendNode() + , m_logicalDevice() +{ + +} + +void AxisActionHandler::updateFromPeer(Qt3DCore::QNode *peer) +{ + Qt3DInput::QAxisActionHandler *handler = static_cast<Qt3DInput::QAxisActionHandler *>(peer); + if (handler->logicalDevice()) + m_logicalDevice = handler->logicalDevice()->id(); +} + +void AxisActionHandler::cleanup() +{ + m_logicalDevice = Qt3DCore::QNodeId(); +} + +void AxisActionHandler::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +{ + if (e->type() == Qt3DCore::NodeUpdated) { + Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e); + if (propertyChange->propertyName() == QByteArrayLiteral("logicalDevice")) { + m_logicalDevice = propertyChange->value().value<Qt3DCore::QNodeId>(); + } + } +} + +} // namespace Input +} // namespace Qt3DInput + +QT_END_NAMESPACE diff --git a/src/input/backend/axisactionhandler_p.h b/src/input/backend/axisactionhandler_p.h new file mode 100644 index 000000000..a8a5d983a --- /dev/null +++ b/src/input/backend/axisactionhandler_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QINPUTASPECT_INPUT_AXISACTIONHANDLER_P_H +#define QINPUTASPECT_INPUT_AXISACTIONHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DCore/qbackendnode.h> +#include <Qt3DCore/qnodeid.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { +namespace Input { + +class AxisActionHandler : public Qt3DCore::QBackendNode +{ +public: + AxisActionHandler(); + void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE; + void cleanup(); + +protected: + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + +private: + Qt3DCore::QNodeId m_logicalDevice; +}; + +} // namespace Input +} // namespace Qt3DInput + +QT_END_NAMESPACE + +#endif // QINPUTASPECT_INPUT_AXISACTIONHANDLER_P_H diff --git a/src/input/backend/backend.pri b/src/input/backend/backend.pri index 033754a33..e950eef4f 100644 --- a/src/input/backend/backend.pri +++ b/src/input/backend/backend.pri @@ -22,7 +22,8 @@ HEADERS += \ $$PWD/movingaverage_p.h \ $$PWD/axissetting_p.h \ $$PWD/qabstractphysicaldevicebackendnode_p.h \ - $$PWD/updateaxisactionjob_p.h + $$PWD/updateaxisactionjob_p.h \ + $$PWD/axisactionhandler_p.h SOURCES += \ $$PWD/cameracontroller.cpp \ @@ -44,6 +45,7 @@ SOURCES += \ $$PWD/qabstractphysicaldevicebackendnode.cpp \ $$PWD/movingaverage.cpp \ $$PWD/axissetting.cpp \ - $$PWD/updateaxisactionjob.cpp + $$PWD/updateaxisactionjob.cpp \ + $$PWD/axisactionhandler.cpp INCLUDEPATH += $$PWD diff --git a/src/input/backend/handle_types_p.h b/src/input/backend/handle_types_p.h index 698de0455..03d8dee3c 100644 --- a/src/input/backend/handle_types_p.h +++ b/src/input/backend/handle_types_p.h @@ -60,6 +60,7 @@ class KeyboardInput; class MouseController; class MouseInput; class Axis; +class AxisActionHandler; class AxisInput; class AxisSetting; class Action; @@ -71,6 +72,7 @@ typedef Qt3DCore::QHandle<KeyboardInput, 16> HKeyboardInput; typedef Qt3DCore::QHandle<MouseController, 8> HMouseController; typedef Qt3DCore::QHandle<MouseInput, 16> HMouseInput; typedef Qt3DCore::QHandle<Axis, 16> HAxis; +typedef Qt3DCore::QHandle<AxisActionHandler, 16> HAxisActionHandler; typedef Qt3DCore::QHandle<AxisSetting, 16> HAxisSetting; typedef Qt3DCore::QHandle<Action, 16> HAction; typedef Qt3DCore::QHandle<AxisInput, 16> HAxisInput; diff --git a/src/input/backend/inputhandler.cpp b/src/input/backend/inputhandler.cpp index 8797315b2..31e476050 100644 --- a/src/input/backend/inputhandler.cpp +++ b/src/input/backend/inputhandler.cpp @@ -60,6 +60,7 @@ InputHandler::InputHandler() , m_axisManager(new AxisManager()) , m_actionManager(new ActionManager()) , m_axisInputManager(new AxisInputManager()) + , m_axisActionHandlerManager(new AxisActionHandlerManager()) , m_axisSettingManager(new AxisSettingManager()) , m_actionInputManager(new ActionInputManager()) , m_logicalDeviceManager(new LogicalDeviceManager()) diff --git a/src/input/backend/inputhandler_p.h b/src/input/backend/inputhandler_p.h index 085597971..e81116d91 100644 --- a/src/input/backend/inputhandler_p.h +++ b/src/input/backend/inputhandler_p.h @@ -73,6 +73,7 @@ class MouseControllerManager; class MouseInputManager; class MouseEventFilter; class AxisManager; +class AxisActionHandlerManager; class ActionManager; class AxisInputManager; class AxisSettingManager; @@ -93,6 +94,7 @@ public: inline AxisManager *axisManager() const { return m_axisManager; } inline ActionManager *actionManager() const { return m_actionManager; } inline AxisInputManager *axisInputManager() const { return m_axisInputManager; } + inline AxisActionHandlerManager *axisActionHandlerManager() const { return m_axisActionHandlerManager; } inline AxisSettingManager *axisSettingManager() const { return m_axisSettingManager; } inline ActionInputManager *actionInputManager() const { return m_actionInputManager; } inline LogicalDeviceManager *logicalDeviceManager() const { return m_logicalDeviceManager; } @@ -134,6 +136,7 @@ private: AxisManager *m_axisManager; ActionManager *m_actionManager; AxisInputManager *m_axisInputManager; + AxisActionHandlerManager *m_axisActionHandlerManager; AxisSettingManager *m_axisSettingManager; ActionInputManager *m_actionInputManager; LogicalDeviceManager *m_logicalDeviceManager; diff --git a/src/input/backend/inputmanagers_p.h b/src/input/backend/inputmanagers_p.h index 60c0237cd..e18f8de4d 100644 --- a/src/input/backend/inputmanagers_p.h +++ b/src/input/backend/inputmanagers_p.h @@ -59,6 +59,7 @@ #include <Qt3DInput/private/axisinput_p.h> #include <Qt3DInput/private/action_p.h> #include <Qt3DInput/private/axis_p.h> +#include <Qt3DInput/private/axisactionhandler_p.h> #include <Qt3DInput/private/axissetting_p.h> #include <Qt3DInput/private/logicaldevice_p.h> @@ -117,6 +118,16 @@ public: AxisManager() {} }; +class AxisActionHandlerManager : public Qt3DCore::QResourceManager< + AxisActionHandler, + Qt3DCore::QNodeId, + 16, + Qt3DCore::ArrayAllocatingPolicy> +{ +public: + AxisActionHandlerManager() {} +}; + class AxisSettingManager : public Qt3DCore::QResourceManager< AxisSetting, Qt3DCore::QNodeId, diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index 220484d4d..ad1a01e0c 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -56,6 +56,7 @@ #include <QPluginLoader> #include <Qt3DInput/qaxis.h> +#include <Qt3DInput/qaxisactionhandler.h> #include <Qt3DInput/qaction.h> #include <Qt3DInput/qaxisinput.h> #include <Qt3DInput/qaxissetting.h> @@ -63,6 +64,7 @@ #include <Qt3DInput/qlogicaldevice.h> #include <Qt3DInput/qabstractphysicaldevice.h> #include <Qt3DInput/private/axis_p.h> +#include <Qt3DInput/private/axisactionhandler_p.h> #include <Qt3DInput/private/action_p.h> #include <Qt3DInput/private/axisinput_p.h> #include <Qt3DInput/private/axissetting_p.h> @@ -107,6 +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<Qt3DInput::QAxisActionHandler>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::AxisActionHandler, Input::AxisActionHandlerManager>(d_func()->m_inputHandler->axisActionHandlerManager()))); registerBackendType<QLogicalDevice>(QBackendNodeFunctorPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager()))); loadInputDevicePlugins(); |