resourcemgmt/vibractrl/inc/vibractrl.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:  Vibra Control API
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VIBRA_CTRL_H__
       
    20 #define VIBRA_CTRL_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <e32std.h>
       
    25 
       
    26 /**
       
    27  *  Interface that is used to control the device vibration feature.
       
    28  *  This class provides the ability to control the device vibration feature.
       
    29  *  Vibration might be used in a game to signal a collision or explosion or for
       
    30  *  giving tactile feedback to gaming events, such as a ball hitting 
       
    31  *  a wall (shaking).
       
    32  *
       
    33  *  @lib VibraCtrl.DLL
       
    34  *  @since 2.0
       
    35  *  @deprecated since Series 60 3.0 - Use HWRM Vibra API instead (HWRMVibra.h)
       
    36  */  
       
    37 class CVibraControl : public CBase
       
    38     {  
       
    39     public:
       
    40         /**
       
    41         * Vibration setting in the user profile.
       
    42         * @deprecated since Series 60 3.0
       
    43         */
       
    44         enum TVibraModeState 
       
    45             {
       
    46             EVibraModeON = 0,   // Vibration setting in the user profile is on.
       
    47             EVibraModeOFF,      // Vibration setting in the user profile is off.
       
    48             EVibraModeUnknown   // For debugging/development and signalling an error condition.
       
    49             };
       
    50 
       
    51         /**
       
    52         * Status of the vibrating setting request.
       
    53         * @deprecated since Series 60 3.0
       
    54         */
       
    55         enum TVibraRequestStatus 
       
    56             {
       
    57             EVibraRequestOK = 0,      // Request is OK.
       
    58             EVibraRequestFail,        // Request has failed.
       
    59             EVibraRequestNotAllowed,  // Vibra is set off in the user profile
       
    60             EVibraRequestStopped,     // Vibra is stopped
       
    61             EVibraRequestUnableToStop,// Unable to stop vibra
       
    62             EVibraRequestUnknown      // For debugging/development and signalling an error condition.
       
    63             };
       
    64 
       
    65         /**
       
    66         * Internal panic codes.
       
    67         * @deprecated since Series 60 3.0
       
    68         */
       
    69         enum TVibraCtrlPanic 
       
    70             {
       
    71             EPanicUnableToGetVibraSetting,
       
    72             EPanicVibraGeneral
       
    73             };
       
    74 
       
    75     public:
       
    76         /**
       
    77         * Destructor.
       
    78         * @deprecated since Series 60 3.0
       
    79         */
       
    80         virtual ~CVibraControl();
       
    81 
       
    82         /**
       
    83         * Starts the device vibration feature with factory-defined intensity.
       
    84         * The method does not block, but returns immediately so that the 
       
    85         * vibration happens simultaneously as the game continues to run.
       
    86         * If StartVibra is called again before the first vibration completes
       
    87         * then the first vibration is interrupted and the second vibrations
       
    88         * starts immediately -- i.e. The periods of vibration are not cumulative.
       
    89         *
       
    90         * The vibration can be interrupted with the method StopVibra before
       
    91         * the specified interval has elasped.
       
    92         *
       
    93         * Vibra settings of the vibration feature in the user profile 
       
    94         * must be active. If no, vibration is not activated.
       
    95         *
       
    96         * Note: The device may have implementation defined or hardware imposed
       
    97         *       limits to the duration of the vibration feature. In such 
       
    98         *       circumstances any vibration will cut off at that limit even if
       
    99         *       the duration parameter is greater than the limit.
       
   100         *
       
   101         * @param aDuration Duration of the vibration measured in milliseconds. 
       
   102         *                  A value of 0 specifies that the vibration should
       
   103         *                  continue indefinitly and should be stopped with a 
       
   104         *                  call to StopVibra.
       
   105         * @exception KErrGeneral Unable to start vibra.
       
   106         *            KErrNotSupported Device doesn't support vibration feature.
       
   107         * @see MVibraControlObserver
       
   108         * @deprecated since Series 60 3.0
       
   109         */
       
   110         virtual void StartVibraL(TUint16 aDuration) = 0;
       
   111 		
       
   112         /**
       
   113         * Interrupts the device vibration that is started with the StartVibra
       
   114         * method immediately.
       
   115         *
       
   116         * @exception KErrNotSupported Device doesn't support vibration feature.
       
   117         * @see MVibraControlObserver
       
   118         * @deprecated since Series 60 3.0
       
   119         */		
       
   120         virtual void StopVibraL(void) = 0; 
       
   121 		
       
   122         /**
       
   123         * This method retrieves the current settings of the vibration feature
       
   124         * in the user profile. The developer can check the Vibra settings 
       
   125         * in the profile and if there is no Vibra active but it is needed by 
       
   126         * the game then the user can be informed, or asked if he wants to enable
       
   127         * the Vibra during the game.
       
   128         * @return TVibraModeState with the possible states EvibraModeON, 
       
   129         *                         EVibraModeOFF or, 
       
   130         *                         if an error occurs, EVibraModeUnknown
       
   131         * @deprecated since Series 60 3.0
       
   132         */
       
   133         virtual TVibraModeState VibraSettings(void) const = 0;
       
   134 
       
   135         /**
       
   136         * Starts the device vibration feature. The method does not block, 
       
   137         * but returns immediately so that the vibration happens simultaneously
       
   138         * as the game continues to run. If StartVibra is called again before
       
   139         * the first vibration completes then the first vibration is interrupted
       
   140         * and the second vibrations starts immediately -- i.e. The periods of
       
   141         * vibration are not cumulative.
       
   142         *
       
   143         * The vibration can be interrupted with the method StopVibra before
       
   144         * the specified interval has elasped.
       
   145         *
       
   146         * Vibra settings of the vibration feature in the user profile 
       
   147         * must be active. If no, vibration is not activated.
       
   148         *
       
   149         * Note: The device may have implementation defined or hardware imposed
       
   150         *       limits to the duration of the vibration feature. In such 
       
   151         *       circumstances any vibration will cut off at that limit even if
       
   152         *       the duration parameter is greater than the limit.
       
   153         *
       
   154         *
       
   155         * @param aDuration Duration of the vibration measured in milliseconds. 
       
   156         *                  A value of 0 specifies that the vibration should
       
   157         *                  continue indefinitly and should be stopped with a 
       
   158         *                  call to StopVibra.
       
   159         * @param aIntensity Intensity of the vibra in decimal is -100 to 100,
       
   160         *                   which shows the percentage of the vibra motor full
       
   161         *                   rotation speed. When intensity is negative, 
       
   162         *                   the vibra motor rotates in the negative direction.
       
   163         *                   When intensity is positive, the vibra motor rotates
       
   164         *                   in the positive direction. Value 0 stops the vibra.
       
   165         * @exception KErrGeneral Unable to start vibra.
       
   166         *            KErrNotSupported Device doesn't support user-defined 
       
   167         *            intensity or vibration feature is not supported.
       
   168         *            KErrArgument One of the parameters is out of range.
       
   169         * @see MVibraControlObserver
       
   170         * @deprecated since Series 60 3.0
       
   171         */
       
   172 	    virtual void StartVibraL(TUint16 aDuration, TInt aIntensity) = 0;
       
   173 	
       
   174     protected:
       
   175        /**
       
   176         * C++ default constructor.
       
   177         * @see VibraFactory
       
   178         * @deprecated since Series 60 3.0
       
   179         */
       
   180         CVibraControl();
       
   181     };
       
   182 
       
   183 /**
       
   184 *  An interface the developer implements for handling notifies events. 
       
   185 *
       
   186 *  @lib VibraCtrl.DLL
       
   187 *  @since 2.0
       
   188 *  @deprecated since Series 60 3.0 - Use HWRM Vibra API instead (HWRMVibra.h)
       
   189 */
       
   190 class MVibraControlObserver
       
   191     {    
       
   192     public:
       
   193         /** 
       
   194         * Called when the vibration setting in the user profile is changed.
       
   195         * @param aStatus Indicates the new setting.
       
   196         * @deprecated since Series 60 3.0
       
   197         */
       
   198         virtual void VibraModeStatus(CVibraControl::TVibraModeState aStatus) = 0;
       
   199         /** 
       
   200         * Called when the device vibration feature is requested.
       
   201         * @param aStatus Indicates vibra request status.
       
   202         * @deprecated since Series 60 3.0
       
   203 		*/
       
   204         virtual void VibraRequestStatus(CVibraControl::TVibraRequestStatus aStatus) = 0;
       
   205 	};
       
   206 
       
   207 /**
       
   208 *  Factory to create instance of the VibraControl.
       
   209 *
       
   210 *  @lib VibraCtrl.DLL
       
   211 *  @since 2.0
       
   212 *  @deprecated since Series 60 3.0 - Use HWRM Vibra API instead (HWRMVibra.h)
       
   213 */
       
   214 class VibraFactory
       
   215     {
       
   216     public:
       
   217         /**
       
   218         * Create a CVibraControl object without notify handling.
       
   219         * @deprecated since Series 60 3.0
       
   220         */
       
   221         IMPORT_C static CVibraControl* NewL(); 
       
   222 		
       
   223         /** 
       
   224         * Create a CVibraControl Object using notify handling
       
   225         * The clients of this code will be notified about every change
       
   226         * of the vibration setting in the user profile via the 
       
   227         * MvibraControlObserver interface.
       
   228         *
       
   229         * @param aCallback A reference to a class implementing 
       
   230         *                  the MVibraControlObserver interface.
       
   231         *                  If aCallback is NULL, notify handling is
       
   232         *                  not enabled.
       
   233         * @see MVibraControlObserver
       
   234         * @deprecated since Series 60 3.0
       
   235         */
       
   236         IMPORT_C static CVibraControl* NewL(MVibraControlObserver* aCallback);
       
   237 
       
   238         /** 
       
   239         * Create a CVibraControl Object using notify handling
       
   240         * The clients of this code will be notified about every change
       
   241         * of the vibration setting in the user profile via the 
       
   242         * MvibraControlObserver interface. The object is left to cleanup stack.
       
   243         *
       
   244         * @param aCallback A reference to a class implementing 
       
   245         *                  the MVibraControlObserver interface.		
       
   246         *                  If aCallback is NULL, notify handling is
       
   247         *                  not enabled.
       
   248         * @see MVibraControlObserver
       
   249         * @deprecated since Series 60 3.0
       
   250         */
       
   251         IMPORT_C static CVibraControl* NewLC(MVibraControlObserver* aCallback);
       
   252 
       
   253     private:
       
   254         /**
       
   255         * C++ default constructor.
       
   256         * @deprecated since Series 60 3.0
       
   257         */
       
   258         VibraFactory();
       
   259     };
       
   260 
       
   261 #endif // VIBRA_CTRL_H__