#include <hwrmhaptics.h>
class CHWRMHaptics : public CBase |
The class used to control the device's haptics feature.
The Haptics API provides the ability to control the device's haptics feature. The API provides methods for receiving the current status and effect completion of the haptics. The API provides synchronous and asynchronous versions of playing methods due to the nature of effect playing where multiple calls may be made to play effects. Synchronous methods are provided for other API functionality. They will block the calling client during their execution. The API is meant for all applications which need to control the device's haptics feature.
The API consist of the class CHWRMHaptics and related observer classes: MHWRMHapticsObserver and MHWRMHapticsActuatorObserver. If the client requires up-to-date status information, it can be achieved by deriving the client from MHWRMHapticsObserver or MHWRMHapticsActuatorObserver or from both and providing a callback pointer(s) of the implementing class for the NewL() method.
// =================================================================== // Usage example 1: // - Setting the license key. // - Playing a periodic effect // - Preconditions: // - Haptics feature must be enabled by the system. // =================================================================== #include <hwrmhaptics.h> // link against hwrmhapticsclient.lib #include <hwrmlogicalactuators.h> // enumeration of logical actuators TInt minPeriod( 0 ); TInt effectHandle( 0 ); TInt suppAct( 0 ); CHWRMHaptics* haptics = CHWRMHaptics::NewL( NULL, NULL ); haptics->SupportedActuators( suppAct ); if( EHWRMLogicalActuatorDevice & suppAct ) { haptics->OpenActuatorL( EHWRMLogicalActuatorDevice ); } else if ( EHWRMLogicalActuatorAny & suppAct ) { haptics->OpenActuatorL( EHWRMLogicalActuatorAny ); } // 3rd party developers can obtain the license key from Nokia Developer _LIT8( KLicenseKey,"_this_value_must_be_32_in_length" ); User::LeaveIfError( haptics->SetDeviceProperty( THWRMHapticsDevicePropertyTypes::EHWRMHapticsLicenseKey, KLicenseKey ) ); // --> now playing effects is possible CHWRMHaptics::THWRMHapticsPeriodicEffect periodicEff; periodicEff.iDuration = 5000; periodicEff.iMagnitude = 5000; periodicEff.iPeriod = minPeriod; periodicEff.iStyle = CHWRMHaptics::EHWRMHapticsStyleSharp; periodicEff.iAttackTime = 250; periodicEff.iAttackLevel = 10000; periodicEff.iFadeTime = 250; periodicEff.iFadeLevel = 0; haptics->PlayPeriodicEffect( periodicEff, effectHandle ); // ... something happened in the application and it has lost focus // so stop the effect immediately haptics->StopPlayingEffect( effectHandle ); // ================================================================ // Usage example 2: // - Loading effect data from a file and playing effects from the // loaded data. // - Preconditions: // - license key is set // - Recommended usage style: // - Effect data file can contain definition(s) of periodic // effects, magsweep effects or a combination of these basic // types called timeline effects, which call basic effects in // sequence thus forming new more complex effects. // - Load the effect data once in the client application. // - Play effects from the loaded data using the effectIndex // ================================================================ // Use S60 FileSystem to load the effect data file to a buffer ... // Effect data has been read into a descriptor by the user. // Load the effect data to be used by the haptic subsystem. TInt fileHandle( 0 ); User::LeaveIfError( haptics->LoadEffectData( data, fileHandle ) ); TInt effectIndex = 0; TInt hapticsStatus = haptics->PlayEffect( fileHandle, effectIndex, effectHandle ); hapticsStatus = haptics->DeleteEffectData( fileHandle ); if( KErrNone != hapticsStatus ) { // do some error handling... } delete haptics; haptics = NULL;
Common error codes returned by the Haptics API methods.
KErrArgument Argument is invalid, e.g., malformatted effect data, or too large magnitude value. KErrAccessDenied The license key is not set when trying to use some haptics method. KErrNoMemory There is insufficient memory available for the method to complete. KErrNotReady Initialization has not been done properly when trying to use a haptics method.
Device's capability types.
Use TInt& aDeviceCapabilityValue overloaded version of the method GetDeviceCapability() unless otherwise mentioned.
Enumerator | Value | Description |
---|---|---|
EHWRMHapticsDeviceCategory | 0 |
Device category. See THWRMHapticsDeviceCategory enumeration defined later in this API header for possible values. |
EHWRMHapticsMaxNestedRepeats |
The maximum number of nested repeat bars supported for Timeline effects. Any repeat bars nested beyond this level are played only once. | |
EHWRMHapticsNumActuators |
Number of vibration actuators present in the device. | |
EHWRMHapticsActuatorType |
Actuator type See THWRMHapticsActuatorType enumeration defined later in this API header for possible values. | |
EHWRMHapticsNumEffectSlots |
Number of effect slots. The number of effect slots represents the maximum number of simple effects that can play simultaneously. If an attempt is made to play more than this number of effects at the same time, some of the simple effects do not play. | |
EHWRMHapticsSupportedStyles |
Supported effect styles, stored as a bitfield. See THWRMHapticsSupportedEffectStyles enumeration defined later in this API header for possible values. | |
EHWRMHapticsMinPeriod |
Minimum period for Periodic effects. | |
EHWRMHapticsMaxPeriod |
Maximum period for Periodic effects. | |
EHWRMHapticsMaxEffectDuration |
Maximum duration for MagSweep and Periodic effects measured in milliseconds. | |
EHWRMHapticsSupportedEffects |
Supported effect types. Stored as a bitfield. See THWRMHapticsSupportedEffectTypes enumeration defined later in this API header for possible values. | |
EHWRMHapticsDeviceName |
Device name. Use TDes8& aDeviceCapabilityValue overloaded version of the method GetDeviceCapability(). | |
EHWRMHapticsMaxEnvelopeTime |
Maximum start time or fade time in milliseconds for effect envelopes of MagSweep or periodic effects. | |
EHWRMHapticsAPIVersionNumber |
Version number of the physical haptics player in the device in hexadecimal format. The format is OxMMNNSSBB, where MM is the major version number, NN is the minor version number, SS is a special build number and BB is the VTMP build number. For example, for the hexadecimal format 0x02000053 the version number is 2.0.83 | |
EHWRMHapticsMaxEffectDataSize | 14 |
Maximum size in bytes of effect data (buffer) that can be played on a non-tethered device. |
THWRMHapticsDevicePropertyTypes enumeration Use SetDeviceProperty() to set properties for the haptics and GetDeviceProperty() to get properties currently in use.
Enumerator | Value | Description |
---|---|---|
EHWRMHapticsLicensekey | 0 |
License key property. Usable with SetDeviceProperty() only. Use const TDesC8& overloaded version of the method. Setting this property to a valid license key unlocks the haptics subsystem in the device. Setting this property to an invalid license key locks the haptics in the device (for this client). The haptics in the device are locked from clients by default. When haptics is locked, all haptics related operations on the device, except for setting the license key and closing the device, fail. Haptics must be unlocked on a per instance basis. |
EHWRMHapticsPriority |
Property used to set/get the priority for effects to played for the given haptics instance (i.e., for the given client). Use TInt overloaded version of the methods SetDeviceProperty()and GetDeviceProperty() to use this property. Different haptics instances can use different priorities on the same physical device. The priority determines which haptics instance's effects are played when multiple haptics instances are attempting to play effects at the same time. The default priority is DefaultDevicePriority(). Priority values can range from KHWRMHapticsMinDevicePriority to KHWRMHapticsMaxDevicePriority. GetDeviceProperty() returns a value inside TInt& aDevicePropertyValue in the range of KHWRMHapticsMinDevicePriority to KHWRMHapticsMaxDevicePriority. If the client has not set the EHWRMHapticsPriority property GetDeviceProperty() returns a value of DefaultDevicePriority(). | |
EHWRMHapticsDisableEffects |
Property used to disable effects for the client's haptics instance. Use TBool overloaded version of the methods SetDeviceProperty() and GetDeviceProperty() to use this property. When this property is set to true, any playing effects are immediately stopped and subsequent requests to play effects are ignored. Applies to the calling client's haptics instance only. When this property is set to false, subsequent requests to play effects are honored. The default value for this property is false. | |
EHWRMHapticsStrength |
A property that reduces/increases the magnitude of all effects for a particular haptics instance. Use TInt overloaded version of the methods SetDeviceProperty()and GetDeviceProperty() to use this property. Strength values can vary from KHWRMHapticsMinStrength ("mute") to KHWRMHapticsMaxStrength. The default value for EHWRMHapticsStrength is KHWRMHapticsMaxStrength. If the EHWRMHapticsStrength property is not set, the default value is used. When reducing/increasing the magnitude of the effects by setting the EHWRMHapticsStrength property, it only applies to the haptics instance of the client which called the function. If there is a second haptics instance held by the same or a different client, it is not affected by the setting of the EHWRMHapticsStrength property of the first client's haptics instance. Modifying the EHWRMHapticsStrength property of the haptics instance does not affect currently playing effects, only effects played or modified after calling the SetDeviceProperty() method using the new EHWRMHapticsStrength value. | |
EHWRMHapticsMasterStrength |
A property that reduces/increases the magnitude of all effects for all haptics instances (whole device). Use TInt overloaded version of the methods SetDeviceProperty()and GetDeviceProperty() to use this property. Strength values can vary from KHWRMHapticsMinStrength ("mute") to KHWRMHapticsMaxStrength. The default value for Master Strength is KHWRMHapticsMaxStrength. If the client does not set the EHWRMHapticsMasterStrength property of the haptics instance, the default value is used. When reducing/increasing the magnitude of the effects, EHWRMHapticsMasterStrength property affects all playing effects on all haptics instances (whole device). This means that all the haptics instances, held by other clients are affected by the setting of EHWRMHapticsMasterStrength property of the first client's haptics instance. The client which wants to set the EHWRMHapticsMasterStrength property must have a haptics instance that has a maximum effect priority. The haptics client instance must set itself to a maximum priority by calling SetDeviceProperty() using EHWRMHapticsPriority property type and KMaxDevicePriority value before changing the EHWRMHapticsMasterStrength property's value. Note: A licensee license key, provided to licensees only, changes the EHWRMHapticsMasterStrength property. A call to SetDeviceProperty( EHWRMHapticsMasterStrength, aValue ) always returns KErrAccessDenied for haptics instances that are not using a licensee license key. |
Effect styles
Used to specify Periodic or MagSweep effect style when calling PlayMagSweepEffect(), PlayPeriodicEffect(), ModifyPlayingMagSweepEffect() and ModifyPlayingPeriodicEffect().
Bitmask for supported effect styles.
To be used to analyze the value returned by GetDeviceCapability().
Bitmask for effect support.
To be used to analyze value returned by GetDeviceCapability().
Creates a streaming effect.
Client calls CreateStreamingEffect() to create a new streaming effect and gets a new handle for it; it should use that effect handle to play a streaming sample by calling PlayStreamingSample().
Parameter | Description |
---|---|
aEffectHandle | Reference to the variable that receives a handle to the streaming effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | DefaultDevicePriority | ( | ) | const [pure virtual] |
Gets the default device priority. Method may be used only after an actuator has been opened successfully.
Returns: TInt Default device property. KErrNotReady, if an actuator has not been opened.
TInt | DeleteAllEffectData | ( | ) | [pure virtual] |
Delete all loaded effect datas.
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Destroys a streaming effect previously created in a successful call to CreateStreamingEffect().
Parameter | Description |
---|---|
aEffectHandle | Handle to the streaming effect to destroy. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Parameter | Description |
---|---|
aDeviceCapabilityType | Capability type of the capability to get. |
aDeviceCapabilityValue | Reference to the variable that receives the requested capability value of the device. |
Returns: TInt KErrNone if successful, KErrNotReady if no actuator has been opened, otherwise one of the other system-wide error codes.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns: TInt KErrNone if successful, KErrNotReady if no actuator has been opened, KErrArgument if the length of the given string is less than MaxCapabilityStringLength(), otherwise one of the other system-wide error codes.
Gets a property value of the haptics.
See also: THWRMHapticsDevicePropertyTypes for a list of the valid property types.
Parameter | Description |
---|---|
aDevicePropertyType | Property type for the property to get. |
aDevicePropertyValue | Reference to the variable that receives the requested property value of the device. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns: KErrNone if successful, KErrArgument if the length of the given string is less than MaxPropertyStringLength(), otherwise one of the other system-wide error codes.
Get a number of effects defined in a loaded effect data buffer.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aCount | Number of effects in the effect data buffer. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | GetEffectDuration | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
TInt & | aEffectDuration | |||
) | const [pure virtual] |
Get the duration of an effect defined in a loaded effect data buffer.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aEffectIndex | Effect for which the duration is wanted. |
aEffectDuration | Reference to the variable that receives the requested effect's duration value. Duration is in milliseconds. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | GetEffectIndexFromName | ( | TInt | aFileHandle, |
const TDesC8 & | aEffectName, | |||
TInt & | aEffectIndex | |||
) | const [pure virtual] |
Gets the index of an effect defined in a loaded effect data buffer from the name of the effect.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aEffectName | Name of the effect for which the index is wanted. |
aEffectIndex | Reference to the variable that receives the requested effect's index value. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Gets the name of an effect defined in a loaded effect data buffer.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aEffectIndex | Index of an effect for which a name is wanted. |
aEffectName | Reference to the variable that receives the requested effect's name. Note that the descriptor's size must be at least the size given from MaxPropertyStringLength(). |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Retrieves the status of an effect (playing, not playing, paused).
See also: THWRMHapticsEffectStates for a list of valid effect states.
Parameter | Description |
---|---|
aEffectHandle | Handle to the effect which must have been obtained by calling PlayMagSweepEffect(), PlayPeriodicEffect(), PlayEffect(), PlayEffectRepeat() or CreateStreamingEffect() |
aEffectState | Pointer to the variable that receives the status bits of the effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Gets the type of an effect defined in loaded effect data buffer.
Parameter | Description |
---|---|
aFileHandle | Handle to loaded effect data buffer. |
aEffectIndex | Index of an effect for which a type is wanted. |
aEffectType | Reference to the variable that receives the requested effect's type value. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | GetMagSweepEffectDefinition | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
CHWRMHaptics::THWRMHapticsMagSweepEffect & | aEffect | |||
) | const [pure virtual] |
Gets the parameters of a MagSweep effect defined in a loaded effect data buffer.
See also: THWRMHapticsMagSweepEffect for effect definition.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aEffectIndex | Index of an effect for which a definition is wanted. |
aEffect | Reference to the variable that receives the effect definition. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | GetPeriodicEffectDefinition | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
CHWRMHaptics::THWRMHapticsPeriodicEffect & | aEffect | |||
) | const [pure virtual] |
Gets the parameters of a periodic effect defined in a loaded effect data buffer.
See also: THWRMHapticsPeriodicEffect for effect definition.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data buffer. |
aEffectIndex | Index of an effect for which a definition is wanted. |
aEffect | Reference to the variable that receives the effect definition. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
MHWRMHapticsObserver::THWRMHapticsStatus | HapticsStatus | ( | ) | const [pure virtual] |
This method retrieves the current haptics status.
See also: THWRMHapticsStatus
Returns: THWRMHapticsStatus indicating the current haptics status
TInt | InfiniteDuration | ( | ) | const [pure virtual] |
Gets the value that represents infinite duration. Method may be used only after an actuator has been opened successfully.
Returns: TInt Value that represents infinite duration. KErrNotReady, if an actuator has not been opened.
TInt | InfiniteRepeat | ( | ) | const [pure virtual] |
Gets the value that represents infinite repeats. Method may be used only after an actuator has been opened successfully.
Returns: TInt Value that represents infinite repeats. KErrNotReady, if an actuator has not been opened.
Load effect data defined in effect data buffer (obtained e.g. from a file containing the effect data).
Parameter | Description |
---|---|
aData | Reference to allocated effect data buffer. |
aFileHandle | On return contains a handle to the passed effect data. This handle is haptics specific, i.e., it is not a file system handle but just a handle to the loaded effect data buffer. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrArgument if the effect data is invalid.
TInt | MaxCapabilityStringLength | ( | ) | const [pure virtual] |
Gets the maximum capability string length. Method may be used only after an actuator has been opened successfully.
Returns: TInt Maximum capability string length. KErrNotReady, if an actuator has not been opened.
TInt | MaxDeviceNameLength | ( | ) | const [pure virtual] |
Gets the maximum device name length. Method may be used only after an actuator has been opened successfully.
Returns: TInt Maximum device name length. KErrNotReady, if an actuator has not been opened.
TInt | MaxEffectNameLength | ( | ) | const [pure virtual] |
Gets the maximum length of an effect name stored in a loaded effect data file. Method may be used only after an actuator has been opened successfully.
Returns: TInt Maximum effect name length. KErrNotReady, if an actuator has not been opened.
TInt | MaxPropertyStringLength | ( | ) | const [pure virtual] |
Gets the maximum property string length. Method may be used only after an actuator has been opened successfully.
Returns: TInt Maximum property string length. KErrNotReady, if an actuator has not been opened.
TInt | MaxStreamingSampleSize | ( | ) | const [pure virtual] |
Gets the maximum streaming sample size. Method may be used only after an actuator has been opened successfully.
Returns: TInt Maximum streaming sample size. KErrNotReady, if an actuator has not been opened.
TInt | ModifyPlayingMagSweepEffect | ( | TInt | aEffectHandle, |
const CHWRMHaptics::THWRMHapticsMagSweepEffect & | aEffect | |||
) | [pure virtual] |
Modifies a playing MagSweep effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
See also: THWRMHapticsMagSweepEffect for effect definition.
Parameter | Description |
---|---|
aEffectHandle | Handle to the playing MagSweep effect to modify. The handle to the effect must have been obtained by calling PlayMagSweepEffect(), PlayEffect() or PlayEffectRepeat(). |
aEffect | Reference to a struct defining the effect parameters. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
void | ModifyPlayingMagSweepEffect | ( | TInt | aEffectHandle, |
const CHWRMHaptics::THWRMHapticsMagSweepEffect & | aEffect, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, otherwise one of the other system-wide error codes. |
TInt | ModifyPlayingPeriodicEffect | ( | TInt | aEffectHandle, |
const CHWRMHaptics::THWRMHapticsPeriodicEffect & | aEffect | |||
) | [pure virtual] |
Modifies a playing periodic effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
See also: THWRMHapticsPeriodicEffect for effect definition.
Parameter | Description |
---|---|
aEffectHandle | Handle to the playing periodic effect to modify. The handle to the effect must have been obtained by calling PlayPeriodicEffect(), PlayEffect() or PlayEffectRepeat(). |
aEffect | Reference to a struct defining the effect parameters. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
void | ModifyPlayingPeriodicEffect | ( | TInt | aEffectHandle, |
const CHWRMHaptics::THWRMHapticsPeriodicEffect & | aEffect, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, otherwise one of the other system-wide error codes. |
IMPORT_C CHWRMHaptics * | NewL | ( | MHWRMHapticsObserver * | aHapticsCallback, |
MHWRMHapticsActuatorObserver * | aActuatorCallback | |||
) | [static] |
Two-phased constructor. Use this method for creating a haptics instance with callbacks.
Parameter | Description |
---|---|
aHapticsCallback | Pointer to callback instance. Can be NULL. |
aActuatorCallback | Pointer to callback instance. Can be NULL. |
Returns: A pointer to a new instance of the CHWRMHaptics class.
IMPORT_C CHWRMHaptics * | NewL | ( | MHWRMHapticsObserver * | aHapticsCallback, |
MHWRMHapticsActuatorObserver * | aActuatorCallback, | |||
TRequestStatus & | aStatus | |||
) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, otherwise one of the other system-wide error codes. |
void | OpenActuatorL | ( | THWRMLogicalActuators | aActuator | ) | [pure virtual] |
Method for opening a logical actuator for use.
This method must be called before using any other methods of this class, except when using GetXXX methods. The Haptics API supports a limited number of instances of CHWRMHaptics class. If all instances are currently in use, the next attempt to call OpenActuatorL() from any client fails. Applications should not use more instances than necessary as this may prevent other applications from instantiating the CHWRMHaptics class.
See also: THWRMLogicalActuators for a list of usable actuators.
Parameter | Description |
---|---|
aActuator | Enumeration of the type of logical actuator the client wants to use. |
Pauses a playing effect.
Parameter | Description |
---|---|
aEffectHandle | Handle to the playing effect to pause. The handle to the effect must have been obtained by calling PlayMagSweepEffect(), PlayPeriodicEffect() , PlayEffect() , PlayEffectRepeat() or CreateStreamingEffect(). |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Plays an effect defined in loaded effect data buffer.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data. |
aEffectIndex | Index of the effect to play. The index of the effect must be greater than or equal to 0 and less than the number of effects returned by GetEffectCount(). |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayEffect | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
Plays an effect defined in effect data buffer.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aData | Reference to effect data buffer containing the definition of the effect to play. |
aEffectIndex | Index of the effect to play. The index of the effect must be greater than or equal to 0 and less than the number of effects returned by GetEffectCount(). |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrArgument if the data is invalid. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayEffect | ( | const TDesC8 & | aData, |
TInt | aEffectIndex, | |||
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrArgument, if the data is invalid, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
TInt | PlayEffectRepeat | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
TUint8 | aRepeat, | |||
TInt & | aEffectHandle | |||
) | [pure virtual] |
Repeatedly plays a Timeline effect defined in loaded effect data buffer.
The current implementation of PlayEffectRepeat() repeats only Timeline effects. If the given effect index refers to a simple effect, PlayEffectRepeat() ignores the aRepeat parameter and plays the simple effect once. In that case, PlayEffectRepeat() behaves like PlayEffect(). PlayEffectRepeat() does not return a warning when requested to repeat a simple effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aFileHandle | Handle to the loaded effect data. |
aEffectIndex | Index of the effect to play. The index of the effect must be greater than or equal to 0 and less than the number of effects returned by GetEffectCount(). |
aRepeat | Number of times to repeat the effect. To play the effect indefinitely, set aRepeat to InfiniteRepeat(). To repeat the effect a finite number of times, set aRepeat to a value from 0 to InfiniteRepeat() - 1. The effect can be repeated at most InfiniteRepeat() - 1 times. Setting aRepeat to 0 plays the effect once (repeats the effect zero times) and is equivalent to calling PlayEffect(). To stop the effect before it has repeated the requested number of times or to stop an effect that is playing indefinitely, call StopPlayingEffect() or StopAllPlayingEffects() |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayEffectRepeat | ( | TInt | aFileHandle, |
TInt | aEffectIndex, | |||
TUint8 | aRepeat, | |||
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
TInt | PlayEffectRepeat | ( | const TDesC8 & | aData, |
TInt | aEffectIndex, | |||
TUint8 | aRepeat, | |||
TInt & | aEffectHandle | |||
) | [pure virtual] |
Repeatedly plays a Timeline effect defined in effect data buffer.
The current implementation of PlayEffectRepeat() repeats only Timeline effects. If the given effect index refers to a simple effect, PlayEffectRepeat() ignores the aRepeat parameter and plays the simple effect once. In that case, PlayEffectRepeat() behaves similarly to PlayEffect(). PlayEffectRepeat() does not return a warning when requested to repeat a simple effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aData | Reference to effect data buffer containing the definition of the effect to play. |
aEffectIndex | Index of the effect to play. The index of the effect must be greater than or equal to 0 and less than the number of effects returned by GetEffectCount(). |
aRepeat | Number of times to repeat the effect. To play the effect indefinitely, set aRepeat to InfiniteRepeat(). To repeat the effect a finite number of times, set aRepeat to a value from 0 to InfiniteRepeat() - 1. The effect can be repeated at most InfiniteRepeat() - 1 times. Setting aRepeat to 0 plays the effect once (repeats the effect zero times) and is equivalent to calling PlayEffect(). To stop the effect before it has repeated the requested number of times or to stop an effect that is playing indefinitely, call StopPlayingEffect() or StopAllPlayingEffects() |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrArgument if the data is invalid. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayEffectRepeat | ( | const TDesC8 & | aData, |
TInt | aEffectIndex, | |||
TUint8 | aRepeat, | |||
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrArgument, if the data is invalid, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
TInt | PlayMagSweepEffect | ( | const CHWRMHaptics::THWRMHapticsMagSweepEffect & | aEffect, |
TInt & | aEffectHandle | |||
) | [pure virtual] |
Plays a MagSweep effect given in the parameters defining the effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
See also: THWRMHapticsMagSweepEffect for effect definition.
Parameter | Description |
---|---|
aEffect | Reference to a struct defining the effect parameters. |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayMagSweepEffect | ( | const CHWRMHaptics::THWRMHapticsMagSweepEffect & | aEffect, |
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
TInt | PlayPeriodicEffect | ( | const CHWRMHaptics::THWRMHapticsPeriodicEffect & | aEffect, |
TInt & | aEffectHandle | |||
) | [pure virtual] |
Plays a Periodic effect given in the parameters defining the effect.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
See also: THWRMHapticsPeriodicEffect for effect definition.
Parameter | Description |
---|---|
aEffect | Reference to a struct defining the effect parameters. |
aEffectHandle | Reference to the variable that receives a handle to the playing effect. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayPeriodicEffect | ( | const CHWRMHaptics::THWRMHapticsPeriodicEffect & | aEffect, |
TInt & | aEffectHandle, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
Plays a streaming sample given in the parameter defining the effect.
Streaming sample can only be played after calling CreateStreamingEffect() and by using the effecthandle it returns.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aEffectHandle | Handle to the streaming effect to play. |
aStreamingSample | Reference to streaming sample data containing the definition of the effect to play. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayStreamingSample | ( | TInt | aEffectHandle, |
const TDesC8 & | aStreamingSample, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
TInt | PlayStreamingSampleWithOffset | ( | TInt | aEffectHandle, |
const TDesC8 & | aStreamingSample, | |||
TInt | aOffsetTime | |||
) | [pure virtual] |
Plays a streaming sample with a time offset given in the parameters defining the effect.
Client calls CreateStreamingEffect() to create a new streaming effect and gets a new handle for it; it should use that effect handle to play the streaming sample with this method.
Synchronous method returns when the haptic command has been evaluated and the return value is valid.
Parameter | Description |
---|---|
aEffectHandle | Handle to the streaming effect to play. |
aStreamingSample | Reference to streaming sample data containing the definition of the effect to play. |
aOffsetTime | For aOffsetTime values that are greater than 0, playback is delayed for aOffsetTime in milliseconds. For aOffsetTime values that are less than 0, sample playback begins in offset time in milliseconds into the current sample. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes. TInt KErrInUse when haptics is reserved for a higher or equal priority client.
void | PlayStreamingSampleWithOffset | ( | TInt | aEffectHandle, |
const TDesC8 & | aStreamingSample, | |||
TInt | aOffsetTime, | |||
TRequestStatus & | aStatus | |||
) | [pure virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameter | Description |
---|---|
aStatus | Request status. On completion contains: KErrNone, if successful, KErrInUse when haptics is reserved for a higher or equal priority client, otherwise one of the other system-wide error codes. |
void | ReleaseHaptics | ( | ) | [pure virtual] |
Releases haptics feature if it was previously reserved for this client.
If this client has not reserved haptics feature, does nothing. If haptics is on when it is released and no other client has a suspended reservation, haptics is stopped.
void | ReserveHapticsL | ( | ) | [pure virtual] |
Reserves haptics feature exclusively for this client. A higher priority client may cause lower priority client reservation to be temporarily suspended. The suspended client does not get any notification about suspension. If haptics is already reserved by a higher or equal priority client, reserving still succeeds, but reservation is immediately suspended. When the reservation is suspended, playing effects do not actually cause the effects to be played. Note: Unless the client has instantiated the Haptics API with the status observer, it does not receive any notifications about the fact that its effects are not actually played by the physical player when the client has been suspended by a higher priority reservation. Note also that even if haptics is reserved by some client, a higher priority client succeeds in playing its effects.
Calling this method is equal to call ReserveHapticsL(EFalse), i.e. foreground status is always used to control further reservations. However, this is a future feature, and not implemented in current version.
void | ReserveHapticsL | ( | TBool | aForceNoCCoeEnv | ) | [pure virtual] |
Reserves haptics feature exclusively for this client. A higher priority client may cause lower priority client reservation to be temporarily suspended. The suspended client does not get any notifications about suspension. If haptics is already reserved by a higher or equal priority client, reserving still succeeds, but reservation is immediately suspended. When the reservation is suspended, playing effects does not actually cause the effects to be played. Note: Unless the client has instantiated the Haptics API with the status observer, it does not receive any notifications about the fact that its effects are not actually played by the physical player when the client has been suspended by a higher priority reservation. Note also that even if haptics is reserved by some client, a higher priority client succeeds in playing its effects.
Parameter | Description |
---|---|
aForceNoCCoeEnv | (Note: This is a future feature, and not implemented in current version. You can think of it ETrue always.) If EFalse, then reservation requires that this client has the keyboard focus at the time of reservation and haptics is automatically released and re-reserved based on the keyboard focus status of this client. This also implies that CCoeEnv::Static() != NULL is required. If ETrue, the client does not require CCoeEnv to be present nor does it automatically reserve or release haptics by depending on the foreground or background status of the client. Only trusted clients are allowed to set this flag to ETrue. The client application is considered trusted if it has a priority defined in haptics policy file. The policy files can be modified by S60 licensees. |
Resumes playback on a paused effect from the point where the effect was paused.
Depending on the available slots, it is possible that all simple effects from a paused effect data buffer or streaming sample cannot be resumed. The API returns success when it is able to play one of these simple effects.
Parameter | Description |
---|---|
aEffectHandle | Handle to the paused effect to resume. The handle to the effect must have been obtained by calling PlayMagSweepEffect(), PlayPeriodicEffect(), PlayEffect(), PlayEffectRepeat() or CreateStreamingEffect(). |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Sets a property of the haptics.
Some properties affect all haptics instances, some only the current instance of the haptics. More about that can be found in THWRMHapticsDevicePropertyTypes.
See also: THWRMHapticsDevicePropertyTypes for a list of valid property types
Parameter | Description |
---|---|
aDevicePropertyType | Property type for the property to be set. |
aDevicePropertyValue | Value of the property to set. |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
TInt | StopAllPlayingEffects | ( | ) | [pure virtual] |
Stops all playing and paused effects of a haptics instance.
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Stops a playing effect.
Parameter | Description |
---|---|
aEffectHandle | Handle to the playing effect to stop. The handle to the effect must have been obtained by calling PlayMagSweepEffect(), PlayPeriodicEffect(), PlayEffect(), PlayEffectRepeat() or CreateStreamingEffect(). |
Returns: TInt KErrNone if successful, otherwise one of the other system-wide error codes.
Method for getting a bitmask value of supported logical actuators.
Developer needs to evaluate the returned bitmask against THWRMLogicalActuators enumeration values to know the supported logical actuators.
See also: THWRMLogicalActuators for a list of usable actuators.
Parameter | Description |
---|---|
aActuators | Bitmask of supported logical actuators. |
Returns: TInt KErrNone, if successful, otherwise one of the other system-wide error codes.