summaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-12-08 09:39:22 +0000
committerSean Harmer <sean.harmer@kdab.com>2015-12-09 16:55:02 +0000
commit4fc1f58689ac91ff9e338d58e82727eb7ad7cc62 (patch)
tree31e01637f51291df921bfb7fc13bc6687a913c0d /src/input
parent94f3df1aacab5853d09e79596eb3bdae3aecae0a (diff)
Use lists of ints for axes on axis settings
Change-Id: Ie1cc4b46f7888f4e9ecdecb0b204c30703da36ee Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r--src/input/backend/axissetting.cpp20
-rw-r--r--src/input/backend/axissetting_p.h4
-rw-r--r--src/input/frontend/qaxissetting.cpp8
-rw-r--r--src/input/frontend/qaxissetting.h8
4 files changed, 27 insertions, 13 deletions
diff --git a/src/input/backend/axissetting.cpp b/src/input/backend/axissetting.cpp
index eac5fa09c..407308649 100644
--- a/src/input/backend/axissetting.cpp
+++ b/src/input/backend/axissetting.cpp
@@ -40,6 +40,20 @@
QT_BEGIN_NAMESPACE
+namespace {
+
+QVector<int> variantListToVector(const QVariantList &list)
+{
+ QVector<int> v(list.size());
+ int i = 0;
+ Q_FOREACH (const QVariant &e, list) {
+ v[i++] = e.toInt();
+ }
+ return v;
+}
+
+}
+
namespace Qt3DInput {
namespace Input {
@@ -55,14 +69,14 @@ void AxisSetting::updateFromPeer(Qt3DCore::QNode *peer)
{
QAxisSetting *setting = static_cast<QAxisSetting *>(peer);
m_deadZone = setting->deadZone();
- m_axes = setting->axes();
+ m_axes = variantListToVector(setting->axes());
m_filter = setting->isFilterEnabled();
}
void AxisSetting::cleanup()
{
m_deadZone = 0.0f;
- m_axes = 0;
+ m_axes.clear();
m_filter = false;
}
@@ -73,7 +87,7 @@ void AxisSetting::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
if (propertyChange->propertyName() == QByteArrayLiteral("deadZone")) {
m_deadZone = propertyChange->value().toFloat();
} else if (propertyChange->propertyName() == QByteArrayLiteral("axes")) {
- m_axes = propertyChange->value().toInt();
+ m_axes = variantListToVector(propertyChange->value().toList());
} else if (propertyChange->propertyName() == QByteArrayLiteral("filter")) {
m_filter = propertyChange->value().toBool();
}
diff --git a/src/input/backend/axissetting_p.h b/src/input/backend/axissetting_p.h
index 38d99b85b..7464a5b08 100644
--- a/src/input/backend/axissetting_p.h
+++ b/src/input/backend/axissetting_p.h
@@ -64,7 +64,7 @@ public:
void cleanup();
inline float deadZone() const { return m_deadZone; }
- inline int axes() const { return m_axes; }
+ inline QVector<int> axes() const { return m_axes; }
inline bool isFilterEnabled() const { return m_filter; }
protected:
@@ -72,7 +72,7 @@ protected:
private:
float m_deadZone;
- int m_axes;
+ QVector<int> m_axes;
bool m_filter;
};
diff --git a/src/input/frontend/qaxissetting.cpp b/src/input/frontend/qaxissetting.cpp
index eee0be04b..5590200a3 100644
--- a/src/input/frontend/qaxissetting.cpp
+++ b/src/input/frontend/qaxissetting.cpp
@@ -47,12 +47,12 @@ public:
QAxisSettingPrivate()
: Qt3DCore::QNodePrivate()
, m_deadZone(0.0f)
- , m_axes(0)
+ , m_axes()
, m_filter(false)
{}
float m_deadZone;
- int m_axes;
+ QVariantList m_axes;
bool m_filter;
};
@@ -66,7 +66,7 @@ QAxisSetting::~QAxisSetting()
QNode::cleanup();
}
-int QAxisSetting::axes() const
+QVariantList QAxisSetting::axes() const
{
Q_D(const QAxisSetting);
return d->m_axes;
@@ -94,7 +94,7 @@ void QAxisSetting::setDeadZone(float deadZone)
emit deadZoneChanged(deadZone);
}
-void QAxisSetting::setAxes(int axes)
+void QAxisSetting::setAxes(const QVariantList &axes)
{
Q_D(QAxisSetting);
if (d->m_axes == axes)
diff --git a/src/input/frontend/qaxissetting.h b/src/input/frontend/qaxissetting.h
index 1737b5bb2..8c6c2ac25 100644
--- a/src/input/frontend/qaxissetting.h
+++ b/src/input/frontend/qaxissetting.h
@@ -52,7 +52,7 @@ class QT3DINPUTSHARED_EXPORT QAxisSetting : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(float deadZone READ deadZone WRITE setDeadZone NOTIFY deadZoneChanged)
- Q_PROPERTY(int axes READ axes WRITE setAxes NOTIFY axesChanged)
+ Q_PROPERTY(QVariantList axes READ axes WRITE setAxes NOTIFY axesChanged)
Q_PROPERTY(bool filter READ isFilterEnabled WRITE setFilterEnabled NOTIFY filterChanged)
public:
@@ -60,17 +60,17 @@ public:
~QAxisSetting();
float deadZone() const;
- int axes() const;
+ QVariantList axes() const;
bool isFilterEnabled() const;
public Q_SLOTS:
void setDeadZone(float deadZone);
- void setAxes(int axes);
+ void setAxes(const QVariantList &axes);
void setFilterEnabled(bool enabled);
Q_SIGNALS:
void deadZoneChanged(float deadZone);
- void axesChanged(int axes);
+ void axesChanged(QVariantList axes);
void filterChanged(bool filter);
protected: