aboutsummaryrefslogtreecommitdiffstats
path: root/src/xr/quick3dxr/qquick3dxrabstracthapticeffect.cpp
blob: 488d8b25333eb9190fb346ccaf508b946e9add43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "qquick3dxrabstracthapticeffect_p.h"

QT_BEGIN_NAMESPACE

/*!
    \qmltype XrHapticEffect
    \qmlabstract
    \inherits QtObject
    \inqmlmodule QtQuick3D.Xr
    \brief Represents a haptic effect.
    \since 6.9

    XrHapticEffect defines the characteristics of the haptic effect.

    This type is abstract. Use a subtype, such as \l XrSimpleHapticEffect.

    \sa XrHapticFeedback XrSimpleHapticEffect
 */

/*!
    \qmltype XrSimpleHapticEffect
    \inherits XrHapticEffect
    \inqmlmodule QtQuick3D.Xr
    \brief Allows setting controller haptics using amplitude, duration and frequency.
    \since 6.9

    \qml
    XrSimpleHapticEffect {
        amplitude: 0.5
        duration: 300
        frequency: 3000
    }
    \endqml

    \sa XrHapticFeedback
*/

/*!
    \qmlproperty bool XrSimpleHapticEffect::amplitude()
    \brief Defines the amplitude of the effect's vibration.
    Acceptable values are from 0.0 to 1.0
    \default 0.5
 */
float QQuick3DXrSimpleHapticEffect::amplitude()
{
    return m_amplitude;
}

void QQuick3DXrSimpleHapticEffect::setAmplitude(float newAmplitude)
{
    if (m_amplitude == newAmplitude)
        return;
    m_amplitude = newAmplitude;
    emit amplitudeChanged();
}

/*!
    \qmlproperty bool XrSimpleHapticEffect::duration()
    \brief Defines the duration of the haptic effect in milliseconds.
    \default 30
 */
float QQuick3DXrSimpleHapticEffect::duration()
{
    return m_duration;
}

void QQuick3DXrSimpleHapticEffect::setDuration(float newDuration)
{
    if (m_duration == newDuration)
        return;
    m_duration = newDuration;
    emit durationChanged();
}

/*!
    \qmlproperty bool XrSimpleHapticEffect::frequency()
    \brief Defines the frequency of the haptic effect in Hz
    \default 3000
 */

float QQuick3DXrSimpleHapticEffect::frequency()
{
    return m_frequency;
}

void QQuick3DXrSimpleHapticEffect::setFrequency(float newFrequency)
{
    if (m_frequency == newFrequency)
        return;
    m_frequency = newFrequency;
    emit frequencyChanged();
}

QT_END_NAMESPACE