tactilefeedback/tactilefeedbackresolver/inc/tactilefeedbackresolver.h
changeset 0 d54f32e146dd
child 12 63c33341dc19
equal deleted inserted replaced
-1:000000000000 0:d54f32e146dd
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class for resolving physical feedback type based on 
       
    15 *                tactile feedback settings and current device state.
       
    16 * Part of:      Tactile Feedback.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef C_TACTILEFEEDBACKRESOLVER_H
       
    22 #define C_TACTILEFEEDBACKRESOLVER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <touchlogicalfeedback.h>
       
    26 #include <cenrepnotifyhandler.h>
       
    27 
       
    28 #include "tactilepropertyobserver.h"
       
    29 
       
    30 class CRepository;
       
    31 class CTactilePlayer;
       
    32 class CTactilePropertyWatcher;
       
    33 
       
    34 /**
       
    35  *  Class for procuding physical feedback based on logical
       
    36  *  feedback type.
       
    37  *
       
    38  *  Feedback is generated according to Tactile Feedback settings and
       
    39  *  current device state, and it may be that feedback is not even generated
       
    40  *  at all.
       
    41  *
       
    42  *  @lib tactilefeedbackresolver.lib
       
    43  *  @since S60 5.2
       
    44   */
       
    45 class CTactileFeedbackResolver: public CBase,
       
    46                                 public MTactilePropertyObserver,
       
    47                                 public MCenRepNotifyHandlerCallback
       
    48     {
       
    49 public:
       
    50 
       
    51     static CTactileFeedbackResolver* NewL();
       
    52 
       
    53     virtual ~CTactileFeedbackResolver();
       
    54 
       
    55     /**
       
    56      * Produces immediately physical feedback according to given
       
    57      * logical feedback type.
       
    58      *
       
    59      * Actual physical feedback type depends on settings of existing player 
       
    60      * plugins and current device state.
       
    61      *
       
    62      * @param aFeedback  - Logical feedback type.
       
    63      * @param aPlayVibra - If EFalse then vibra feedback is not played.
       
    64      * @param aPlayAudio - If EFalse then audio feedback is not played.
       
    65      */
       
    66     void PlayFeedback( TTouchLogicalFeedback aFeedback,
       
    67                        TBool aPlayVibra,
       
    68                        TBool aPlayAudio );
       
    69 
       
    70     /**
       
    71      * Starts playing continuous feedback.
       
    72      *
       
    73      * @since S60 5.2
       
    74      * @param aType         - Type of continuous feedback to be played.
       
    75      * @param aIntensity    - Intensity of continuous feedback. Value
       
    76      *                        range for intensity is 0-100%.
       
    77      */ 
       
    78     void StartFeedback( TTouchContinuousFeedback aType,
       
    79                         TInt aIntensity );
       
    80                         
       
    81     /**
       
    82      * Modifies the intensity of ongoing continuous feedback.
       
    83      * @since S60 5.2
       
    84      * @param aIntensity    - New intensity for continuous feedback. Value
       
    85      *                        range for intensity is 0-100%. 
       
    86      */                         
       
    87     void ModifyFeedback( TInt aIntensity );
       
    88     
       
    89     /**
       
    90      * Stops the ongoing continuous feedback.
       
    91      *
       
    92      * @since S60 5.2
       
    93      */    
       
    94     void StopFeedback();
       
    95     
       
    96     /**
       
    97      * Produces immediate physical feedback according to given
       
    98      * logical feedback type and given level. 
       
    99      *
       
   100      * @since S60 5.2
       
   101      * @param aLevel        - Level value defines the strength of playing 
       
   102      *                        effect. Maximum level value is player dependent.
       
   103      * @param aFeedbackType - Logical feedback type.
       
   104      * @param aType         - Type of feedback to be previewed. 
       
   105      */    
       
   106     void PlayPreviewFeedback( TInt aLevel,
       
   107                               TTouchLogicalFeedback aFeedback,
       
   108                               TTouchFeedbackType aType );
       
   109 
       
   110     /**
       
   111      * Starts playing continuous feedback of given type on given level.
       
   112      *
       
   113      * @since S60 5.2
       
   114      * @param aLevel        - Level value defines the strength of playing 
       
   115      *                        effect. Maximum level value is player dependent.     
       
   116      * @param aFeedback     - Type of continuous feedback to be played.
       
   117      * @param aIntensity    - Intensity of continuous feedback. Value
       
   118      *                        range for intensity is 0-100% from basic
       
   119      *                        strength (aLevel).
       
   120      * @param aType         - Type of feedback to be previewed.
       
   121      */    
       
   122     void StartPreviewFeedback( TInt aLevel,
       
   123                                TTouchContinuousFeedback aFeedback,
       
   124                                TInt aIntensity,
       
   125                                TTouchFeedbackType aType );
       
   126 
       
   127     /**
       
   128      * Stops the ongoing preview of continuous feedback.
       
   129      *
       
   130      * @since S60 5.2
       
   131      */
       
   132     void StopPreviewFeedback();    
       
   133 
       
   134 private:
       
   135     /**
       
   136      * Constructor.
       
   137      */
       
   138     CTactileFeedbackResolver();
       
   139 
       
   140     /**
       
   141      * 2nd phase constructor..
       
   142      */
       
   143     void ConstructL();
       
   144 
       
   145     /**
       
   146      * Central repository related initializations.
       
   147      */
       
   148     void InitializeCrKeysL();
       
   149 
       
   150     /**
       
   151      * Publish & Subscribe related initializations.
       
   152      */
       
   153      void InitializePsKeysL();
       
   154      
       
   155     /**
       
   156      * This function reads the feedback enabled/disabled value from
       
   157      * the dedicated P&S key, and stores it into iFeedbackEnabled
       
   158      * -member variable.
       
   159      *
       
   160      * Dedicated fuction used for avoiding duplicate code (in
       
   161      * construction and when the P&S key changes)
       
   162      */
       
   163      void ReadFeedbackEnabledFromPS();
       
   164      
       
   165 // from base class MTactilePropertyObserver
       
   166 
       
   167     /**
       
   168      * From MTactilePropertyObserver
       
   169      *
       
   170      * This is called when the property for temporary disabling feedback
       
   171      * is updated.
       
   172      *
       
   173      * @param aCategory - The UID of the changed property
       
   174      * @param aKey      - The key (i.e. identifier) of the changed property
       
   175      */
       
   176     void PropertyChangedL( const TUid aCategory, 
       
   177                            const TUint aKey );
       
   178                            
       
   179     
       
   180 //from base class MCenRepNotifyHandlerCallback.
       
   181 
       
   182     /**
       
   183      * From MCenRepNotifyHandlerCallback.
       
   184      *
       
   185      * This is called when Tactile Feedback settings in Central Repository
       
   186      * are changed.
       
   187      *
       
   188      * @param aId       - The id of the changed Central Repository value.
       
   189      */        
       
   190     void HandleNotifyGeneric( TUint32 aId );
       
   191         
       
   192 private: 
       
   193     /**
       
   194      * Handle changes in tactile feedback settings.
       
   195      */    
       
   196     void DoHandleNotifyGenericL( TUint32 aId );
       
   197     
       
   198     /**
       
   199      * Create haptics player. ECom implementation uid is used for selecting
       
   200      * the player plugin. 
       
   201      */    
       
   202     void CreateHapticsPlayerL( TUid aHapticsUid );
       
   203     
       
   204     /**
       
   205      * Create audio player. ECom implementation uid is used for selecting
       
   206      * the player plugin.
       
   207      */    
       
   208     void CreateAudioPlayerL( TUid aAudioUid );
       
   209      
       
   210 private: // data
       
   211 
       
   212     /**
       
   213      * Access to the P&S property, which is used for temporary disabling
       
   214      * the feedback.
       
   215      * Own.  
       
   216      */
       
   217     CTactilePropertyWatcher* iPropertyWatcher;
       
   218     
       
   219     /**
       
   220      * Haptics player.
       
   221      * Own.  
       
   222      */
       
   223     CTactilePlayer*       iHapticsPlayer;
       
   224     
       
   225     /**
       
   226      * Audio player.
       
   227      * Own.  
       
   228      */    
       
   229     CTactilePlayer*       iAudioPlayer;
       
   230     
       
   231     /**
       
   232      * Central repository for reading tactile feedback settings.
       
   233      * Own.
       
   234      */
       
   235     CRepository*          iRepository;
       
   236     
       
   237     /**
       
   238      * Central repository notifier, which sends notification when tactile 
       
   239      * feedback settings has been changed.
       
   240      * Own.
       
   241      */
       
   242     CCenRepNotifyHandler* iCenRepNotifier; 
       
   243     
       
   244     /**
       
   245      * This flag indicates the vibra feedback state according to the P&S key
       
   246      * that can be used for globally disabling vibra and/or audio
       
   247      * feedback.  
       
   248      */    
       
   249     TBool iVibraEnabled;
       
   250     
       
   251     /**
       
   252      * This flag indicates the audio feedback state according to the P&S key
       
   253      * that can be used for globally disabling vibra and/or audio
       
   254      * feedback.  
       
   255      */    
       
   256     TBool iAudioEnabled;
       
   257     
       
   258     /**
       
   259      * This flag indicates whether the continuous feedback is started or not.
       
   260      * 
       
   261      */
       
   262     TBool iFeedbackStarted;
       
   263     
       
   264     /**
       
   265      * Minimum interval between feedbacks.
       
   266      * 
       
   267      */
       
   268     TTimeIntervalMicroSeconds iMinimumInterval;
       
   269     
       
   270     /**
       
   271      * Timestamp of the last played feedback.
       
   272      * 
       
   273      */    
       
   274     TTime iLastFeedbackTimeStamp;
       
   275     
       
   276     /**
       
   277      * This flag determinates the playing order of feedback types.
       
   278      * ETrue  - vibra feedback is played first.
       
   279      * EFalse - audio feedback is played first.
       
   280      */
       
   281     TBool iVibraFirst;
       
   282     };
       
   283 
       
   284 
       
   285 #endif // C_TACTILEFEEDBACKPLAYER_H