From 3d0bdc89b3faa544ee019e6cdec648856deef426 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 15 Jul 2010 10:40:14 +1000 Subject: Add new feedback example, and expand documentation for feedback module The new example is a simple example which contains four buttons, each of which plays a simple haptic effect. Also add some doc snippets for feedback --- .../qtfeedbackdocsample/qtfeedbackdocsample.cpp | 57 ++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp') diff --git a/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp b/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp index 257011312b..e26412fb4c 100644 --- a/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp +++ b/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp @@ -43,6 +43,7 @@ #include #include +#include QTM_USE_NAMESPACE @@ -50,8 +51,56 @@ void completeExample(); void completeExample() { - //TODO.. -//! [Complete example] - // Coming soon... -//! [Complete example] +//! [Play the system theme button click effect] + QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBasicButton); +//! [Play the system theme button click effect] + +//! [Play the system theme bounce effect] + QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBounceEffect); +//! [Play the system theme bounce effect] + +//! [Define a custom haptic effect] + QFeedbackHapticsEffect rumble; + rumble.setAttackIntensity(0.0); + rumble.setAttackTime(250); + rumble.setIntensity(1.0); + rumble.setDuration(100); + rumble.setFadeTime(250); + rumble.setFadeIntensity(0.0); +//! [Define a custom haptic effect] + +//! [Start playing a custom haptic effect] + rumble.start(); +//! [Start playing a custom haptic effect] + +//! [Pause a custom haptic effect] + rumble.pause(); +//! [Pause a custom haptic effect] + +//! [Stop playing a custom haptic effect] + rumble.stop(); +//! [Stop playing a custom haptic effect] + +//! [Query the state of a custom haptic effect] + if (rumble.state() == QFeedbackEffect::Stopped) + qDebug() << "The device has stopped rumbling!"; +//! [Query the state of a custom haptic effect] + +//! [Set the actuator which should play the custom effect] + QFeedbackActuator actuator; // default system actuator + QList actuators = QFeedbackActuator::actuators(); + foreach (const QFeedbackActuator& temp, actuators) { + if (temp.name() == "ExampleActuatorName") { + actuator = temp; + } + } + rumble.setActuator(actuator); +//! [Set the actuator which should play the custom effect] + +//! [Play a haptic effect from a file] + QFeedbackFileEffect hapticTune; + hapticTune.setFileName("mySavedRumble.ifr"); + hapticTune.load(); + hapticTune.start(); +//! [Play a haptic effect from a file] } -- cgit v1.2.3