diff options
author | Colin Ogilvie <colin.ogilvie@kdab.com> | 2016-01-13 12:07:23 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-01-16 15:52:37 +0000 |
commit | f33a8d16417a91f9fcc7f703c3daf8605a18399c (patch) | |
tree | 595df58b370642557ccd88bcad7e52fadca99629 /src/input | |
parent | e218d2a65441a68f0818154552d3ddd66925b823 (diff) |
Backend Nodes for Aggregate Actions
Change-Id: I51dbd9eaedfd8b152e3f65c0c9e16cf81e69fb02
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/backend/backend.pri | 8 | ||||
-rw-r--r-- | src/input/backend/handle_types_p.h | 4 | ||||
-rw-r--r-- | src/input/backend/inputchord.cpp | 88 | ||||
-rw-r--r-- | src/input/backend/inputchord_p.h | 84 | ||||
-rw-r--r-- | src/input/backend/inputhandler.cpp | 2 | ||||
-rw-r--r-- | src/input/backend/inputhandler_p.h | 6 | ||||
-rw-r--r-- | src/input/backend/inputmanagers_p.h | 22 | ||||
-rw-r--r-- | src/input/backend/inputsequence.cpp | 99 | ||||
-rw-r--r-- | src/input/backend/inputsequence_p.h | 88 | ||||
-rw-r--r-- | src/input/frontend/qinputaspect.cpp | 6 |
10 files changed, 405 insertions, 2 deletions
diff --git a/src/input/backend/backend.pri b/src/input/backend/backend.pri index ee23ea208..a1fcedd0e 100644 --- a/src/input/backend/backend.pri +++ b/src/input/backend/backend.pri @@ -27,7 +27,9 @@ HEADERS += \ $$PWD/updatehandlerjob_p.h \ $$PWD/axisactionpayload_p.h \ $$PWD/keyboardmousegenericdeviceintegration_p.h \ - $$PWD/genericdevicebackendnode_p.h + $$PWD/genericdevicebackendnode_p.h \ + $$PWD/inputchord_p.h \ + $$PWD/inputsequence_p.h SOURCES += \ $$PWD/cameracontroller.cpp \ @@ -53,6 +55,8 @@ SOURCES += \ $$PWD/axisactionhandler.cpp \ $$PWD/updatehandlerjob.cpp \ $$PWD/keyboardmousegenericdeviceintegration.cpp \ - $$PWD/genericdevicebackendnode.cpp + $$PWD/genericdevicebackendnode.cpp \ + $$PWD/inputchord.cpp \ + $$PWD/inputsequence.cpp INCLUDEPATH += $$PWD diff --git a/src/input/backend/handle_types_p.h b/src/input/backend/handle_types_p.h index 77c72289d..948027cc2 100644 --- a/src/input/backend/handle_types_p.h +++ b/src/input/backend/handle_types_p.h @@ -65,6 +65,8 @@ class AxisInput; class AxisSetting; class Action; class ActionInput; +class InputSequence; +class InputChord; class LogicalDevice; class GenericDeviceBackendNode; @@ -78,6 +80,8 @@ typedef Qt3DCore::QHandle<AxisSetting, 16> HAxisSetting; typedef Qt3DCore::QHandle<Action, 16> HAction; typedef Qt3DCore::QHandle<AxisInput, 16> HAxisInput; typedef Qt3DCore::QHandle<ActionInput, 16> HActionInput; +typedef Qt3DCore::QHandle<InputSequence, 16> HInputSequence; +typedef Qt3DCore::QHandle<InputChord, 16> HInputChord; typedef Qt3DCore::QHandle<LogicalDevice, 16> HLogicalDevice; typedef Qt3DCore::QHandle<GenericDeviceBackendNode, 8> HGenericDeviceBackendNode; diff --git a/src/input/backend/inputchord.cpp b/src/input/backend/inputchord.cpp new file mode 100644 index 000000000..adaf727d7 --- /dev/null +++ b/src/input/backend/inputchord.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 "inputchord_p.h" +#include <Qt3DInput/qinputchord.h> +#include <Qt3DCore/qscenepropertychange.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +namespace Input { + +InputChord::InputChord() + : Qt3DCore::QBackendNode() + , m_inputs() + , m_tolerance(0) + , m_enabled(false) +{ +} + +void InputChord::updateFromPeer(Qt3DCore::QNode *peer) +{ + QInputChord *input = static_cast<QInputChord *>(peer); + m_enabled = input->isEnabled(); + m_tolerance = input->tolerance(); + Q_FOREACH (QAbstractActionInput *i, input->inputs()) + m_inputs.push_back(i->id()); +} + +void InputChord::cleanup() +{ + m_enabled = false; + m_tolerance = 0; + m_inputs.clear(); +} + +void InputChord::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +{ + if (e->type() == Qt3DCore::NodeUpdated) { + Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e); + if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { + m_enabled = propertyChange->value().toBool(); + } else if (propertyChange->propertyName() == QByteArrayLiteral("tolerance")) { + m_tolerance = propertyChange->value().toInt(); + } + } +} + +} // namespace Input + +} // namespace Qt3DInput + +QT_END_NAMESPACE + diff --git a/src/input/backend/inputchord_p.h b/src/input/backend/inputchord_p.h new file mode 100644 index 000000000..a8870e531 --- /dev/null +++ b/src/input/backend/inputchord_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 QT3DINPUT_INPUT_INPUTCHORD_H +#define QT3DINPUT_INPUT_INPUTCHORD_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 Q_AUTOTEST_EXPORT InputChord : public Qt3DCore::QBackendNode +{ +public: + InputChord(); + void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE; + void cleanup(); + + inline QVector<Qt3DCore::QNodeId> inputs() const { return m_inputs; } + inline int tolerance() const { return m_tolerance; } + inline bool isEnabled() const { return m_enabled; } + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + +private: + QVector<Qt3DCore::QNodeId> m_inputs; + int m_tolerance; + bool m_enabled; +}; + +} // namespace Input + +} // namespace Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_INPUT_INPUTCHORD_H diff --git a/src/input/backend/inputhandler.cpp b/src/input/backend/inputhandler.cpp index ea3fbf9f6..8fdef2bf2 100644 --- a/src/input/backend/inputhandler.cpp +++ b/src/input/backend/inputhandler.cpp @@ -63,6 +63,8 @@ InputHandler::InputHandler() , m_axisActionHandlerManager(new AxisActionHandlerManager()) , m_axisSettingManager(new AxisSettingManager()) , m_actionInputManager(new ActionInputManager()) + , m_inputChordManager(new InputChordManager()) + , m_inputSequenceManager(new InputSequenceManager()) , m_logicalDeviceManager(new LogicalDeviceManager()) , m_genericPhysicalDeviceBackendNodeManager(new GenericDeviceBackendNodeManager) { diff --git a/src/input/backend/inputhandler_p.h b/src/input/backend/inputhandler_p.h index 6c55614d0..97b7da6a2 100644 --- a/src/input/backend/inputhandler_p.h +++ b/src/input/backend/inputhandler_p.h @@ -78,6 +78,8 @@ class ActionManager; class AxisInputManager; class AxisSettingManager; class ActionInputManager; +class InputChordManager; +class InputSequenceManager; class LogicalDeviceManager; class GenericPhysicalDeviceManager; class GenericDeviceBackendNodeManager; @@ -99,6 +101,8 @@ public: inline AxisActionHandlerManager *axisActionHandlerManager() const { return m_axisActionHandlerManager; } inline AxisSettingManager *axisSettingManager() const { return m_axisSettingManager; } inline ActionInputManager *actionInputManager() const { return m_actionInputManager; } + inline InputChordManager *inputChordManager() const { return m_inputChordManager; } + inline InputSequenceManager *inputSequenceManager() const { return m_inputSequenceManager; } inline LogicalDeviceManager *logicalDeviceManager() const { return m_logicalDeviceManager; } inline GenericDeviceBackendNodeManager *genericDeviceBackendNodeManager() const { return m_genericPhysicalDeviceBackendNodeManager; } @@ -146,6 +150,8 @@ private: AxisActionHandlerManager *m_axisActionHandlerManager; AxisSettingManager *m_axisSettingManager; ActionInputManager *m_actionInputManager; + InputChordManager *m_inputChordManager; + InputSequenceManager *m_inputSequenceManager; LogicalDeviceManager *m_logicalDeviceManager; GenericDeviceBackendNodeManager *m_genericPhysicalDeviceBackendNodeManager; QVector<Qt3DInput::QInputDeviceIntegration *> m_inputDeviceIntegrations; diff --git a/src/input/backend/inputmanagers_p.h b/src/input/backend/inputmanagers_p.h index f6c5408c2..7d1885376 100644 --- a/src/input/backend/inputmanagers_p.h +++ b/src/input/backend/inputmanagers_p.h @@ -56,6 +56,8 @@ #include <Qt3DInput/private/mouseinput_p.h> #include <Qt3DCore/private/qresourcemanager_p.h> #include <Qt3DInput/private/actioninput_p.h> +#include <Qt3DInput/private/inputsequence_p.h> +#include <Qt3DInput/private/inputchord_p.h> #include <Qt3DInput/private/axisinput_p.h> #include <Qt3DInput/private/action_p.h> #include <Qt3DInput/private/axis_p.h> @@ -176,6 +178,26 @@ public: ActionInputManager() {} }; +class InputChordManager : public Qt3DCore::QResourceManager< + InputChord, + Qt3DCore::QNodeId, + 16, + Qt3DCore::ArrayAllocatingPolicy> +{ +public: + InputChordManager() {} +}; + +class InputSequenceManager : public Qt3DCore::QResourceManager< + InputSequence, + Qt3DCore::QNodeId, + 16, + Qt3DCore::ArrayAllocatingPolicy> +{ +public: + InputSequenceManager() {} +}; + class LogicalDeviceManager : public Qt3DCore::QResourceManager< LogicalDevice, Qt3DCore::QNodeId, diff --git a/src/input/backend/inputsequence.cpp b/src/input/backend/inputsequence.cpp new file mode 100644 index 000000000..cb648a105 --- /dev/null +++ b/src/input/backend/inputsequence.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 "inputsequence_p.h" +#include <Qt3DInput/qinputsequence.h> +#include <Qt3DInput/qabstractphysicaldevice.h> +#include <Qt3DCore/qscenepropertychange.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +namespace Input { + +InputSequence::InputSequence() + : Qt3DCore::QBackendNode() + , m_inputs() + , m_timeout(0) + , m_interval(0) + , m_sequential(true) + , m_enabled(false) +{ +} + +void InputSequence::updateFromPeer(Qt3DCore::QNode *peer) +{ + QInputSequence *input = static_cast<QInputSequence *>(peer); + m_enabled = input->isEnabled(); + m_timeout = input->timeout(); + m_interval = input->interval(); + m_sequential = input->sequential(); + Q_FOREACH (QAbstractActionInput *i, input->inputs()) + m_inputs.push_back(i->id()); +} + +void InputSequence::cleanup() +{ + m_enabled = false; + m_timeout = 0; + m_interval = 0; + m_sequential = true; + m_inputs.clear(); +} + +void InputSequence::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +{ + if (e->type() == Qt3DCore::NodeUpdated) { + Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e); + if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { + m_enabled = propertyChange->value().toBool(); + } else if (propertyChange->propertyName() == QByteArrayLiteral("timeout")) { + m_timeout = propertyChange->value().toInt(); + } else if (propertyChange->propertyName() == QByteArrayLiteral("interval")) { + m_interval = propertyChange->value().toInt(); + } else if (propertyChange->propertyName() == QByteArrayLiteral("sequential")) { + m_sequential = propertyChange->value().toBool(); + } + } +} + +} // namespace Input + +} // namespace Qt3DInput + +QT_END_NAMESPACE + diff --git a/src/input/backend/inputsequence_p.h b/src/input/backend/inputsequence_p.h new file mode 100644 index 000000000..ef916aa7c --- /dev/null +++ b/src/input/backend/inputsequence_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 QT3DINPUT_INPUT_INPUTSEQUENCE_H +#define QT3DINPUT_INPUT_INPUTSEQUENCE_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 Q_AUTOTEST_EXPORT InputSequence : public Qt3DCore::QBackendNode +{ +public: + InputSequence(); + void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE; + void cleanup(); + + inline QVector<Qt3DCore::QNodeId> inputs() const { return m_inputs; } + inline int timeout() const { return m_timeout; } + inline int interval() const { return m_interval; } + inline bool isSequential() const { return m_sequential; } + inline bool isEnabled() const { return m_enabled; } + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + +private: + QVector<Qt3DCore::QNodeId> m_inputs; + int m_timeout; + int m_interval; + bool m_sequential; + bool m_enabled; +}; + +} // namespace Input + +} // namespace Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_INPUT_INPUTSEQUENCE_H diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index 4c6c9d340..942ac9250 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -62,6 +62,8 @@ #include <Qt3DInput/qaxisinput.h> #include <Qt3DInput/qaxissetting.h> #include <Qt3DInput/qactioninput.h> +#include <Qt3DInput/qinputchord.h> +#include <Qt3DInput/qinputsequence.h> #include <Qt3DInput/qlogicaldevice.h> #include <Qt3DInput/qabstractphysicaldevice.h> #include <Qt3DInput/private/axis_p.h> @@ -70,6 +72,8 @@ #include <Qt3DInput/private/axisinput_p.h> #include <Qt3DInput/private/axissetting_p.h> #include <Qt3DInput/private/actioninput_p.h> +#include <Qt3DInput/private/inputchord_p.h> +#include <Qt3DInput/private/inputsequence_p.h> #include <Qt3DInput/private/logicaldevice_p.h> #include <Qt3DInput/private/inputbackendnodefunctor_p.h> #include <Qt3DInput/private/inputmanagers_p.h> @@ -114,6 +118,8 @@ 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<QInputChord>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::InputChord, Input::InputChordManager>(d_func()->m_inputHandler->inputChordManager()))); + registerBackendType<QInputSequence>(QBackendNodeFunctorPtr(new Input::InputNodeFunctor<Input::InputSequence, Input::InputSequenceManager>(d_func()->m_inputHandler->inputSequenceManager()))); registerBackendType<Qt3DInput::QAxisActionHandler>(QBackendNodeFunctorPtr(new Input::AxisActionHandlerNodeFunctor(d_func()->m_inputHandler->axisActionHandlerManager()))); registerBackendType<QLogicalDevice>(QBackendNodeFunctorPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager()))); registerBackendType<QGenericInputDevice>(QBackendNodeFunctorPtr(new Input::GenericDeviceBackendFunctor(this, d_func()->m_inputHandler.data()))); |