summaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/input')
-rw-r--r--src/input/backend/inputhandler.cpp1
-rw-r--r--src/input/backend/logicaldevice_p.h3
-rw-r--r--src/input/backend/mousedevice.cpp18
-rw-r--r--src/input/backend/mousedevice_p.h5
-rw-r--r--src/input/backend/updateaxisactionjob.cpp4
-rw-r--r--src/input/frontend/frontend.pri7
-rw-r--r--src/input/frontend/qaxisaccumulator.cpp274
-rw-r--r--src/input/frontend/qaxisaccumulator.h99
-rw-r--r--src/input/frontend/qaxisaccumulator_p.h87
-rw-r--r--src/input/frontend/qinputaspect.cpp7
-rw-r--r--src/input/frontend/qmousedevice.cpp15
-rw-r--r--src/input/frontend/qmousedevice.h4
12 files changed, 511 insertions, 13 deletions
diff --git a/src/input/backend/inputhandler.cpp b/src/input/backend/inputhandler.cpp
index 82b017b1c..fe2a04bd7 100644
--- a/src/input/backend/inputhandler.cpp
+++ b/src/input/backend/inputhandler.cpp
@@ -249,6 +249,7 @@ QVector<Qt3DCore::QAspectJobPtr> InputHandler::mouseJobs()
MouseDevice *controller = m_mouseDeviceManager->data(cHandle);
controller->updateMouseEvents(mouseEvents);
+ controller->updateWheelEvents(wheelEvents);
// Event dispacthing job
if (!mouseEvents.isEmpty() || !wheelEvents.empty()) {
// Send the events to the mouse handlers that have for sourceDevice controller
diff --git a/src/input/backend/logicaldevice_p.h b/src/input/backend/logicaldevice_p.h
index a7fdcd0ef..38d4e2dd5 100644
--- a/src/input/backend/logicaldevice_p.h
+++ b/src/input/backend/logicaldevice_p.h
@@ -62,7 +62,7 @@ namespace Input {
class LogicalDeviceManager;
-class LogicalDevice : public Qt3DCore::QBackendNode
+class Q_AUTOTEST_EXPORT LogicalDevice : public Qt3DCore::QBackendNode
{
public:
LogicalDevice();
@@ -71,7 +71,6 @@ public:
inline QVector<Qt3DCore::QNodeId> axes() const { return m_axes; }
inline QVector<Qt3DCore::QNodeId> actions() const { return m_actions; }
-protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
private:
diff --git a/src/input/backend/mousedevice.cpp b/src/input/backend/mousedevice.cpp
index a2f106d94..e649824a4 100644
--- a/src/input/backend/mousedevice.cpp
+++ b/src/input/backend/mousedevice.cpp
@@ -84,7 +84,10 @@ float MouseDevice::axisValue(int axisIdentifier) const
return m_mouseState.xAxis;
case QMouseDevice::Y:
return m_mouseState.yAxis;
- break;
+ case QMouseDevice::WheelX:
+ return m_mouseState.wXAxis;
+ case QMouseDevice::WheelY:
+ return m_mouseState.wYAxis;
default:
break;
}
@@ -106,6 +109,19 @@ bool MouseDevice::isButtonPressed(int buttonIdentifier) const
return false;
}
+void MouseDevice::updateWheelEvents(const QList<QT_PREPEND_NAMESPACE (QWheelEvent)> &events)
+{
+ // Reset axis values before we accumulate new values for this frame
+ m_mouseState.wXAxis = 0.0f;
+ m_mouseState.wYAxis = 0.0f;
+ if (!events.isEmpty()) {
+ for (const QT_PREPEND_NAMESPACE(QWheelEvent) &e : events) {
+ m_mouseState.wXAxis += m_sensitivity * e.angleDelta().x();
+ m_mouseState.wYAxis += m_sensitivity * e.angleDelta().y();
+ }
+ }
+}
+
void MouseDevice::updateMouseEvents(const QList<QT_PREPEND_NAMESPACE(QMouseEvent)> &events)
{
// Reset axis values before we accumulate new values for this frame
diff --git a/src/input/backend/mousedevice_p.h b/src/input/backend/mousedevice_p.h
index 723945554..02a6d916e 100644
--- a/src/input/backend/mousedevice_p.h
+++ b/src/input/backend/mousedevice_p.h
@@ -76,6 +76,7 @@ public:
bool isButtonPressed(int buttonIdentifier) const Q_DECL_OVERRIDE;
void updateMouseEvents(const QList<QT_PREPEND_NAMESPACE(QMouseEvent)> &events);
+ void updateWheelEvents(const QList<QT_PREPEND_NAMESPACE(QWheelEvent)> &events);
protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
@@ -90,6 +91,8 @@ private:
MouseState()
: xAxis(0.0f)
, yAxis(0.0f)
+ , wXAxis(0.0f)
+ , wYAxis(0.0f)
, leftPressed(false)
, rightPressed(false)
, centerPressed(false)
@@ -97,6 +100,8 @@ private:
float xAxis;
float yAxis;
+ float wXAxis;
+ float wYAxis;
bool leftPressed;
bool rightPressed;
bool centerPressed;
diff --git a/src/input/backend/updateaxisactionjob.cpp b/src/input/backend/updateaxisactionjob.cpp
index 0cbd325c9..bbd36228e 100644
--- a/src/input/backend/updateaxisactionjob.cpp
+++ b/src/input/backend/updateaxisactionjob.cpp
@@ -80,6 +80,10 @@ void UpdateAxisActionJob::run()
// Note: we assume axis/action are not really shared:
// there's no benefit in sharing those when it comes to computing
LogicalDevice *device = m_handler->logicalDeviceManager()->data(m_handle);
+
+ if (!device->isEnabled())
+ return;
+
updateAction(device);
updateAxis(device);
}
diff --git a/src/input/frontend/frontend.pri b/src/input/frontend/frontend.pri
index 93b3e0839..67c93d2b9 100644
--- a/src/input/frontend/frontend.pri
+++ b/src/input/frontend/frontend.pri
@@ -43,7 +43,9 @@ HEADERS += \
$$PWD/qinputsequence_p.h \
$$PWD/qinputchord_p.h \
$$PWD/qphysicaldevicecreatedchange.h \
- $$PWD/qphysicaldevicecreatedchange_p.h
+ $$PWD/qphysicaldevicecreatedchange_p.h \
+ $$PWD/qaxisaccumulator.h \
+ $$PWD/qaxisaccumulator_p.h
SOURCES += \
@@ -71,7 +73,8 @@ SOURCES += \
$$PWD/qinputchord.cpp \
$$PWD/qinputsequence.cpp \
$$PWD/qinputsettings.cpp \
- $$PWD/qphysicaldevicecreatedchange.cpp
+ $$PWD/qphysicaldevicecreatedchange.cpp \
+ $$PWD/qaxisaccumulator.cpp
qtHaveModule(gamepad) {
QT += gamepad
diff --git a/src/input/frontend/qaxisaccumulator.cpp b/src/input/frontend/qaxisaccumulator.cpp
new file mode 100644
index 000000000..d205bce16
--- /dev/null
+++ b/src/input/frontend/qaxisaccumulator.cpp
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaxisaccumulator.h"
+#include "qaxisaccumulator_p.h"
+#include <Qt3DInput/qaxis.h>
+#include <Qt3DCore/qnodecreatedchange.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+/*!
+ Constructs a new QAxisAccumulator instance with \a parent.
+ \class Qt3DInput::QAxisAccumulator
+ \inmodule Qt3DInput
+ \inherits Qt3DCore::QNode
+ \brief QAxisAccumulator processes velocity or acceleration data from a QAxis.
+ \since 5.8
+
+ A Qt3DInput::QAxis reports the current position of an axis on an input
+ device. When the axis is returned to its neutral position the value of that
+ axis returns to 0. Often, it is required to have the input from an axis
+ control a variable in other ways, for example treating the value from the
+ Qt3DInput::QAxis as a velocity (first derivative with respect to time) or
+ as an acceleration (second derivative with respect to time). This can be
+ done with user code or with a Qt3DLogic::QFrameAction but those approached
+ are not ideal as they add more work to the main thread and are inherently
+ imperative. The Qt3DInput::QAxisAccumulator class allows for this common
+ task to be performed on the Qt 3D backend and be specified in a declarative
+ manner.
+*/
+
+/*!
+ \qmltype AxisAccumulator
+ \inqmlmodule Qt3D.Input
+ \instantiates Qt3DInput::QAxisAccumulator
+ \brief QML frontend for the Qt3DInput::QAxisAccumulator C++ class.
+ \since 5.8
+
+ An Axis reports the current position of an axis on an input device. When the
+ axis is returned to its neutral position the value of that axis returns to 0.
+ Often, it is required to have the input from an axis control a variable in
+ other ways, for example treating the value from the Axis as a velocity (first
+ derivative with respect to time) or as an acceleration (second derivative with
+ respect to time). This can be done with user code or with a FrameAction but
+ those approached are not ideal as they add more work to the main thread and
+ are inherently imperative. The AxisAccumulator class allows for this common
+ task to be performed on the Qt 3D backend and be specified in a declarative
+ manner.
+*/
+
+/*!
+ \qmlproperty int Qt3D.Inpit::Axis::value
+ \readonly
+
+ Holds the value accumulated from the sourceAxis.
+*/
+
+/*!
+ * \enum Qt3DInput::QAxisAccumulator::SourceAxisType
+ *
+ * \value Velocity
+ * \value Acceleration
+ */
+
+/*! \internal */
+QAxisAccumulatorPrivate::QAxisAccumulatorPrivate()
+ : Qt3DCore::QNodePrivate()
+ , m_sourceAxis(nullptr)
+ , m_sourceAxisType(QAxisAccumulator::Velocity)
+ , m_scale(1.0f)
+ , m_value(0.0f)
+{
+}
+
+/*! \internal */
+void QAxisAccumulatorPrivate::setValue(float value)
+{
+ if (value != m_value) {
+ m_value = value;
+ q_func()->valueChanged(m_value);
+ }
+}
+
+/*!
+ Constructs a new QAxisAccumulator instance with parent \a parent.
+ */
+QAxisAccumulator::QAxisAccumulator(Qt3DCore::QNode *parent)
+ : Qt3DCore::QNode(*new QAxisAccumulatorPrivate, parent)
+{
+}
+
+/*! \internal */
+QAxisAccumulator::~QAxisAccumulator()
+{
+}
+
+/*!
+ \qmlproperty Axis Qt3D.Input::AxisAccumulator::sourceAxis
+
+ The Axis for which the accumulator should integrate axis values.
+ */
+
+/*!
+ \return QAxis for which the accumulator should integrate axis values.
+ */
+QAxis *QAxisAccumulator::sourceAxis() const
+{
+ Q_D(const QAxisAccumulator);
+ return d->m_sourceAxis;
+}
+
+/*!
+ \qmlproperty SourceAxisType Qt3D.Input::AxisAccumulator::sourceAxisType
+
+ The sourceAxisType property specifies how the accumulator treats the values
+ from the source axis.
+ */
+
+/*!
+ \return how the accumulator treats the value of the sourceAxis.
+ */
+QAxisAccumulator::SourceAxisType QAxisAccumulator::sourceAxisType() const
+{
+ Q_D(const QAxisAccumulator);
+ return d->m_sourceAxisType;
+}
+
+/*!
+ \qmlproperty real Qt3D.Input::AxisAccumulator::value
+
+ The accumulated (integrated) value.
+ */
+
+/*!
+ \return the accumulated (integrated) value.
+ */
+float QAxisAccumulator::value() const
+{
+ Q_D(const QAxisAccumulator);
+ return d->m_value;
+}
+
+/*!
+ \qmlproperty real Qt3D.Input::AxisAccumulator::value
+
+ The amount to scale the axis value by when accumulating. This can be
+ thought of as the maximum velocity or acceleration the axis can
+ control.
+ */
+
+/*!
+ The amount to scale the axis value by when accumulating. This can be
+ thought of as the maximum velocity or acceleration the axis can
+ control.
+
+ \return the amount the input axis values are scaled by.
+ */
+float QAxisAccumulator::scale() const
+{
+ Q_D(const QAxisAccumulator);
+ return d->m_scale;
+}
+
+/*!
+ Sets the source axis from which the accumulator should receive values from to
+ \a sourceAxis. How these values are treated is controlled by the sourceAxisType
+ and scale properties.
+ */
+void QAxisAccumulator::setSourceAxis(QAxis *sourceAxis)
+{
+ Q_D(QAxisAccumulator);
+ if (d->m_sourceAxis == sourceAxis)
+ return;
+
+ if (d->m_sourceAxis)
+ d->unregisterDestructionHelper(d->m_sourceAxis);
+
+ if (sourceAxis && !sourceAxis->parent())
+ sourceAxis->setParent(this);
+ d->m_sourceAxis = sourceAxis;
+
+ // Ensures proper bookkeeping
+ if (d->m_sourceAxis)
+ d->registerDestructionHelper(d->m_sourceAxis, &QAxisAccumulator::setSourceAxis, d->m_sourceAxis);
+
+ emit sourceAxisChanged(sourceAxis);
+}
+
+/*!
+ Sets how the accumulator treats the values originating from the source axis.
+ */
+void QAxisAccumulator::setSourceAxisType(QAxisAccumulator::SourceAxisType sourceAxisType)
+{
+ Q_D(QAxisAccumulator);
+ if (d->m_sourceAxisType == sourceAxisType)
+ return;
+
+ d->m_sourceAxisType = sourceAxisType;
+ emit sourceAxisTypeChanged(sourceAxisType);
+}
+
+void QAxisAccumulator::setScale(float scale)
+{
+ Q_D(QAxisAccumulator);
+ if (d->m_scale == scale)
+ return;
+
+ d->m_scale = scale;
+ emit scaleChanged(scale);
+}
+
+/*! \internal */
+void QAxisAccumulator::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QAxisAccumulator);
+ auto e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
+ if (e->type() == Qt3DCore::PropertyUpdated && e->propertyName() == QByteArrayLiteral("value"))
+ d->setValue(e->value().toFloat());
+}
+
+/*! \internal */
+Qt3DCore::QNodeCreatedChangeBasePtr QAxisAccumulator::createNodeCreationChange() const
+{
+ auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAxisAccumulatorData>::create(this);
+ auto &data = creationChange->data;
+ Q_D(const QAxisAccumulator);
+ data.sourceAxisId = qIdForNode(d->m_sourceAxis);
+ data.sourceAxisType = d->m_sourceAxisType;
+ data.scale = d->m_scale;
+ return creationChange;
+}
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
diff --git a/src/input/frontend/qaxisaccumulator.h b/src/input/frontend/qaxisaccumulator.h
new file mode 100644
index 000000000..c62e4c35f
--- /dev/null
+++ b/src/input/frontend/qaxisaccumulator.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QAXISACCUMULATOR_H
+#define QT3DINPUT_QAXISACCUMULATOR_H
+
+#include <Qt3DInput/qt3dinput_global.h>
+#include <Qt3DCore/qnode.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAxis;
+class QAxisAccumulatorPrivate;
+
+class QT3DINPUTSHARED_EXPORT QAxisAccumulator : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DInput::QAxis *sourceAxis READ sourceAxis WRITE setSourceAxis NOTIFY sourceAxisChanged)
+ Q_PROPERTY(SourceAxisType sourceAxisType READ sourceAxisType WRITE setSourceAxisType NOTIFY sourceAxisTypeChanged)
+ Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(float value READ value NOTIFY valueChanged)
+
+public:
+ enum SourceAxisType {
+ Velocity,
+ Acceleration
+ };
+ Q_ENUM(SourceAxisType)
+
+ QAxisAccumulator(Qt3DCore::QNode *parent = nullptr);
+ ~QAxisAccumulator();
+
+ Qt3DInput::QAxis *sourceAxis() const;
+ SourceAxisType sourceAxisType() const;
+ float value() const;
+ float scale() const;
+
+public Q_SLOTS:
+ void setSourceAxis(Qt3DInput::QAxis *sourceAxis);
+ void setSourceAxisType(QAxisAccumulator::SourceAxisType sourceAxisType);
+ void setScale(float scale);
+
+Q_SIGNALS:
+ void sourceAxisChanged(Qt3DInput::QAxis *sourceAxis);
+ void sourceAxisTypeChanged(QAxisAccumulator::SourceAxisType sourceAxisType);
+ void valueChanged(float value);
+ void scaleChanged(float scale);
+
+protected:
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
+
+private:
+ Q_DECLARE_PRIVATE(QAxisAccumulator)
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE;
+};
+
+} // namespace Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QAXISACCUMULATOR_H
diff --git a/src/input/frontend/qaxisaccumulator_p.h b/src/input/frontend/qaxisaccumulator_p.h
new file mode 100644
index 000000000..a07284009
--- /dev/null
+++ b/src/input/frontend/qaxisaccumulator_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DINPUT_QAXISACCUMULATOR_P_H
+#define QT3DINPUT_QAXISACCUMULATOR_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/private/qnode_p.h>
+#include <Qt3DInput/qaxisaccumulator.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DInput {
+
+class QAxisAccumulatorPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ QAxisAccumulatorPrivate();
+
+ Q_DECLARE_PUBLIC(QAxisAccumulator)
+
+ void setValue(float value);
+
+ QAxis *m_sourceAxis;
+ QAxisAccumulator::SourceAxisType m_sourceAxisType;
+ float m_scale;
+ float m_value;
+};
+
+struct QAxisAccumulatorData
+{
+ Qt3DCore::QNodeId sourceAxisId;
+ QAxisAccumulator::SourceAxisType sourceAxisType;
+ float scale;
+};
+
+} // Qt3DInput
+
+QT_END_NAMESPACE
+
+#endif // QT3DINPUT_QAXISACCUMULATOR_P_H
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index 342998556..d0e91a362 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -189,11 +189,12 @@ QAbstractPhysicalDevice *QInputAspect::createPhysicalDevice(const QString &name)
{
Q_D(QInputAspect);
const auto integrations = d->m_inputHandler->inputDeviceIntegrations();
+ QAbstractPhysicalDevice *device = nullptr;
for (Qt3DInput::QInputDeviceIntegration *integration : integrations) {
- if (auto dev = integration->createPhysicalDevice(name))
- return dev;
+ if ((device = integration->createPhysicalDevice(name)) != nullptr)
+ break;
}
- return nullptr;
+ return device;
}
/*!
diff --git a/src/input/frontend/qmousedevice.cpp b/src/input/frontend/qmousedevice.cpp
index bbf42b793..56d3731ce 100644
--- a/src/input/frontend/qmousedevice.cpp
+++ b/src/input/frontend/qmousedevice.cpp
@@ -91,6 +91,8 @@ QMouseDevicePrivate::QMouseDevicePrivate()
\value X
\value Y
+ \value WheelX
+ \value WheelY
\sa Qt3DInput::QAnalogAxisInput::setAxis
*/
@@ -125,12 +127,11 @@ QMouseDevice::~QMouseDevice()
/*!
\return the axis count.
- \note Currently always returns 2.
+ \note Currently always returns 4.
*/
int QMouseDevice::axisCount() const
{
- // TO DO: we could have mouse wheel later on
- return 2;
+ return 4;
}
/*!
@@ -152,7 +153,9 @@ QStringList QMouseDevice::axisNames() const
{
return QStringList()
<< QStringLiteral("X")
- << QStringLiteral("Y");
+ << QStringLiteral("Y")
+ << QStringLiteral("WheelX")
+ << QStringLiteral("WheelY");
}
/*!
@@ -177,6 +180,10 @@ int QMouseDevice::axisIdentifier(const QString &name) const
return X;
else if (name == QLatin1String("Y"))
return Y;
+ else if (name == QLatin1String("WheelX"))
+ return WheelX;
+ else if (name == QLatin1String("WheelY"))
+ return WheelY;
return -1;
}
diff --git a/src/input/frontend/qmousedevice.h b/src/input/frontend/qmousedevice.h
index fe43c6c84..7a1f6332a 100644
--- a/src/input/frontend/qmousedevice.h
+++ b/src/input/frontend/qmousedevice.h
@@ -63,7 +63,9 @@ public:
enum Axis {
X,
- Y
+ Y,
+ WheelX,
+ WheelY
};
Q_ENUM(Axis)