×
Namespaces

Variants
Actions

Monitoring Tactile Feedback Vibration Mode

From Nokia Developer Wiki
Jump to: navigation, search

This Symbian C++ code snippet shows how to Monitor Touch Screen Vibration Mode Change.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic.
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: VibraFeedbackModeChanged(),MHWRMVibraFeedbackObserver ,Tactile Feedback Vibration Mode
Created: vasant21 (03 Nov 2008)
Last edited: hamishwillee (30 May 2013)

Contents

Preconditions

Here we assume that we already have a working application.

MMP file

The following capabilities and libraries are required:

CAPABILITY None


LIBRARY HWRMVibraClient.lib



<STEP 1>

Whatever Client that needs to monitor Touch Screen Vibration should derive from the MHWRMVibraFeedbackObserver interface and implement the VibraFeedbackModeChanged() method.


#include <HWRMVibra.h> 
 
class CVibrationModeMonitorAppView : public CCoeControl, public MHWRMVibraFeedbackObserver
{
...
 
public:
// from MHWRMVibraFeedbackObserver
virtual void VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode);
 
...
 
private:
/**
* Owned
* CHWRMVibra instance
*/

CHWRMVibra* iVibra;
};



<STEP 2>

Create CHWRMVibra instance and set CVibrationModeMonitorAppView as observer for notification of feedback setting change.


void CVibrationModeMonitorAppView::ConstructL(const TRect& aRect)
{
...
 
iVibra = CHWRMVibra::NewL();
 
// Set View as observer for notification of feedback setting change //
iVibra->SetFeedbackObserver(this);
 
...
}



<STEP 3>

Implement VibraFeedbackModeChanged().



void CVibrationModeMonitorAppView::VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode)
{
 
// Create new CAknGlobalNote instance.
CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
// Push CAknGlobalNote's pointer to CleanupStack
CleanupStack::PushL( globalNote );
TBuf<KMaxMessageLen> message;
 
switch ( aMode )
{
case CHWRMVibra::EVibraFeedbackModeON:
 
message.Copy( KVibraModeOn );
globalNote->ShowNoteL( EAknGlobalInformationNote, message );
break;
case CHWRMVibra::EVibraFeedbackModeOFF:
message.Copy( KVibraModeOff );
globalNote->ShowNoteL( EAknGlobalInformationNote, message );
break;
default:
break;
 
}
// Pop and Destroy CAknGlobalNote's pointer from CleanupStack
CleanupStack::PopAndDestroy();
 
}



<STEP 4>

Testing : For testing the Vibration Mode, run the attached application, keep the application running in the background and then try to enable/disable tactile feedback through Control Panel -> Personal -> Profiles -> <Profile_in_use> -> <Personalise> -> Touch Screen Tones.

After changing the status you will see the appropriate message on the profile screen itself, because we have used Global Notes in the example.



Postconditions

Appropriate Tactile Feedback Vibration Mode Status Events will be received by CVibrationModeMonitorAppView displaying notes with appropriate message.

Example Application

This page was last modified on 30 May 2013, at 07:34.
52 page views in the last 30 days.
×