summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-09-27 18:43:31 +0100
committerMike Krus <mike.krus@kdab.com>2019-10-01 07:03:59 +0100
commite532a1cf37855f79a0a662d9b07786337e5fd220 (patch)
tree63e1db51740285e44bdc32ec49f7e135b5405f97
parentecd455dc00ced212a156f678cd022c10652c8422 (diff)
Update device nodes to use direct sync
Change-Id: Ic93968816b719ff407db1d1f2f67d906fab3ca0a Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/input/backend/genericdevicebackendnode.cpp28
-rw-r--r--src/input/backend/genericdevicebackendnode_p.h2
-rw-r--r--src/input/backend/keyboarddevice.cpp5
-rw-r--r--src/input/backend/keyboarddevice_p.h3
-rw-r--r--src/input/backend/mousedevice.cpp21
-rw-r--r--src/input/backend/mousedevice_p.h4
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode.cpp90
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode_p.h8
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode_p_p.h5
-rw-r--r--src/input/frontend/qabstractphysicaldevice.cpp28
-rw-r--r--src/input/frontend/qabstractphysicaldevice_p.h3
-rw-r--r--src/input/frontend/qinputaspect.cpp6
-rw-r--r--tests/auto/input/mousedevice/tst_mousedevice.cpp18
-rw-r--r--tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp34
14 files changed, 92 insertions, 163 deletions
diff --git a/src/input/backend/genericdevicebackendnode.cpp b/src/input/backend/genericdevicebackendnode.cpp
index 40202b4a5..d56a674fc 100644
--- a/src/input/backend/genericdevicebackendnode.cpp
+++ b/src/input/backend/genericdevicebackendnode.cpp
@@ -40,10 +40,11 @@
#include "genericdevicebackendnode_p.h"
#include <Qt3DInput/qabstractphysicaldevice.h>
-#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DInput/private/inputhandler_p.h>
#include <Qt3DInput/private/inputmanagers_p.h>
+#include <Qt3DInput/private/qgenericinputdevice_p.h>
+#include <Qt3DInput/private/qabstractphysicaldevice_p.h>
QT_BEGIN_NAMESPACE
@@ -60,19 +61,24 @@ GenericDeviceBackendNode::~GenericDeviceBackendNode()
{
}
-void GenericDeviceBackendNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void GenericDeviceBackendNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (e->type() == Qt3DCore::PropertyUpdated) {
- if (propertyChange->propertyName() == QByteArrayLiteral("axisEvent")) {
- QPair<int, qreal> val = propertyChange->value().value<QPair<int, qreal>>();
- const QMutexLocker lock(&m_mutex);
+ QAbstractPhysicalDeviceBackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const Qt3DInput::QGenericInputDevice *node = qobject_cast<const Qt3DInput::QGenericInputDevice *>(frontEnd);
+ if (!node)
+ return;
+
+ auto *d = static_cast<Qt3DInput::QAbstractPhysicalDevicePrivate *>( Qt3DCore::QNodePrivate::get(const_cast<Qt3DCore::QNode *>(frontEnd)) );
+
+ {
+ const QMutexLocker lock(&m_mutex);
+ for (const auto &val: qAsConst(d->m_pendingAxisEvents))
m_axesValues[val.first] = val.second;
- } else if (propertyChange->propertyName() == QByteArrayLiteral("buttonEvent")) {
- QPair<int, qreal> val = propertyChange->value().value<QPair<int, qreal>>();
- const QMutexLocker lock(&m_mutex);
+ for (const auto &val: qAsConst(d->m_pendingButtonsEvents))
m_buttonsValues[val.first] = val.second;
- }
+
+ d->m_pendingAxisEvents.clear();
+ d->m_pendingButtonsEvents.clear();
}
}
diff --git a/src/input/backend/genericdevicebackendnode_p.h b/src/input/backend/genericdevicebackendnode_p.h
index c3ee1e467..3ae712115 100644
--- a/src/input/backend/genericdevicebackendnode_p.h
+++ b/src/input/backend/genericdevicebackendnode_p.h
@@ -73,7 +73,7 @@ public:
void updateEvents();
// QAbstractPhysicalDeviceBackendNode interface
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void cleanup() override;
float axisValue(int axisIdentifier) const override;
bool isButtonPressed(int buttonIdentifier) const override;
diff --git a/src/input/backend/keyboarddevice.cpp b/src/input/backend/keyboarddevice.cpp
index 33578bdad..0e45d1c84 100644
--- a/src/input/backend/keyboarddevice.cpp
+++ b/src/input/backend/keyboarddevice.cpp
@@ -427,11 +427,6 @@ void KeyboardDevice::updateKeyEvents(const QList<QT_PREPEND_NAMESPACE(QKeyEvent)
setButtonValue(e.key(), e.type() == QT_PREPEND_NAMESPACE(QKeyEvent)::KeyPress ? true : false);
}
-
-void KeyboardDevice::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &)
-{
-}
-
KeyboardDeviceFunctor::KeyboardDeviceFunctor(QInputAspect *inputaspect, InputHandler *handler)
: m_inputAspect(inputaspect)
, m_handler(handler)
diff --git a/src/input/backend/keyboarddevice_p.h b/src/input/backend/keyboarddevice_p.h
index 781e8ead5..2df5eb64d 100644
--- a/src/input/backend/keyboarddevice_p.h
+++ b/src/input/backend/keyboarddevice_p.h
@@ -86,9 +86,6 @@ public:
inline Qt3DCore::QNodeId currentFocusItem() const { return m_currentFocusItem; }
inline Qt3DCore::QNodeId lastKeyboardInputRequester() const { return m_lastRequester; }
-protected:
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) override;
-
private:
void setButtonValue(int key, bool value);
diff --git a/src/input/backend/mousedevice.cpp b/src/input/backend/mousedevice.cpp
index e285783b7..ab2458bc0 100644
--- a/src/input/backend/mousedevice.cpp
+++ b/src/input/backend/mousedevice.cpp
@@ -65,14 +65,6 @@ MouseDevice::~MouseDevice()
{
}
-void MouseDevice::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QMouseDeviceData>>(change);
- const auto &data = typedChange->data;
- m_sensitivity = data.sensitivity;
- QAbstractPhysicalDeviceBackendNode::initializeFromPeer(change);
-}
-
void MouseDevice::setInputHandler(InputHandler *handler)
{
m_inputHandler = handler;
@@ -173,13 +165,14 @@ void MouseDevice::updateMouseEvents(const QList<QT_PREPEND_NAMESPACE(QMouseEvent
}
}
-void MouseDevice::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void MouseDevice::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- if (e->type() == Qt3DCore::PropertyUpdated) {
- Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("sensitivity"))
- m_sensitivity = propertyChange->value().toFloat();
- }
+ QAbstractPhysicalDeviceBackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const Qt3DInput::QMouseDevice *node = qobject_cast<const Qt3DInput::QMouseDevice *>(frontEnd);
+ if (!node)
+ return;
+
+ m_sensitivity = node->sensitivity();
}
MouseDeviceFunctor::MouseDeviceFunctor(QInputAspect *inputAspect, InputHandler *handler)
diff --git a/src/input/backend/mousedevice_p.h b/src/input/backend/mousedevice_p.h
index d49ea2502..283eeaeaf 100644
--- a/src/input/backend/mousedevice_p.h
+++ b/src/input/backend/mousedevice_p.h
@@ -108,11 +108,9 @@ public:
bool wasPressed() const;
float sensitivity() const;
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
InputHandler *m_inputHandler;
MouseState m_mouseState;
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.cpp b/src/input/backend/qabstractphysicaldevicebackendnode.cpp
index 5006d702a..e9a7721d7 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode.cpp
+++ b/src/input/backend/qabstractphysicaldevicebackendnode.cpp
@@ -49,6 +49,7 @@
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <cmath>
+#include <algorithm>
#include <Qt3DInput/private/inputhandler_p.h>
#include <Qt3DInput/private/inputmanagers_p.h>
@@ -132,51 +133,14 @@ Input::AxisSetting *QAbstractPhysicalDeviceBackendNodePrivate::getAxisSetting(Qt
return axisSetting;
}
-QVector<Input::AxisIdSetting> QAbstractPhysicalDeviceBackendNodePrivate::convertToAxisIdSettingVector(Qt3DCore::QNodeId axisSettingId) const
-{
- const auto axisSetting = getAxisSetting(axisSettingId);
- const auto axisIds = axisSetting->axes();
-
- auto result = QVector<Input::AxisIdSetting>();
- result.reserve(axisIds.size());
- std::transform(axisIds.constBegin(), axisIds.constEnd(),
- std::back_inserter(result),
- [axisSettingId] (int axisId) {
- return Input::AxisIdSetting{ axisId, axisSettingId };
- });
- return result;
-}
-
-void QAbstractPhysicalDeviceBackendNodePrivate::updatePendingAxisSettings()
-{
- if (m_pendingAxisSettingIds.isEmpty())
- return;
-
- m_axisSettings = std::accumulate(
- m_pendingAxisSettingIds.constBegin(), m_pendingAxisSettingIds.constEnd(),
- QVector<Input::AxisIdSetting>(),
- [this] (const QVector<Input::AxisIdSetting> &current, Qt3DCore::QNodeId axisSettingId) {
- return current + convertToAxisIdSettingVector(axisSettingId);
- });
- m_pendingAxisSettingIds.clear();
-}
-
QAbstractPhysicalDeviceBackendNode::QAbstractPhysicalDeviceBackendNode(QBackendNode::Mode mode)
- : Qt3DCore::QBackendNode(*new QAbstractPhysicalDeviceBackendNodePrivate(mode))
+ : Input::BackendNode(*new QAbstractPhysicalDeviceBackendNodePrivate(mode))
{
}
QAbstractPhysicalDeviceBackendNode::QAbstractPhysicalDeviceBackendNode(QAbstractPhysicalDeviceBackendNodePrivate &dd)
- : Qt3DCore::QBackendNode(dd)
-{
-}
-
-void QAbstractPhysicalDeviceBackendNode::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+ : Input::BackendNode(dd)
{
- const auto deviceChange = qSharedPointerCast<QPhysicalDeviceCreatedChangeBase>(change);
- Q_D(QAbstractPhysicalDeviceBackendNode);
- // Store the axis setting Ids. We will update the settings themselves when needed
- d->m_pendingAxisSettingIds = deviceChange->axisSettingIds();
}
void QAbstractPhysicalDeviceBackendNode::cleanup()
@@ -188,33 +152,34 @@ void QAbstractPhysicalDeviceBackendNode::cleanup()
d->m_inputAspect = nullptr;
}
-void QAbstractPhysicalDeviceBackendNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void QAbstractPhysicalDeviceBackendNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
Q_D(QAbstractPhysicalDeviceBackendNode);
- switch (e->type()) {
- case Qt3DCore::PropertyValueAdded: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("axisSettings")) {
- const auto axisSettingId = change->addedNodeId();
- Input::AxisSetting *axisSetting = d->getAxisSetting(axisSettingId);
- const auto axisIds = axisSetting->axes();
- for (int axisId : axisIds)
- d->addAxisSetting(axisId, axisSettingId);
- }
- break;
- }
-
- case Qt3DCore::PropertyValueRemoved: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("axisSettings"))
- d->removeAxisSetting(change->removedNodeId());
- break;
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const Qt3DInput::QAbstractPhysicalDevice *node = qobject_cast<const Qt3DInput::QAbstractPhysicalDevice *>(frontEnd);
+ if (!node)
+ return;
- default:
- break;
+ auto settings = Qt3DCore::qIdsForNodes(node->axisSettings());
+ std::sort(std::begin(settings), std::end(settings));
+ Qt3DCore::QNodeIdVector addedSettings;
+ Qt3DCore::QNodeIdVector removedSettings;
+ std::set_difference(std::begin(settings), std::end(settings),
+ std::begin(d->m_currentAxisSettingIds), std::end(d->m_currentAxisSettingIds),
+ std::inserter(addedSettings, addedSettings.end()));
+ std::set_difference(std::begin(d->m_currentAxisSettingIds), std::end(d->m_currentAxisSettingIds),
+ std::begin(settings), std::end(settings),
+ std::inserter(removedSettings, removedSettings.end()));
+ d->m_currentAxisSettingIds = settings;
+
+ for (const auto &axisSettingId: qAsConst(addedSettings)) {
+ Input::AxisSetting *axisSetting = d->getAxisSetting(axisSettingId);
+ const auto axisIds = axisSetting->axes();
+ for (int axisId : axisIds)
+ d->addAxisSetting(axisId, axisSettingId);
}
- QBackendNode::sceneChangeEvent(e);
+ for (const auto &axisSettingId: qAsConst(removedSettings))
+ d->removeAxisSetting(axisSettingId);
}
void QAbstractPhysicalDeviceBackendNode::setInputAspect(QInputAspect *aspect)
@@ -232,7 +197,6 @@ QInputAspect *QAbstractPhysicalDeviceBackendNode::inputAspect() const
float QAbstractPhysicalDeviceBackendNode::processedAxisValue(int axisIdentifier)
{
Q_D(QAbstractPhysicalDeviceBackendNode);
- d->updatePendingAxisSettings();
// Find axis settings for this axis (if any)
Qt3DCore::QNodeId axisSettingId;
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode_p.h b/src/input/backend/qabstractphysicaldevicebackendnode_p.h
index e8e397883..ff46cf814 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode_p.h
+++ b/src/input/backend/qabstractphysicaldevicebackendnode_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <Qt3DCore/qbackendnode.h>
+#include <Qt3DInput/private/backendnode_p.h>
#include <Qt3DInput/private/qt3dinput_global_p.h>
@@ -66,12 +66,12 @@ namespace Qt3DInput {
class QInputAspect;
class QAbstractPhysicalDeviceBackendNodePrivate;
-class Q_3DINPUTSHARED_PRIVATE_EXPORT QAbstractPhysicalDeviceBackendNode : public Qt3DCore::QBackendNode
+class Q_3DINPUTSHARED_PRIVATE_EXPORT QAbstractPhysicalDeviceBackendNode : public Input::BackendNode
{
public:
explicit QAbstractPhysicalDeviceBackendNode(QBackendNode::Mode mode);
virtual void cleanup();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void setInputAspect(QInputAspect *aspect);
QInputAspect *inputAspect() const;
@@ -83,8 +83,6 @@ public:
protected:
QAbstractPhysicalDeviceBackendNode(QAbstractPhysicalDeviceBackendNodePrivate &dd);
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
-
Q_DECLARE_PRIVATE(QAbstractPhysicalDeviceBackendNode)
};
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode_p_p.h b/src/input/backend/qabstractphysicaldevicebackendnode_p_p.h
index 4b0c47b36..9156fc64d 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode_p_p.h
+++ b/src/input/backend/qabstractphysicaldevicebackendnode_p_p.h
@@ -97,10 +97,7 @@ public:
Input::AxisSetting *getAxisSetting(Qt3DCore::QNodeId axisSettingId) const;
- QVector<Input::AxisIdSetting> convertToAxisIdSettingVector(Qt3DCore::QNodeId axisSettingId) const;
- void updatePendingAxisSettings();
-
- Qt3DCore::QNodeIdVector m_pendingAxisSettingIds;
+ Qt3DCore::QNodeIdVector m_currentAxisSettingIds;
QVector<Input::AxisIdSetting> m_axisSettings;
QVector<Input::AxisIdFilter> m_axisFilters;
QInputAspect *m_inputAspect;
diff --git a/src/input/frontend/qabstractphysicaldevice.cpp b/src/input/frontend/qabstractphysicaldevice.cpp
index 120ec43a2..b925f8ed3 100644
--- a/src/input/frontend/qabstractphysicaldevice.cpp
+++ b/src/input/frontend/qabstractphysicaldevice.cpp
@@ -168,12 +168,7 @@ void QAbstractPhysicalDevice::addAxisSetting(QAxisSetting *axisSetting)
{
Q_D(QAbstractPhysicalDevice);
if (axisSetting && !d->m_axisSettings.contains(axisSetting)) {
- if (d->m_changeArbiter) {
- const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), axisSetting);
- change->setPropertyName("axisSettings");
- d->notifyObservers(change);
- }
-
+ d->update();
d->m_axisSettings.push_back(axisSetting);
}
}
@@ -185,12 +180,7 @@ void QAbstractPhysicalDevice::removeAxisSetting(QAxisSetting *axisSetting)
{
Q_D(QAbstractPhysicalDevice);
if (axisSetting && d->m_axisSettings.contains(axisSetting)) {
- if (d->m_changeArbiter) {
- const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), axisSetting);
- change->setPropertyName("axisSettings");
- d->notifyObservers(change);
- }
-
+ d->update();
d->m_axisSettings.removeOne(axisSetting);
}
}
@@ -209,11 +199,8 @@ QVector<QAxisSetting *> QAbstractPhysicalDevice::axisSettings() const
*/
void QAbstractPhysicalDevicePrivate::postAxisEvent(int axis, qreal value)
{
- Q_Q(QAbstractPhysicalDevice);
- Qt3DCore::QPropertyUpdatedChangePtr change(new Qt3DCore::QPropertyUpdatedChange(q->id()));
- change->setPropertyName("axisEvent");
- change->setValue(QVariant::fromValue(QPair<int, qreal>(axis, value)));
- notifyObservers(change);
+ m_pendingAxisEvents.push_back({axis, value});
+ update();
}
/*
@@ -221,11 +208,8 @@ void QAbstractPhysicalDevicePrivate::postAxisEvent(int axis, qreal value)
*/
void QAbstractPhysicalDevicePrivate::postButtonEvent(int button, qreal value)
{
- Q_Q(QAbstractPhysicalDevice);
- Qt3DCore::QPropertyUpdatedChangePtr change(new Qt3DCore::QPropertyUpdatedChange(q->id()));
- change->setPropertyName("buttonEvent");
- change->setValue(QVariant::fromValue(QPair<int, qreal>(button, value)));
- notifyObservers(change);
+ m_pendingButtonsEvents.push_back({button, value});
+ update();
}
/*!
diff --git a/src/input/frontend/qabstractphysicaldevice_p.h b/src/input/frontend/qabstractphysicaldevice_p.h
index 8fa72aa02..fc8ad561c 100644
--- a/src/input/frontend/qabstractphysicaldevice_p.h
+++ b/src/input/frontend/qabstractphysicaldevice_p.h
@@ -76,6 +76,9 @@ public:
QHash<QString, int> m_axesHash;
QHash<QString, int> m_buttonsHash;
+ QVector<QPair<int, qreal>> m_pendingAxisEvents;
+ QVector<QPair<int, qreal>> m_pendingButtonsEvents;
+
void postAxisEvent(int axis, qreal value);
void postButtonEvent(int button, qreal value);
};
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index e79a9d944..05e860a4b 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -145,9 +145,9 @@ QInputAspect::QInputAspect(QInputAspectPrivate &dd, QObject *parent)
qRegisterMetaType<Qt3DInput::QAbstractPhysicalDevice*>();
- registerBackendType<QKeyboardDevice>(QBackendNodeMapperPtr(new Input::KeyboardDeviceFunctor(this, d_func()->m_inputHandler.data())));
+ registerBackendType<QKeyboardDevice, true>(QBackendNodeMapperPtr(new Input::KeyboardDeviceFunctor(this, d_func()->m_inputHandler.data())));
registerBackendType<QKeyboardHandler>(QBackendNodeMapperPtr(new Input::KeyboardHandlerFunctor(d_func()->m_inputHandler.data())));
- registerBackendType<QMouseDevice>(QBackendNodeMapperPtr(new Input::MouseDeviceFunctor(this, d_func()->m_inputHandler.data())));
+ registerBackendType<QMouseDevice, true>(QBackendNodeMapperPtr(new Input::MouseDeviceFunctor(this, d_func()->m_inputHandler.data())));
registerBackendType<QMouseHandler>(QBackendNodeMapperPtr(new Input::MouseHandlerFunctor(d_func()->m_inputHandler.data())));
registerBackendType<QAxis, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Axis, Input::AxisManager>(d_func()->m_inputHandler->axisManager())));
registerBackendType<QAxisAccumulator>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisAccumulator, Input::AxisAccumulatorManager>(d_func()->m_inputHandler->axisAccumulatorManager())));
@@ -159,7 +159,7 @@ QInputAspect::QInputAspect(QInputAspectPrivate &dd, QObject *parent)
registerBackendType<QInputChord>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::InputChord, Input::InputChordManager>(d_func()->m_inputHandler->inputChordManager())));
registerBackendType<QInputSequence>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::InputSequence, Input::InputSequenceManager>(d_func()->m_inputHandler->inputSequenceManager())));
registerBackendType<QLogicalDevice>(QBackendNodeMapperPtr(new Input::LogicalDeviceNodeFunctor(d_func()->m_inputHandler->logicalDeviceManager())));
- registerBackendType<QGenericInputDevice>(QBackendNodeMapperPtr(new Input::GenericDeviceBackendFunctor(this, d_func()->m_inputHandler.data())));
+ registerBackendType<QGenericInputDevice, true>(QBackendNodeMapperPtr(new Input::GenericDeviceBackendFunctor(this, d_func()->m_inputHandler.data())));
registerBackendType<QInputSettings>(QBackendNodeMapperPtr(new Input::InputSettingsFunctor(d_func()->m_inputHandler.data())));
registerBackendType<QAbstractPhysicalDeviceProxy>(QBackendNodeMapperPtr(new Input::PhysicalDeviceProxyNodeFunctor(d_func()->m_inputHandler->physicalDeviceProxyManager())));
diff --git a/tests/auto/input/mousedevice/tst_mousedevice.cpp b/tests/auto/input/mousedevice/tst_mousedevice.cpp
index 64447d0de..2d44848ee 100644
--- a/tests/auto/input/mousedevice/tst_mousedevice.cpp
+++ b/tests/auto/input/mousedevice/tst_mousedevice.cpp
@@ -70,7 +70,7 @@ private Q_SLOTS:
{
// WHEN
Qt3DInput::Input::MouseDevice backendMouseDevice;
- simulateInitialization(&mouseDevice, &backendMouseDevice);
+ simulateInitializationSync(&mouseDevice, &backendMouseDevice);
// THEN
QCOMPARE(backendMouseDevice.isEnabled(), true);
@@ -91,7 +91,7 @@ private Q_SLOTS:
// WHEN
Qt3DInput::Input::MouseDevice backendMouseDevice;
mouseDevice.setEnabled(false);
- simulateInitialization(&mouseDevice, &backendMouseDevice);
+ simulateInitializationSync(&mouseDevice, &backendMouseDevice);
// THEN
QCOMPARE(backendMouseDevice.peerId(), mouseDevice.id());
@@ -220,15 +220,15 @@ private Q_SLOTS:
void checkSceneChangeEvents()
{
// GIVEN
+ Qt3DInput::QMouseDevice mouseDevice;
Qt3DInput::Input::MouseDevice backendMouseDevice;
+ simulateInitializationSync(&mouseDevice, &backendMouseDevice);
{
// WHEN
const bool newValue = false;
- const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- change->setPropertyName("enabled");
- change->setValue(newValue);
- backendMouseDevice.sceneChangeEvent(change);
+ mouseDevice.setEnabled(newValue);
+ backendMouseDevice.syncFromFrontEnd(&mouseDevice, false);
// THEN
QCOMPARE(backendMouseDevice.isEnabled(), newValue);
@@ -236,10 +236,8 @@ private Q_SLOTS:
{
// WHEN
const float newValue = 99.0f;
- const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- change->setPropertyName("sensitivity");
- change->setValue(QVariant::fromValue(newValue));
- backendMouseDevice.sceneChangeEvent(change);
+ mouseDevice.setSensitivity(newValue);
+ backendMouseDevice.syncFromFrontEnd(&mouseDevice, false);
// THEN
QCOMPARE(backendMouseDevice.sensitivity(), newValue);
diff --git a/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
index 06d390859..7d9666225 100644
--- a/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
+++ b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
@@ -143,7 +143,7 @@ private Q_SLOTS:
{
// WHEN
TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
- simulateInitialization(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
+ simulateInitializationSync(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
// THEN
QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), true);
@@ -153,7 +153,7 @@ private Q_SLOTS:
// WHEN
TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
physicalDeviceNode.setEnabled(false);
- simulateInitialization(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
+ simulateInitializationSync(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
// THEN
QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.peerId(), physicalDeviceNode.id());
@@ -164,17 +164,17 @@ private Q_SLOTS:
void checkSceneChangeEvents()
{
// GIVEN
+ TestDevice physicalDeviceNode;
TestPhysicalDeviceBackendNode backendQAbstractPhysicalDeviceBackendNode;
Qt3DInput::QInputAspect aspect;
backendQAbstractPhysicalDeviceBackendNode.setInputAspect(&aspect);
+ simulateInitializationSync(&physicalDeviceNode, &backendQAbstractPhysicalDeviceBackendNode);
{
// WHEN
const bool newValue = false;
- const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
- change->setPropertyName("enabled");
- change->setValue(newValue);
- backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+ physicalDeviceNode.setEnabled(newValue);
+ backendQAbstractPhysicalDeviceBackendNode.syncFromFrontEnd(&physicalDeviceNode, false);
// THEN
QCOMPARE(backendQAbstractPhysicalDeviceBackendNode.isEnabled(), newValue);
@@ -202,40 +202,36 @@ private Q_SLOTS:
// Adding AxisSettings
{
// WHEN
- auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &settings1);
- change->setPropertyName("axisSettings");
- backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+ physicalDeviceNode.addAxisSetting(&settings1);
+ backendQAbstractPhysicalDeviceBackendNode.syncFromFrontEnd(&physicalDeviceNode, false);
// THEN
QCOMPARE(priv->m_axisSettings.size(), 1);
// WHEN
- change = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &settings2);
- change->setPropertyName("axisSettings");
- backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+ physicalDeviceNode.addAxisSetting(&settings2);
+ backendQAbstractPhysicalDeviceBackendNode.syncFromFrontEnd(&physicalDeviceNode, false);
// THEN
QCOMPARE(priv->m_axisSettings.size(), 2);
}
+
// Removing AxisSettings
{
// WHEN
- auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &settings1);
- change->setPropertyName("axisSettings");
- backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+ physicalDeviceNode.removeAxisSetting(&settings1);
+ backendQAbstractPhysicalDeviceBackendNode.syncFromFrontEnd(&physicalDeviceNode, false);
// THEN
QCOMPARE(priv->m_axisSettings.size(), 1);
// WHEN
- change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &settings2);
- change->setPropertyName("axisSettings");
- backendQAbstractPhysicalDeviceBackendNode.sceneChangeEvent(change);
+ physicalDeviceNode.removeAxisSetting(&settings2);
+ backendQAbstractPhysicalDeviceBackendNode.syncFromFrontEnd(&physicalDeviceNode, false);
// THEN
QCOMPARE(priv->m_axisSettings.size(), 0);
}
-
}
}