williamr@2: /* williamr@2: * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: This file contains the header of the williamr@2: * CHWRMVibra class. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef HWRMVIBRA_H williamr@2: #define HWRMVIBRA_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: williamr@2: // CONSTANTS williamr@2: williamr@2: /** williamr@2: * Minimum allowed intensity setting for vibra. When intensity is negative, williamr@2: * the vibra motor rotates in the negative direction. williamr@2: */ williamr@2: const TInt KHWRMVibraMinIntensity = -100; williamr@2: williamr@2: /** williamr@2: * Minimum allowed intensity setting for vibra pulse. williamr@2: */ williamr@2: const TInt KHWRMVibraMinPulseIntensity = 1; williamr@2: williamr@2: /** williamr@2: * Maximum allowed intensity setting for vibra. When intensity is positive, williamr@2: * the vibra motor rotates in the positive direction. Value 0 effectively williamr@2: * stops the vibra. williamr@2: */ williamr@2: const TInt KHWRMVibraMaxIntensity = 100; williamr@2: williamr@2: /** williamr@2: * Maximum allowed duration value in milliseconds. Maximum vibrating time williamr@2: * supported by device is declared in KVibraCtrlMaxTime cenrep-key. williamr@2: * williamr@2: * Note that duration probably has device specific williamr@2: * maximum duration that is much lower. williamr@2: */ williamr@2: const TInt KHWRMVibraMaxDuration = (KMaxTInt / 1000) - 1; williamr@2: williamr@2: /** williamr@2: * KHWRMVibraInfiniteDuration specifies, that vibrating should continue maximum williamr@2: * vibrating time supported by device if vibrating is not explicitly stopped. williamr@2: * williamr@2: */ williamr@2: const TInt KHWRMVibraInfiniteDuration = 0; williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class MHWRMVibraObserver; williamr@2: class MHWRMVibraFeedbackObserver; williamr@2: williamr@2: // CLASS DECLARATIONS williamr@2: williamr@2: /** williamr@2: * The class used to control the device vibra. williamr@2: * williamr@2: * HW Resource Manager Vibra API is a library API providing ability to control williamr@2: * the device vibra. The API provides also methods to retrieve the current settings williamr@2: * of the vibration feature in the user profile and the current status of the vibra. williamr@2: * williamr@2: * The type of HW Resource Manager Vibra API is a synchronous method call meaning williamr@2: * the method call will block the client application. However, e.g. StartVibraL methods do williamr@2: * return right after device vibration has successfully been started. Callback is intended only williamr@2: * for observing vibra and feedback on/off changes. The API is meant for all williamr@2: * applications which need to control the device vibra. williamr@2: * williamr@2: * The API consist of the classes CHWRMVibra, MHWRMVibraObserver and MHWRMVibraFeedbackObserver. williamr@2: * If the client requires up-to-date status information, it should also provide callback pointer williamr@2: * of the MHWRMVibraObserver implementing class for the NewL-method and explicitly set feedback observer. williamr@2: * williamr@2: * Usage: williamr@2: * williamr@2: * @code williamr@2: * #include // link against HWRMVibraClient.lib williamr@2: * williamr@2: * // A CHWRMVibra instance can be created by using NewL() or NewLC() methods. williamr@2: * // Up-to-date status information not required, no callbacks. williamr@2: * CHWRMVibra* vibra = CHWRMVibra::NewL(); williamr@2: * williamr@2: * // After this, vibra can be directly controlled via the provided class methods. williamr@2: * vibra->StartVibraL(5000); // Start vibra for five seconds williamr@2: * vibra->StopVibraL(); // Immediately stop vibra williamr@2: * williamr@2: * // To clean up, delete the created object: williamr@2: * delete vibra; williamr@2: * @endcode williamr@2: * williamr@2: * @lib HWRMVIBRACLIENT.DLL williamr@2: * @since S60 3.0 williamr@2: */ williamr@2: class CHWRMVibra : public CBase williamr@2: { williamr@2: public: // enums williamr@2: /** williamr@2: * Vibration setting in the user profile. williamr@2: */ williamr@2: enum TVibraModeState williamr@2: { williamr@2: EVibraModeUnknown = 0, ///< Not initialized yet or there is an error condion. williamr@2: EVibraModeON, ///< Vibration setting in the user profile is on. williamr@2: EVibraModeOFF ///< Vibration setting in the user profile is off. williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Status of the vibration feature williamr@2: */ williamr@2: enum TVibraStatus williamr@2: { williamr@2: EVibraStatusUnknown = 0, ///< Vibra is not initialized yet or status is uncertain williamr@2: ///< because of an error condition. williamr@2: EVibraStatusNotAllowed, ///< Vibra is set off in the user profile or some williamr@2: ///< application is specifically blocking vibra. williamr@2: EVibraStatusStopped, ///< Vibra is stopped. williamr@2: EVibraStatusOn ///< Vibra is on. williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Tactile feedback vibration setting in the user profile. williamr@2: */ williamr@2: enum TVibraFeedbackModeState williamr@2: { williamr@2: EVibraFeedbackModeUnknown = 0, ///< Not initialized yet or there is an error condion. williamr@2: EVibraFeedbackModeON, ///< Feedback vibration setting in the user profile is on. williamr@2: EVibraFeedbackModeOFF ///< Feedback vibration setting in the user profile is off. williamr@2: }; williamr@2: williamr@2: public: // Constructors williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * williamr@2: * @return A pointer to a new instance of the CHWRMVibra class. williamr@2: * williamr@2: * @leave KErrNotSupported Device doesn't support vibration feature. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: IMPORT_C static CHWRMVibra* NewL(); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * Leaves instance to cleanup stack. williamr@2: * williamr@2: * @return A pointer to a new instance of the CHWRMVibra class. williamr@2: * williamr@2: * @leave KErrNotSupported Device doesn't support vibration feature. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: IMPORT_C static CHWRMVibra* NewLC(); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * Use this method for creating a vibra client with callbacks. williamr@2: * williamr@2: * @param aCallback Pointer to callback instance williamr@2: * @return A pointer to a new instance of the CHWRMVibra class. williamr@2: * williamr@2: * @leave KErrNotSupported Device doesn't support vibration feature. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: IMPORT_C static CHWRMVibra* NewL(MHWRMVibraObserver* aCallback); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * Use this method for creating a vibra client with callbacks. williamr@2: * Leaves instance to cleanup stack. williamr@2: * williamr@2: * @param aCallback Pointer to callback instance williamr@2: * @return A pointer to a new instance of the CHWRMVibra class. williamr@2: * williamr@2: * @leave KErrNotSupported Device doesn't support vibration feature. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: IMPORT_C static CHWRMVibra* NewLC(MHWRMVibraObserver* aCallback); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Reserves vibration feature exclusively for this client. williamr@2: * A higher priority (not process or thread priority, but the priority defined williamr@2: * in the internal vibra policy of the HW Resource Manager) client may cause williamr@2: * lower priority client reservation to be temporarily suspended. Commands williamr@2: * can still be issued in suspended state, but they will not be acted upon williamr@2: * unless suspension is lifted within specified duration. williamr@2: * The suspended client will not get any notification about suspension and williamr@2: * neither from resumption of reservation. williamr@2: * If vibra is already reserved by a higher or equal priority application, williamr@2: * reserving will still succeed, but reservation is immediately suspended. williamr@2: * williamr@2: * Calling this method is equal to call ReserveVibraL(EFalse, EFalse), williamr@2: * i.e. any previously frozen state will not be restored and CCoeEnv williamr@2: * background/foreground status is always used to control further reservations. williamr@2: * williamr@2: * @leave KErrAccessDenied No CCoeEnv present. williamr@2: * @leave KErrNotReady Trying to reserve while on background. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: virtual void ReserveVibraL()=0; williamr@2: williamr@2: /** williamr@2: * Reserves vibration feature exclusively for this client. williamr@2: * A higher priority (not process or thread priority, but the priority defined williamr@2: * in the internal vibra policy of the HW Resource Manager) client may cause williamr@2: * lower priority client reservation to be temporarily suspended. Commands williamr@2: * can still be issued in suspended state, but they will not be acted upon williamr@2: * unless suspension is lifted within specified duration. williamr@2: * The suspended client will not get any notification about suspension and williamr@2: * neither from resumption of reservation. williamr@2: * If vibra is already reserved by a higher or equal priority application, williamr@2: * reserving will still succeed, but reservation is immediately suspended. williamr@2: * williamr@2: * williamr@2: * @param aRestoreState If ETrue, the state frozen on last release will be williamr@2: * restored upon successful reservation. williamr@2: * I.e. if vibra was on when it was released by this williamr@2: * client the last time, it would continue the vibrating williamr@2: * upon successful reservation. williamr@2: * For the first reservation of each session this williamr@2: * parameter is always considered EFalse regardless of williamr@2: * what is supplied, as there is no previous frozen state williamr@2: * to restore. williamr@2: * @param aForceNoCCoeEnv If EFalse, then reservation requires that this client williamr@2: * has the keyboard focus at the time of reservation and williamr@2: * vibra will be automatically released and re-reserved williamr@2: * based on the keyboard focus status of this client. williamr@2: * This also implies that CCoeEnv::Static() != NULL is williamr@2: * required. williamr@2: * If ETrue, the client will not require CCoeEnv to be williamr@2: * present nor does it automatically reserve/release vibra williamr@2: * by depending on foreground/background status of the williamr@2: * client. williamr@2: * Only trusted clients are allowed to set this flag to williamr@2: * ETrue. A client is considered trusted if it has nonstandard williamr@2: * priority defined in the internal vibra policy of the williamr@2: * HW Resource Manager. A client can be defined trusted williamr@2: * only by S60 or a product. williamr@2: * williamr@2: * @leave KErrAccessDenied Parameter aForceNoCCoeEnv is ETrue and client is not williamr@2: * trusted. williamr@2: * @leave KErrBadHandle Parameter aForceNoCCoeEnv is EFalse and no CCoeEnv present. williamr@2: * @leave KErrNotReady Trying to reserve while on background and parameter williamr@2: * aForceNoCCoeEnv is EFalse. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: */ williamr@2: virtual void ReserveVibraL(TBool aRestoreState, TBool aForceNoCCoeEnv)=0; williamr@2: williamr@2: /** williamr@2: * Releases vibration feature if it was previously reserved for this client. williamr@2: * If this client has not reserved vibration feature, does nothing. williamr@2: * If vibra is on when it is released and no other client has a suspended williamr@2: * reservation, vibra is stopped. williamr@2: */ williamr@2: virtual void ReleaseVibra()=0; williamr@2: williamr@2: williamr@2: /** williamr@2: * Starts the device vibration feature with the product specific default williamr@2: * intensity. williamr@2: * If StartVibraL is called again before the first vibration completes williamr@2: * then the first vibration is interrupted and the second vibrations williamr@2: * starts immediately -- i.e. The periods of vibration are not cumulative. williamr@2: * williamr@2: * The vibration can be interrupted with the method StopVibraL before williamr@2: * the specified interval has elapsed. williamr@2: * williamr@2: * Vibra settings of the vibration feature in the user profile williamr@2: * must be active. williamr@2: * williamr@2: * Note: The device may have implementation defined or hardware imposed williamr@2: * limits to the duration of the vibration feature. In such williamr@2: * circumstances any vibration will cut off at that limit even if williamr@2: * the duration parameter is greater than the limit. williamr@2: * williamr@2: * @param aDuration Duration of the vibration measured in milliseconds. williamr@2: * A value of KHWRMVibraInfiniteDuration specifies that williamr@2: * the vibration should continue indefinetely and should williamr@2: * be stopped with a call to StopVibraL. Duration williamr@2: * usually has device specific maximum value. williamr@2: * williamr@2: * @leave KErrArgument Duration is invalid. williamr@2: * @leave KErrAccessDenied Vibration setting in the user profile is not set. williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrLocked Vibra is locked down because too much continuous use williamr@2: * or explicitly blocked by for example some vibration williamr@2: * sensitive accessory. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraObserver williamr@2: */ williamr@2: virtual void StartVibraL(TInt aDuration)=0; williamr@2: williamr@2: /** williamr@2: * Starts the device vibration feature. If StartVibraL is called again before williamr@2: * the first vibration completes then the first vibration is interrupted williamr@2: * and the second vibrations starts immediately -- i.e. The periods of williamr@2: * vibration are not cumulative. williamr@2: * williamr@2: * The vibration can be interrupted with the method StopVibraL before williamr@2: * the specified interval has elapsed. williamr@2: * williamr@2: * Vibra settings of the vibration feature in the user profile williamr@2: * must be active. williamr@2: * williamr@2: * Note: The device may have implementation defined or hardware imposed williamr@2: * limits to the duration of the vibration feature. In such williamr@2: * circumstances any vibration will cut off at that limit even if williamr@2: * the duration parameter is greater than the limit. williamr@2: * williamr@2: * @param aDuration Duration of the vibration measured in milliseconds. williamr@2: * A value of KHWRMVibraInfiniteDuration specifies that williamr@2: * the vibration should continue indefinetely and should williamr@2: * be stopped with a call to StopVibraL. Duration williamr@2: * usually has device specific maximum value. williamr@2: * @param aIntensity Intensity of the vibra in decimal is KHWRMVibraMinIntensity williamr@2: * to KHWRMVibraMaxIntensity, williamr@2: * which shows the percentage of the vibra motor full williamr@2: * rotation speed. When intensity is negative, williamr@2: * the vibra motor rotates in the negative direction. williamr@2: * When intensity is positive, the vibra motor rotates williamr@2: * in the positive direction. Value 0 stops the vibra. williamr@2: * NOTE: The device might have hardware-imposed limits williamr@2: * on supported vibra intensity values, so actual williamr@2: * effect might vary between different hardware. williamr@2: * williamr@2: * @leave KErrNotSupported The device doesn't support user-defined williamr@2: * vibra intensity. williamr@2: * @leave KErrArgument One of the parameters is out of range. williamr@2: * @leave KErrAccessDenied Vibration setting in the user profile williamr@2: * is not set. williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrLocked Vibra is locked down because too much continuous use williamr@2: * or explicitly blocked by for example some vibration williamr@2: * sensitive accessory. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraObserver williamr@2: */ williamr@2: virtual void StartVibraL(TInt aDuration, TInt aIntensity)=0; williamr@2: williamr@2: /** williamr@2: * Interrupts the device vibration that is started with the StartVibraL williamr@2: * method immediately. williamr@2: * williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraObserver williamr@2: */ williamr@2: virtual void StopVibraL()=0; williamr@2: williamr@2: /** williamr@2: * This method retrieves the current settings of the vibration feature williamr@2: * in the user profile. The developer can check the Vibra settings williamr@2: * in the profile and if there is no Vibra active but it is needed by williamr@2: * the client application then the user can be informed. williamr@2: * williamr@2: * @return TVibraModeState indicating the current vibra mode setting. williamr@2: * williamr@2: * @see TVibraModeState williamr@2: * @see MHWRMVibraObserver williamr@2: */ williamr@2: virtual TVibraModeState VibraSettings() const=0; williamr@2: williamr@2: /** williamr@2: * This method retrieves the current vibra status. williamr@2: * williamr@2: * @return TVibraStatus indicating the current vibra status williamr@2: * williamr@2: * @see TVibraStatus williamr@2: * @see MHWRMVibraObserver williamr@2: */ williamr@2: virtual TVibraStatus VibraStatus() const=0; williamr@2: williamr@2: /** williamr@2: * This method is intended only for firmware build time configured williamr@2: * privileged clients. williamr@2: * williamr@2: * Executes a tactile feedback vibration pulse with product williamr@2: * specific default intensity and duration. williamr@2: * If PulseVibraL is called before ongoing vibration completes and williamr@2: * PulseVibraL calling client has higher priority than executing client, williamr@2: * pulse request is accepted. Also possible vibra-reservations are bypassed. williamr@2: * If client calling PulseVibraL has lower or equal priority williamr@2: * than executing client, ongoing vibration is not affected. williamr@2: * williamr@2: * Tactile feedback vibration settings of the vibration feature in the williamr@2: * user profile must be active. williamr@2: * williamr@2: * Note: The device may have implementation defined or hardware imposed williamr@2: * limits to the duration of the vibration feature. In such williamr@2: * circumstances any vibration will cut off at that limit even if williamr@2: * the duration parameter is greater than the limit. williamr@2: * williamr@2: * @param aDuration Duration of the vibration measured in milliseconds. williamr@2: * Duration can have maximum value williamr@2: * of KHWRMVibraMaxDuration. williamr@2: * williamr@2: * @leave KErrAccessDenied Vibration setting in the user profile is not set williamr@2: * or client is not privileged to use pulse feature. williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrLocked Vibra is locked down because too much continuous use williamr@2: * or explicitly blocked by for example some vibration williamr@2: * sensitive accessory. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client or ongoing vibration williamr@2: * has been requested by higher priority client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraFeedbackObserver williamr@2: */ williamr@2: virtual void PulseVibraL()=0; williamr@2: williamr@2: /** williamr@2: * This method is intended only for firmware build time configured williamr@2: * privileged clients. williamr@2: * williamr@2: * Executes a tactile feedback vibration pulse with product williamr@2: * specific default intensity and specified duration. williamr@2: * If PulseVibraL is called before ongoing vibration completes and williamr@2: * PulseVibraL calling client has higher priority than executing client, williamr@2: * pulse request is accepted. Also possible vibra-reservations are bypassed. williamr@2: * If client calling PulseVibraL has lower or equal priority williamr@2: * than executing client, ongoing vibration is not affected. williamr@2: * williamr@2: * Tactile feedback vibration settings of the vibration feature in the williamr@2: * user profile must be active. williamr@2: * williamr@2: * Note: The device may have implementation defined or hardware imposed williamr@2: * limits to the duration of the vibration feature. In such williamr@2: * circumstances any vibration will cut off at that limit even if williamr@2: * the duration parameter is greater than the limit. williamr@2: * williamr@2: * @param aDuration Duration of the vibration measured in milliseconds. williamr@2: * Duration can have maximum value williamr@2: * of KHWRMVibraMaxDuration. williamr@2: * williamr@2: * @leave KErrArgument One of the parameters is out of range. williamr@2: * @leave KErrAccessDenied Vibration setting in the user profile is not set williamr@2: * or client is not privileged to use pulse feature. williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrLocked Vibra is locked down because too much continuous use williamr@2: * or explicitly blocked by for example some vibration williamr@2: * sensitive accessory. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client or ongoing vibration williamr@2: * has been requested by higher priority client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraFeedbackObserver williamr@2: */ williamr@2: virtual void PulseVibraL(TInt aDuration)=0; williamr@2: williamr@2: /** williamr@2: * This method is intended only for firmware build time configured williamr@2: * privileged clients. williamr@2: * williamr@2: * Executes a tactile feedback vibration pulse. williamr@2: * If PulseVibraL is called before ongoing vibration completes and williamr@2: * PulseVibraL calling client has higher priority than executing client, williamr@2: * pulse request is accepted. Also possible vibra-reservations are bypassed. williamr@2: * If client calling PulseVibraL has lower or equal priority williamr@2: * than executing client, ongoing vibration is not affected. williamr@2: * williamr@2: * Tactile feedback vibration settings of the vibration feature in the williamr@2: * user profile must be active. williamr@2: * williamr@2: * Note: The device may have implementation defined or hardware imposed williamr@2: * limits to the duration of the vibration feature. In such williamr@2: * circumstances any vibration will cut off at that limit even if williamr@2: * the duration parameter is greater than the limit. williamr@2: * williamr@2: * @param aDuration Duration of the vibration measured in milliseconds. williamr@2: * Duration can have maximum value williamr@2: * of KHWRMVibraMaxDuration. williamr@2: * @param aIntensity Intensity of the pulse in decimal is KHWRMVibraMinPulseIntensity williamr@2: * to KHWRMVibraMaxIntensity, which shows the percentage williamr@2: * of the vibra motor full rotation speed. williamr@2: * NOTE: The device might have hardware-imposed limits williamr@2: * on supported vibra intensity values, so actual williamr@2: * effect might vary between different hardware. williamr@2: * williamr@2: * @leave KErrNotSupported The device doesn't support user-defined williamr@2: * vibra intensity. williamr@2: * @leave KErrArgument One of the parameters is out of range. williamr@2: * @leave KErrAccessDenied Vibration setting in the user profile is not set williamr@2: * or client is not privileged to use pulse feature. williamr@2: * @leave KErrBadHandle Vibra session has been invalidated. williamr@2: * @leave KErrLocked Vibra is locked down because too much continuous use williamr@2: * or explicitly blocked by for example some vibration williamr@2: * sensitive accessory. williamr@2: * @leave KErrTimedOut Timeout occurred in controlling vibra. williamr@2: * @leave KErrInUse Vibra is not reserved to this client but it is williamr@2: * reserved to some other client or ongoing vibration williamr@2: * has been requested by higher priority client. williamr@2: * @leave KErrNoMemory There is a memory allocation failure. williamr@2: * @leave KErrGeneral There is a hardware error. williamr@2: * williamr@2: * @see MHWRMVibraFeedbackObserver williamr@2: */ williamr@2: virtual void PulseVibraL(TInt aDuration, TInt aIntensity)=0; williamr@2: williamr@2: /** williamr@2: * Use this method for setting feedback observer. williamr@2: * williamr@2: * @param aCallback Pointer to callback instance williamr@2: */ williamr@2: virtual void SetFeedbackObserver(MHWRMVibraFeedbackObserver* aCallback)=0; williamr@2: williamr@2: /** williamr@2: * This method retrieves the current settings of the feedback vibration feature williamr@2: * in the user profile. The developer can check the feedback vibration settings williamr@2: * in the profile and if there is no feedback vibration active but it is needed by williamr@2: * the client application then the user can be informed. However, client needs to williamr@2: * explicitly register to listen these changes via SetFeedbackObserver-method. williamr@2: * williamr@2: * @return TVibraFeedbackModeState indicating the current vibra feedback mode setting. williamr@2: * williamr@2: * @see TVibraFeedbackModeState williamr@2: * @see MHWRMVibraFeedbackObserver williamr@2: */ williamr@2: virtual TVibraFeedbackModeState VibraFeedbackSettings() const=0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * A callback interface for vibra status reporting. williamr@2: * williamr@2: * If the client requires up-to-date status information, the client needs williamr@2: * to derive a class from the MHWRMVibraObserver interface and implement williamr@2: * the VibraModeChanged() and VibraStatusChanged() methods. williamr@2: * williamr@2: * A callback object header example: williamr@2: * williamr@2: * @code williamr@2: * // INCLUDES williamr@2: * #include // Link against HWRMVibraClient.lib. williamr@2: * williamr@2: * class CTest : public CBase, williamr@2: * public MHWRMVibraObserver williamr@2: * { williamr@2: * public: williamr@2: * CTest(); williamr@2: * ~CTest(); williamr@2: * williamr@2: * void ConstructL(); williamr@2: * static CTest* NewL(); williamr@2: * williamr@2: * // from MHWRMVibraObserver williamr@2: * virtual void VibraModeChanged(CHWRMVibra::TVibraModeState aStatus); williamr@2: * virtual void VibraStatusChanged(CHWRMVibra::TVibraStatus aStatus); williamr@2: * williamr@2: * private: williamr@2: * CHWRMVibra* iVibra; williamr@2: * }; williamr@2: * @endcode williamr@2: * williamr@2: * A callback method implementation example: williamr@2: * williamr@2: * @code williamr@2: * void CTest::VibraStatusChanged(CHWRMVibra::TVibraStatus aStatus) williamr@2: * { williamr@2: * switch ( aStatus ) williamr@2: * { williamr@2: * case CHWRMVibra::EVibraStatusUnknown: williamr@2: * RDebug::Print(_L("### Vibra state changed: EVibraStatusUnknown")); williamr@2: * break; williamr@2: * case CHWRMVibra::EVibraStatusNotAllowed: williamr@2: * RDebug::Print(_L("### Vibra state changed: EVibraStatusNotAllowed")); williamr@2: * break; williamr@2: * case CHWRMVibra::EVibraStatusStopped: williamr@2: * RDebug::Print(_L("### Vibra state changed: EVibraStatusStopped")); williamr@2: * break; williamr@2: * case CHWRMVibra::EVibraStatusOn: williamr@2: * RDebug::Print(_L("### Vibra state changed: EVibraStatusOn")); williamr@2: * break; williamr@2: * default: williamr@2: * RDebug::Print(_L("### Vibra state changed: UNDEFINED !")); williamr@2: * break; williamr@2: * } williamr@2: * } williamr@2: * @endcode williamr@2: * williamr@2: * @since S60 3.0 williamr@2: */ williamr@2: class MHWRMVibraObserver williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Called when the vibration setting in the user profile is changed. williamr@2: * williamr@2: * @param aStatus Indicates the new setting. williamr@2: * williamr@2: * @see CHWRMVibra::TVibraModeState williamr@2: */ williamr@2: virtual void VibraModeChanged(CHWRMVibra::TVibraModeState aStatus) = 0; williamr@2: williamr@2: /** williamr@2: * Called when the device vibration feature state changes williamr@2: * williamr@2: * @param aStatus Indicates vibra status. williamr@2: * williamr@2: * @see CHWRMVibra::TVibraStatus williamr@2: */ williamr@2: virtual void VibraStatusChanged(CHWRMVibra::TVibraStatus aStatus) = 0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * A callback interface for tactile feedback vibra mode reporting. williamr@2: * williamr@2: * If the client requires up-to-date status information, the client needs williamr@2: * to derive a class from the MHWRMVibraFeedbackObserver interface and implement williamr@2: * the VibraFeedbackModeChanged() method. In order to register for callback, client williamr@2: * needs to call SetFeedbackObserver-method. williamr@2: * williamr@2: * A callback object header example: williamr@2: * williamr@2: * @code williamr@2: * // INCLUDES williamr@2: * #include // Link against HWRMVibraClient.lib. williamr@2: * williamr@2: * class CTest : public CBase, williamr@2: * public MHWRMVibraFeedbackObserver williamr@2: * { williamr@2: * public: williamr@2: * CTest(); williamr@2: * ~CTest(); williamr@2: * williamr@2: * void ConstructL(); williamr@2: * static CTest* NewL(); williamr@2: * williamr@2: * // from MHWRMVibraFeedbackObserver williamr@2: * virtual void VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode); williamr@2: * williamr@2: * private: williamr@2: * CHWRMVibra* iVibra; williamr@2: * }; williamr@2: * @endcode williamr@2: * williamr@2: * A callback method implementation example: williamr@2: * williamr@2: * @code williamr@2: * williamr@2: * #include // link against HWRMVibraClient.lib williamr@2: * williamr@2: * // A CHWRMVibra instance can be created by using NewL() or NewLC() methods. williamr@2: * CHWRMVibra* vibra = CHWRMVibra::NewL(); williamr@2: * williamr@2: * // Request notification of feedback setting change williamr@2: * vibra->SetFeedbackObserver(this); williamr@2: * williamr@2: * // To clean up, delete the created object: williamr@2: * delete vibra; williamr@2: * williamr@2: * void CTest::VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode) williamr@2: * { williamr@2: * switch ( aMode ) williamr@2: * { williamr@2: * case CHWRMVibra::EVibraFeedbackModeUnknown: williamr@2: * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeUnknown")); williamr@2: * break; williamr@2: * case CHWRMVibra::EVibraFeedbackModeON: williamr@2: * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeON")); williamr@2: * break; williamr@2: * case CHWRMVibra::EVibraFeedbackModeOFF: williamr@2: * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeOFF")); williamr@2: * break; williamr@2: * default: williamr@2: * break; williamr@2: * } williamr@2: * } williamr@2: * @endcode williamr@2: * williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: class MHWRMVibraFeedbackObserver williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Called when the tactile feedback vibration setting in the user profile is changed. williamr@2: * williamr@2: * @param aMode Indicates the new setting. williamr@2: * williamr@2: * @see CHWRMVibra::TVibraFeedbackModeState williamr@2: */ williamr@2: virtual void VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode) = 0; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif // HWRMVIBRA_H williamr@2: williamr@2: // End of File