summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire350@gmail.com>2015-11-28 11:02:57 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-11-28 15:01:51 +0000
commitf08480891b1f0ec88268fb69c4dadf34f6cc833e (patch)
treedc9ccd46392b7b921dc46a27522c04c744fdce35 /src
parent1963656636c9bcf576922db65cd8451be07e3077 (diff)
QActionInput: keys specified as a bit mask directly
Change-Id: Idbc36d2a391fa2dcf21735f85a5b2d3859c97450 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/input/backend/actioninput.cpp18
-rw-r--r--src/input/frontend/qactioninput.cpp9
-rw-r--r--src/input/frontend/qactioninput.h6
3 files changed, 10 insertions, 23 deletions
diff --git a/src/input/backend/actioninput.cpp b/src/input/backend/actioninput.cpp
index 7abda9285..694623c50 100644
--- a/src/input/backend/actioninput.cpp
+++ b/src/input/backend/actioninput.cpp
@@ -45,30 +45,18 @@ namespace Qt3DInput {
namespace Input {
-namespace {
-
-qint64 keysToBitArray(const QVariantList &keys)
-{
- qint64 keyBits;
- Q_FOREACH (const QVariant &key, keys)
- keyBits |= key.toInt();
- return keyBits;
-}
-
-} // anonymous
-
ActionInput::ActionInput()
: Qt3DCore::QBackendNode()
+ , m_keys(0)
, m_enabled(false)
{
-
}
void ActionInput::updateFromPeer(Qt3DCore::QNode *peer)
{
QActionInput *input = static_cast<QActionInput *>(peer);
m_enabled = input->isEnabled();
- m_keys = keysToBitArray(input->keys());
+ m_keys = input->keys();
if (input->sourceDevice())
m_sourceDevice = input->sourceDevice()->id();
}
@@ -89,7 +77,7 @@ void ActionInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
} else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) {
m_enabled = propertyChange->value().toBool();
} else if (propertyChange->propertyName() == QByteArrayLiteral("keys")) {
- m_keys = keysToBitArray(propertyChange->value().value<QVariantList>());
+ m_keys = propertyChange->value().toInt();
}
}
}
diff --git a/src/input/frontend/qactioninput.cpp b/src/input/frontend/qactioninput.cpp
index 47a85cc3c..54531df06 100644
--- a/src/input/frontend/qactioninput.cpp
+++ b/src/input/frontend/qactioninput.cpp
@@ -46,10 +46,11 @@ class QActionInputPrivate : public Qt3DCore::QNodePrivate
public:
QActionInputPrivate()
: Qt3DCore::QNodePrivate()
+ , m_keys(0)
, m_sourceDevice(Q_NULLPTR)
{}
- QVariantList m_keys;
+ int m_keys;
QAbstractPhysicalDevice *m_sourceDevice;
};
@@ -63,14 +64,12 @@ QActionInput::~QActionInput()
QNode::cleanup();
}
-QVariantList QActionInput::keys() const
+int QActionInput::keys() const
{
Q_D(const QActionInput);
return d->m_keys;
}
-
-
void QActionInput::setSourceDevice(QAbstractPhysicalDevice *sourceDevice)
{
Q_D(QActionInput);
@@ -92,7 +91,7 @@ QAbstractPhysicalDevice *QActionInput::sourceDevice() const
return d->m_sourceDevice;
}
-void QActionInput::setKeys(const QVariantList &keys)
+void QActionInput::setKeys(int keys)
{
Q_D(QActionInput);
if (d->m_keys != keys) {
diff --git a/src/input/frontend/qactioninput.h b/src/input/frontend/qactioninput.h
index 37e9c7957..537e7e1e0 100644
--- a/src/input/frontend/qactioninput.h
+++ b/src/input/frontend/qactioninput.h
@@ -51,7 +51,7 @@ class QT3DINPUTSHARED_EXPORT QActionInput : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DInput::QAbstractPhysicalDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged)
- Q_PROPERTY(QVariantList keys READ keys WRITE setKeys NOTIFY keysChanged)
+ Q_PROPERTY(int keys READ keys WRITE setKeys NOTIFY keysChanged)
public:
explicit QActionInput(Qt3DCore::QNode *parent = Q_NULLPTR);
@@ -60,8 +60,8 @@ public:
void setSourceDevice(QAbstractPhysicalDevice *sourceDevice);
QAbstractPhysicalDevice *sourceDevice() const;
- void setKeys(const QVariantList &keys);
- QVariantList keys() const;
+ void setKeys(int keys);
+ int keys() const;
Q_SIGNALS:
void sourceDeviceChanged();