Debian Codegraph @

doc/src/qtfeedback.qdoc

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Free Documentation License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Free
19 ** Documentation License version 1.3 as published by the Free Software
20 ** Foundation and appearing in the file included in the packaging of
21 ** this file. Please review the following information to ensure
22 ** the GNU Free Documentation License version 1.3 requirements
23 ** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
24 ** $QT_END_LICENSE$
25 **
26 ****************************************************************************/
27
28 /*!
29
30 \page qtfeedback-index.html
31 \title Qt Feedback
32
33 \brief An API enabling a client to provide tactile and audio feedback to user actions.
34
35 \ingroup mobility
36
37
38 The C++ Feedback API enables a client to control and provide tactile and audio feedback
39 to the user. The feedback is in response to user actions. For example, touching an
40 onscreen button. Control of the feedback involves control of the vibration of
41 the device, when a vibrator is used, or the piezo feedback from the screen.
42
43
44 \tableofcontents
45
46
47
48 \section1 Overview
49
50 The Feedback API allows application developers to implement feedback and programmatic vibration
51 in their applications. The API provides abstractions for various types of
52 feedback, and allows custom implementations of these types of feedback.
53
54 The QFeedbackEffect class provides a simple interface to allow developers to
55 start, stop or pause the playback of an effect. It is an abstract class which
56 is implemented by QFeedbackHapticsEffect and QFeedbackFileEffect. In addition,
57 it allows the instantaneous playback of feedback effects which match the system
58 theme.
59
60 A QFeedbackHapticsEffect is a custom effect which allows a program to play a
61 haptic effect on an actuator. Such an effect might have a duration, intensity,
62 and envelope of playback (including attack time and intensity, and fade time
63 and intensity), as well as a period if it is a periodic (repeating) effect.
64
65 A QFeedbackFileEffect is a haptic tune or audio file saved in a file which may be played
66 back. These effects must be created by third-party applications, and a plugin
67 which supports the specific file format must be installed. In particular, note that
68 audio effects are generally limited to simple formats, to reduce latency. You can
69 check what formats are supported by the system by calling QFeedbackFileEffect::supportedMimeTypes().
70
71 For the vast majority of use cases, the QFeedbackEffect, QFeedbackHapticsEffect
72 and QFeedbackFileEffect classes are the only classes which developers will use
73 in their programs. There are some special cases, however, where they may wish
74 to implement their own feedback plugin. The QtFeedback API allows
75 third party developers to implement QFeedbackInterface in a plugin which may be
76 loaded by the plugin loading mechanism to play feedback effects.
77
78 Note that in any application, only the highest priority plugin for each of the
79 three types of feedback will be used to provide the feedback effects, except
80 for file feedback plugins (where only the highest priority plugin for each
81 supported mime-type is used). The interface classes which must be implemented
82 by a plugin to provide effects to clients are:
83 \list
84 \li \l{QFeedbackHapticsInterface} for \l{QFeedbackHapticsEffect}
85 \li \l{QFeedbackFileInterface} for \l{QFeedbackFileEffect}
86 \li \l{QFeedbackThemeInterface} for the built-in theme effects (\l{QFeedbackEffect::ThemeEffect}).
87 \endlist
88
89 Generally, the device platform will provide an implementation of each of the
90 three different interfaces, which will be the default plugins used for the
91 various \l {QFeedbackEffect}s.
92
93 \section2 Platform Issues
94
95 \note Platforms might have user settings that enable/disables the vibration.
96
97 \section1 Using Effects
98
99 \section2 Theme Effects
100
101 The most common use of the API is to play system theme effects for user
102 interface interaction notifications, for example, button clicks. These
103 system theme effects can be played instantaneously, but cannot be paused or
104 stopped. They are played via the static QFeedbackEffect::playThemeEffect()
105 function:
106 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Play the system theme button click effect
107
108 There are many different theme effects defined, to cover a variety of
109 interactions and notifications, to allow an application to maintain greater
110 consistency with the platform user experience.
111 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Play the system theme bounce effect
112
113 \section2 Custom Effects
114
115 The next most common use of the API is to define a custom effect which can be
116 used to notify the user of application-specific events or to increase the
117 immersiveness of an application. A custom effect may be either periodic or
118 non-periodic.
119
120 The following diagram shows the graph of intensity over time of a non-periodic
121 effect which was started at time \c t and ended at time \c q, with an
122 \l{QFeedbackHapticsEffect::intensity()}{intensity} of \c{I}, an
123 \l{QFeedbackHapticsEffect::attackIntensity()}{attack intensity} of \c{AI}, a
124 \l{QFeedbackHapticsEffect::fadeIntensity()}{fade intensity} of \c{FI}, an
125 \l{QFeedbackHapticsEffect::attackTime()}{attack time} of \c{AT}, and a
126 \l{QFeedbackHapticsEffect::fadeTime()}{fade time} of \c{FT}, with a total
127 \l{QFeedbackEffect::duration()}{duration} of \c{Duration} milliseconds:
128
129 \image non-periodic-effect.png
130
131 The following diagram shows the graph of intensity over time of a periodic
132 effect which was started at time \c t and ended at time \c q, with an
133 \l{QFeedbackHapticsEffect::intensity()}{intensity} of \c{I}, an
134 \l{QFeedbackHapticsEffect::attackIntensity()}{attack intensity} of \c{AI}, a
135 \l{QFeedbackHapticsEffect::fadeIntensity()}{fade intensity} of \c{FI}, an
136 \l{QFeedbackHapticsEffect::attackTime()}{attack time} of \c{AT}, and a
137 \l{QFeedbackHapticsEffect::fadeTime()}{fade time} of \c{FT}, with a
138 \l{QFeedbackHapticsEffect::period()}{period} of \c{Period} milliseconds and a total
139 \l{QFeedbackEffect::duration()}{duration} of \c{Duration} milliseconds:
140
141 \image periodic-effect.png
142
143 A custom haptic effect may be defined in the following manner:
144 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Define a custom haptic effect
145 \note No periodicity was defined for the effect, although that can be done
146 by calling QFeedbackHapticsEffect::setPeriod() if required.
147
148 Once the effect has been defined, it may be played via the API offered in the
149 QFeedbackEffect base class:
150 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Start playing a custom haptic effect
151
152 Custom haptic effects are stateful, and so they may be paused:
153 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Pause a custom haptic effect
154
155 Or stopped:
156 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Stop playing a custom haptic effect
157
158 Certain operations cannot be performed on an effect if it is in a certain
159 state. The current state of the effect may be queried via the base-class API:
160 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Query the state of a custom haptic effect
161
162 All custom effects are played using a specific
163 \l{QFeedbackActuator}{device actuator}. By default, the effect is played via
164 the actuator which the current haptic effect provider plugin considers to be
165 the system default actuator, and so most application developers will not need
166 to change which actuator is used. In some cases, however, it may be desirable
167 to set which actuator the effect is played on; doing so requires prior
168 knowledge of either the name or the id of the actuator on which the developer
169 wishes the effect to be played:
170 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Set the actuator which should play the custom effect
171
172 Finally, there is software available which allows "haptic tunes" to be saved to
173 file, for later playback. If the haptic file effect provider plugin on the
174 system understands that file format, the file can be played on device:
175 \snippet doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp Play a haptic effect from a file
176 In addition, small audio effects can be played as feedback.
177
178 If you wish to see a simple example application which demonstrates some of
179 the above code in use, please see the \l{hapticsquare}{Haptic Square} example
180 application.
181
182 \section1 Main Classes
183 \list
184 \li \l{QFeedbackEffect}
185 \li \l{QFeedbackHapticsEffect}
186 \li \l{QFeedbackFileEffect}
187 \li \l{QFeedbackActuator}
188 \li \l{QFeedbackInterface}
189 \endlist
190
191 \section1 Examples
192 \list
193 \li \l{hapticsquare}{Haptic Square}
194 \li \l{hapticsplayer}{Haptics Player}
195 \endlist
196
197
198 */
199
200 /*!
201 \page feedback-api.html
202
203 \title Qt Feedback C++ Classes
204
205 \brief An API enabling a client to provide tactile and audio feedback to user actions.
206
207 \section1 Overview
208
209 The C++ Feedback API enables a client to control and provide tactile and audio feedback
210 to the user. The feedback is in response to user actions. For example, touching an
211 onscreen button. Control of the feedback involves control of the vibration of
212 the device, when a vibrator is used, or the piezo feedback from the screen.
213
214 \section1 Feedback C++ Classes
215
216 \annotatedlist feedback
217 */