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 "qabstractaxisinput_p.h"
5
6#include <Qt3DInput/qabstractaxisinput.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DInput {
11
12/*!
13 * \qmltype AbstractAxisInput
14 * \inqmlmodule Qt3D.Input
15 * \brief QML frontend for abstract QAbstractAxisInput C++ class.
16 * \since 5.5
17 *
18 */
19
20/*!
21 * \class Qt3DInput::QAbstractAxisInput
22 * \inheaderfile Qt3DInput/QAbstractAxisInput
23 * \inmodule Qt3DInput
24 * \brief QAbstractActionInput is the base class for all Axis Input.
25 * \since 5.5
26 *
27 */
28
29/*!
30 \qmlproperty AbstractPhysicalDevice Qt3D.Input::AbstractAxisInput::sourceDevice
31*/
32
33/*!
34 \internal
35 */
36QAbstractAxisInput::QAbstractAxisInput(QAbstractAxisInputPrivate &dd, Qt3DCore::QNode *parent)
37 : QNode(dd, parent)
38{
39}
40
41/*!
42 \property Qt3DInput::QAbstractAxisInput::sourceDevice
43
44 The source device for the QAbstractAxisInput.
45*/
46
47void QAbstractAxisInput::setSourceDevice(QAbstractPhysicalDevice *sourceDevice)
48{
49 Q_D(QAbstractAxisInput);
50 if (d->m_sourceDevice != sourceDevice) {
51
52 if (d->m_sourceDevice)
53 d->unregisterDestructionHelper(node: d->m_sourceDevice);
54
55 // We need to add it as a child of the current node if it has been declared inline
56 // Or not previously added as a child of the current node so that
57 // 1) The backend gets notified about it's creation
58 // 2) When the current node is destroyed, it gets destroyed as well
59 if (sourceDevice && !sourceDevice->parent())
60 sourceDevice->setParent(this);
61
62 d->m_sourceDevice = sourceDevice;
63 // Ensures proper bookkeeping
64 if (d->m_sourceDevice)
65 d->registerDestructionHelper(node: sourceDevice, func: &QAbstractAxisInput::setSourceDevice, d->m_sourceDevice);
66
67 emit sourceDeviceChanged(sourceDevice);
68 }
69}
70
71/*!
72 \internal
73 */
74QAbstractAxisInput::~QAbstractAxisInput()
75{
76}
77
78QAbstractPhysicalDevice *QAbstractAxisInput::sourceDevice() const
79{
80 Q_D(const QAbstractAxisInput);
81 return d->m_sourceDevice;
82}
83
84} // Qt3DInput
85
86QT_END_NAMESPACE
87
88#include "moc_qabstractaxisinput.cpp"
89

source code of qt3d/src/input/frontend/qabstractaxisinput.cpp