tactilefeedback/tactilefeedbackresolver/plugins/tactilevibraplugin/inc/tactilevibraplayer.h
changeset 0 d54f32e146dd
equal deleted inserted replaced
-1:000000000000 0:d54f32e146dd
       
     1 /*
       
     2 * Copyright (c) 2007 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 producing vibra feedback.
       
    15 * Part of:      Tactile Feedback.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef C_TACTILEVIBRAPLAYER_H
       
    20 #define C_TACTILEVIBRAPLAYER_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <cenrepnotifyhandler.h>
       
    25 #include <touchlogicalfeedback.h>
       
    26 
       
    27 #include "tactileplayer.h"
       
    28 
       
    29 class CHWRMVibra;
       
    30 
       
    31 /**
       
    32  *  Class for procuding vibra feedback based on logical
       
    33  *  feedback type.
       
    34  *
       
    35  *  @lib tactilevibraplugin.lib
       
    36  *  @since S60 5.2
       
    37   */
       
    38 
       
    39 NONSHARABLE_CLASS( CTactileVibraPlayer ): public CTactilePlayer,
       
    40                                           public MCenRepNotifyHandlerCallback
       
    41     {
       
    42 public:
       
    43     /**  
       
    44      * Parameters of one vibrator effect 
       
    45      */
       
    46     struct TTactileVibraParams
       
    47         {
       
    48         TInt iTime;
       
    49         TInt iIntensity;
       
    50         };
       
    51 
       
    52     /**
       
    53      * 2-phased constructor.
       
    54      * @param aRepository - Reference to Central Repository.
       
    55      * @return Instance of CTactileVibraPlayer.
       
    56      */
       
    57     static CTactileVibraPlayer* NewL( CRepository& aRepository );
       
    58 
       
    59     /**
       
    60      * Destructor.
       
    61      */
       
    62     virtual ~CTactileVibraPlayer();
       
    63 
       
    64  // from base class CTactilePlayer
       
    65  
       
    66     /**
       
    67      * @see CTactilePlayer.
       
    68      */ 
       
    69     TInt PlayFeedback( TTouchLogicalFeedback aFeedback );
       
    70     
       
    71     /**
       
    72      * @see CTactilePlayer.
       
    73      */     
       
    74     TInt StartFeedback( TTouchContinuousFeedback aFeedback,
       
    75                         TInt aIntensity );
       
    76 
       
    77     /**
       
    78      * @see CTactilePlayer.
       
    79      */ 
       
    80     TInt ModifyFeedback( TInt aIntensity );
       
    81 
       
    82     /**
       
    83      * @see CTactilePlayer.
       
    84      */ 
       
    85     void StopFeedback();    
       
    86     
       
    87     /**
       
    88      * @see CTactilePlayer.
       
    89      */    
       
    90     TInt PlayPreviewFeedback( TInt aLevel, TTouchLogicalFeedback aFeedback );
       
    91         
       
    92 
       
    93 private: // From MCenRepNotifyHandlerCallback.
       
    94     /**
       
    95      * @see MCenRepNotifyHandlerCallback.
       
    96      */ 
       
    97     void HandleNotifyInt( TUint32 aId, TInt aNewValue );
       
    98 
       
    99 private:
       
   100     /**
       
   101      * Plays vibra effect by logical feedback type.
       
   102      */
       
   103     void DoPlayFeedbackL( TInt aTime, TInt aIntensity );
       
   104 
       
   105     /**
       
   106      * Starts continuous vibra effect by logical feedback type.
       
   107      */
       
   108     void DoStartFeedbackL( TTouchContinuousFeedback aType,
       
   109                            TInt aIntensity );
       
   110     /**
       
   111      * Read settings values.
       
   112      */ 
       
   113     void ReadSettings();
       
   114 
       
   115 private:
       
   116     /**
       
   117      * Constructor.
       
   118      */
       
   119     CTactileVibraPlayer( CRepository& aRepository );
       
   120 
       
   121     /**
       
   122      * 2nd phase constructor.
       
   123      */
       
   124     void ConstructL();
       
   125     
       
   126 
       
   127 private: // data
       
   128 
       
   129     /**
       
   130      * Array for storing vibrator parameters for each
       
   131      * different physical feedback type.
       
   132      */
       
   133     RArray<TTactileVibraParams> iVibraParams;
       
   134 
       
   135     /**
       
   136      * Access to vibra functionality
       
   137      * Own.  
       
   138      */
       
   139     CHWRMVibra* iVibra;
       
   140     
       
   141      /**
       
   142      * Access to settings.
       
   143      * Not own.
       
   144      */    
       
   145     CRepository& iRepository;
       
   146     
       
   147     /**
       
   148      * Utility for listening to changes in configurable parameters.
       
   149      * Own.  
       
   150      */
       
   151     CCenRepNotifyHandler* iCenRepNotifier;    
       
   152     
       
   153     /**
       
   154      * Current vibra level.
       
   155      */
       
   156     TInt iVibraLevel;
       
   157     
       
   158     /**
       
   159      * Original vibra level is saved here when preview is played.
       
   160      */    
       
   161     TInt iOriginalLevel;
       
   162     
       
   163     };
       
   164 
       
   165 
       
   166 #endif // C_TACTILEVIBRAPLAYER_H