1// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "axis_p.h"
5
6#include <Qt3DInput/qaxis.h>
7#include <Qt3DInput/qabstractaxisinput.h>
8
9#include <Qt3DInput/private/qaxis_p.h>
10#include <algorithm>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DInput {
15
16namespace Input {
17
18Axis::Axis()
19 : BackendNode(ReadWrite)
20 , m_axisValue(0.0f)
21{
22}
23
24void Axis::cleanup()
25{
26 QBackendNode::setEnabled(false);
27 m_inputs.clear();
28 m_axisValue = 0.0f;
29}
30
31void Axis::setAxisValue(float axisValue)
32{
33 if (isEnabled() && (!qFuzzyCompare(p1: axisValue, p2: m_axisValue)))
34 m_axisValue = axisValue;
35}
36
37void Axis::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
38{
39 BackendNode::syncFromFrontEnd(frontEnd, firstTime);
40 const Qt3DInput::QAxis *node = qobject_cast<const Qt3DInput::QAxis *>(object: frontEnd);
41 if (!node)
42 return;
43
44 auto ids = Qt3DCore::qIdsForNodes(nodes: node->inputs());
45 m_inputs = ids;
46}
47
48} // namespace Input
49
50} // namespace Qt3DInput
51
52QT_END_NAMESPACE
53

source code of qt3d/src/input/backend/axis.cpp