QFeedbackHapticsEffect Class
The QFeedbackHapticsEffect class allows you to play a haptics effect. More...
Header: | #include <QFeedbackHapticsEffect> |
Inherits: | QFeedbackEffect |
Properties
|
|
- 2 properties inherited from QFeedbackEffect
Public Functions
QFeedbackHapticsEffect(QObject *parent = Q_NULLPTR) | |
virtual | ~QFeedbackHapticsEffect() |
QFeedbackActuator * | actuator() const |
qreal | attackIntensity() const |
int | attackTime() const |
qreal | fadeIntensity() const |
int | fadeTime() const |
qreal | intensity() const |
int | period() const |
void | setActuator(QFeedbackActuator *actuator) |
void | setAttackIntensity(qreal intensity) |
void | setAttackTime(int msecs) |
void | setDuration(int msecs) |
void | setFadeIntensity(qreal intensity) |
void | setFadeTime(int msecs) |
void | setIntensity(qreal intensity) |
void | setPeriod(int msecs) |
Reimplemented Public Functions
virtual int | duration() const |
- 2 public functions inherited from QFeedbackEffect
Static Public Members
const QMetaObject | staticMetaObject |
- 2 static public members inherited from QFeedbackEffect
Additional Inherited Members
- 3 public slots inherited from QFeedbackEffect
- 2 signals inherited from QFeedbackEffect
- 1 protected function inherited from QFeedbackEffect
Detailed Description
The QFeedbackHapticsEffect class allows you to play a haptics effect.
A haptics effect is an effect that takes advantage of the sense of touch. Most mobile devices today supports one such effect, vibration, which will then be the default when you create a QFeedbackHapticsEffect.
A haptics effect has a few parameters that must be set up before it can be played:
- duration(): The total duration of the effect in milliseconds.
- intensity(): The intensity, e.g., how hard the device will vibrate.
An effect can, for example, be set up as follows:
QFeedbackHapticsEffect rumble; rumble.setIntensity(1.0); rumble.setDuration(100);
You can now start() the effect.
rumble.start();
At any given time, the effect is in one of four states: Stopped, Paused, Running, or Loading. You can request a state change by calling start(), pause(), or stop(). The state is queried with state().
The haptics effect also supports a fade-in of the effect. For vibration, this means that the vibration will grow (or sink) in intensity from when the effect starts until intensity() is reached. You can set that up as follows:
rumble.setAttackIntensity(0.0); rumble.setAttackTime(250);
Attack intensity is the start intensity and attack time is the duration of the fade-in. We have a similar fade-out:
rumble.setFadeTime(250); rumble.setFadeIntensity(0.0);
When using fade-in and fade-out the total duration of the haptics effect will be: duration(); the main intensity() will be played for (duration() - (attackTime() + fadeTime())) milliseconds.
A QFeedbackHapticsEffect is played on an actuator(), which is the physical component that performs the effect. You can query if other actuators are available - see the QFeedbackActuator::actuators() function documentation for details.
Errors occurring during playback are notified through the error() signal.
See also QFeedbackActuator.
Property Documentation
actuator : QFeedbackActuator*
This property holds the actuator on which the effect operates.
This property defines the actuator on which the effect operates. You can only change the actuator used when the effect is stopped. Setting a null actuator resets the effect to use the default actuator.
Access functions:
QFeedbackActuator * | actuator() const |
void | setActuator(QFeedbackActuator *actuator) |
attackIntensity : qreal
This property holds the initial intensity of the effect.
This property defines the initial intensity of the effect, before it fades in. It is usually lower than intensity. The effect will ramp up (or down) from attackIntensity() to intensity() in attackTime() milliseconds.
Access functions:
qreal | attackIntensity() const |
void | setAttackIntensity(qreal intensity) |
attackTime : int
This property holds the duration of the fade-in effect.
This property defines the duration of the fade-in effect in milliseconds. The effect will ramp up (or down) from attackIntensity() to intensity() in attackTime() milliseconds.
If the attack time is set to a value such that attackTime() + fadeTime() is greater than duration() for non-periodic effects, or greater than period() for periodic effects, the waveform which will result is backend-specific.
Access functions:
int | attackTime() const |
void | setAttackTime(int msecs) |
See also duration() and period().
duration : int
This property holds the expected duration of the effect.
This property defines the total duration of the feedback effect, in milliseconds. It includes the duration of any fade-in or fade-out parts, if any, in non-periodic effects, and includes all repetitions of the period in periodic-effects, if any.
If the duration is set to a value less than attackTime() + fadeTime(), or less than the period() of the effect, the waveform which will result is backend-specific.
Access functions:
virtual int | duration() const |
void | setDuration(int msecs) |
See also fadeTime(), attackTime(), and period().
fadeIntensity : qreal
This property holds the final intensity of the effect.
This property defines the final intensity of the effect, after it fades out. It is usually lower than intensity. The effect will ramp down (or up) from intensity() to fadeIntensity() in fadeTime() milliseconds.
Access functions:
qreal | fadeIntensity() const |
void | setFadeIntensity(qreal intensity) |
fadeTime : int
This property holds the duration of the fade-out effect.
This property defines the duration of the fade-out effect in milliseconds. The effect will ramp down (or up) from intensity() to fadeIntensity() in fadeTime() milliseconds.
If the fade time is set to a value such that attackTime() + fadeTime() is greater than duration() for non-periodic effects, or greater than period() for periodic effects, the waveform which will result is backend-specific.
Access functions:
int | fadeTime() const |
void | setFadeTime(int msecs) |
See also duration() and period().
intensity : qreal
This property holds the intensity of the effect.
This property defines the intensity of the feedback effect. The value can be between 0 and 1.
For non-periodic effects, the effect will be at this intensity for (duration() - (attackTime() + fadeTime())) milliseconds. For periodic effects, the effect will be at this intensity once per period for (period() - (attackTime() + fadeTime())) milliseconds.
Access functions:
qreal | intensity() const |
void | setIntensity(qreal intensity) |
period : int
set the period for the effect.
It has a default value of -1, which means that it is not a periodic effect. You can only change the period when the effect is stopped. The duration of the effect should be set to a value larger than the period of the effect if you wish the periodicity to be discernable.
Note: Not all actuators support periodic effects
The period defines the total length of the periodic envelope, which will be repeated up until duration() milliseconds has elapsed. For a periodic effect, the intensity will start at attackIntensity(), ramp to intensity() (where it stays for (period() - (attackTime() + fadeTime())) milliseconds), then ramp to fadeIntensity(). This waveform will be repeated as many times as required until the duration() has elapsed.
If the period is set to a value which is less than attackTime() + fadeTime(), the waveform which will result is backend-specific.
Access functions:
int | period() const |
void | setPeriod(int msecs) |
Member Function Documentation
QFeedbackHapticsEffect::QFeedbackHapticsEffect(QObject *parent = Q_NULLPTR)
Constructs the QFeedbackHapticsEffect class, and passes parent to QObject's constructor. The default QFeedbackActuator will be used.
See also QFeedbackActuator::actuators().
[virtual]
QFeedbackHapticsEffect::~QFeedbackHapticsEffect()
Destroys this effect and stops the feedback if it is running.