1// Copyright (C) 2016 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 "qbuttonaxisinput.h"
5#include "qbuttonaxisinput_p.h"
6
7#include <Qt3DInput/qabstractphysicaldevice.h>
8
9QT_BEGIN_NAMESPACE
10
11namespace Qt3DInput {
12
13/*!
14 * \qmltype ButtonAxisInput
15 * \instantiates Qt3DInput::QButtonAxisInput
16 * \inqmlmodule Qt3D.Input
17 * \brief QML frontend for QButtonAxisInput C++ class.
18 * \since 5.7
19 * The axis value is controlled by buttons rather than a traditional analog input such as a joystick.
20 *
21 */
22
23/*!
24 * \class Qt3DInput::QButtonAxisInput
25 * \inheaderfile Qt3DInput/QButtonAxisInput
26 * \inmodule Qt3DInput
27 * \brief An axis input controlled by buttons
28 * \since 5.7
29 * The axis value is controlled by buttons rather than a traditional analog input such as a joystick.
30 *
31 */
32/*!
33 \qmlproperty real ButtonAxisInput::scale
34 Specifies how the axis output value is scaled. No scaling is applied by default
35 so it defaults to 1.
36*/
37
38/*!
39 \qmlproperty list<var> ButtonAxisInput::buttons
40 Specifies the buttons which control the axis
41*/
42
43/*!
44 \qmlproperty real ButtonAxisInput::acceleration
45 Specifies the rate at which the axis value changes when a button is held
46*/
47
48/*!
49 \qmlproperty list<var> ButtonAxisInput::deceleration
50 Specifies the rate at which the axis value returns to normal when a button is released
51*/
52
53/*!
54 Constructs a new QButtonAxisInput instance with \a parent.
55 */
56QButtonAxisInput::QButtonAxisInput(Qt3DCore::QNode *parent)
57 : QAbstractAxisInput(*new QButtonAxisInputPrivate, parent)
58{
59}
60
61/*! \internal */
62QButtonAxisInput::~QButtonAxisInput()
63{
64}
65
66/*!
67 \property QButtonAxisInput::scale
68 Specifies how the axis output value is scaled. No scaling is applied by default
69 so it defaults to 1.
70 */
71void QButtonAxisInput::setScale(float scale)
72{
73 Q_D(QButtonAxisInput);
74 if (d->m_scale != scale) {
75 d->m_scale = scale;
76 emit scaleChanged(scale);
77 }
78}
79
80float QButtonAxisInput::scale() const
81{
82 Q_D(const QButtonAxisInput);
83 return d->m_scale;
84}
85
86/*!
87 \property QButtonAxisInput::buttons
88 Specifies the buttons which control the axis
89 */
90void QButtonAxisInput::setButtons(const QList<int> &buttons)
91{
92 Q_D(QButtonAxisInput);
93 if (buttons != d->m_buttons) {
94 d->m_buttons = buttons;
95 emit buttonsChanged(buttons);
96 }
97}
98
99QList<int> QButtonAxisInput::buttons() const
100{
101 Q_D(const QButtonAxisInput);
102 return d->m_buttons;
103}
104
105/*!
106 \property QButtonAxisInput::acceleration
107 Specifies the rate at which the axis value changes when a button is held
108 */
109float QButtonAxisInput::acceleration() const
110{
111 Q_D(const QButtonAxisInput);
112 return d->m_acceleration;
113}
114
115void QButtonAxisInput::setAcceleration(float acceleration)
116{
117 Q_D(QButtonAxisInput);
118 if (d->m_acceleration != acceleration) {
119 d->m_acceleration = acceleration;
120 emit accelerationChanged(acceleration);
121 }
122}
123
124/*!
125 \property QButtonAxisInput::deceleration
126 Specifies the rate at which the axis value returns to normal when a button is released
127 */
128float QButtonAxisInput::deceleration() const
129{
130 Q_D(const QButtonAxisInput);
131 return d->m_deceleration;
132}
133
134void QButtonAxisInput::setDeceleration(float deceleration)
135{
136 Q_D(QButtonAxisInput);
137 if (d->m_deceleration != deceleration) {
138 d->m_deceleration = deceleration;
139 emit decelerationChanged(deceleration);
140 }
141}
142
143} // Qt3DInput
144
145QT_END_NAMESPACE
146
147#include "moc_qbuttonaxisinput.cpp"
148

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