epoc32/include/mw/touchfeedback.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * 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
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Interface for using area registry and direct feedback from
    14 * Description:  Interface for using area registry and direct feedback from
    15 *                applications and UI controls.
    15 *                applications and UI controls.
       
    16 * Part of:      Tactile Feedback.
    16 *
    17 *
    17 */
    18 */
    18 
    19 
    19 
    20 
    20 
    21 
    24 #include <e32std.h>
    25 #include <e32std.h>
    25 #include <e32base.h>
    26 #include <e32base.h>
    26 #include <coemain.h>
    27 #include <coemain.h>
    27 
    28 
    28 #include <touchlogicalfeedback.h>
    29 #include <touchlogicalfeedback.h>
       
    30 #include <touchfeedbackspec.h>
    29 
    31 
    30 class CCoeControl;
    32 class CCoeControl;
    31 
       
    32 
    33 
    33 /**
    34 /**
    34  *  This is the Tactile Feedback interface for UI Controls.
    35  *  This is the Tactile Feedback interface for UI Controls.
    35  *
    36  *
    36  *  Provides an interface to add, modify and remove feedback areas
    37  *  Provides an interface to add, modify and remove feedback areas
   309      * do nothing.
   310      * do nothing.
   310      *
   311      *
   311      * If given control pointer is NULL, then this function call
   312      * If given control pointer is NULL, then this function call
   312      * is ignored.
   313      * is ignored.
   313      *
   314      *
       
   315      * This function only changes feedback type for down event.
       
   316      * To change feedback types for all the events in the feedback area use
       
   317      * function SetFeedbackArea with CFeedbackSpec container class 
       
   318      * definion instead.
       
   319      *
   314      * @since S60 5.0
   320      * @since S60 5.0
   315      * @param aControl - The control, who has registered the area.
   321      * @param aControl - The control, who has registered the area.
   316      * @param aIndex   - The index number of the area, that will be changed.
   322      * @param aIndex   - The index number of the area, that will be changed.
   317      * @param aNewType - New feedback type for the area.
   323      * @param aNewType - New feedback type for the area.
   318      */
   324      */
   394      * If feedback is enabled for the given control, then this function 
   400      * If feedback is enabled for the given control, then this function 
   395      * causes a synchronous client-server transaction, 
   401      * causes a synchronous client-server transaction, 
   396      * and potentially flushing of window server client-side buffer.
   402      * and potentially flushing of window server client-side buffer.
   397      *
   403      *
   398      * @since S60 5.0
   404      * @since S60 5.0
   399      * @param aControl - The control, who fishes to play feedback.
   405      * @param aControl - The control, who wishes to play feedback.
   400      * @param aType    - The logical feedback type to play.
   406      * @param aType    - The logical feedback type to play.
   401      */
   407      */
   402     virtual void InstantFeedback( const CCoeControl* aControl,
   408     virtual void InstantFeedback( const CCoeControl* aControl,
   403                                   TTouchLogicalFeedback aType ) = 0;
   409                                   TTouchLogicalFeedback aType ) = 0;
   404                                   
   410                                   
   496     virtual void EnableFeedbackForControl( const CCoeControl* aControl,
   502     virtual void EnableFeedbackForControl( const CCoeControl* aControl,
   497                                            TBool aEnableVibra,
   503                                            TBool aEnableVibra,
   498                                            TBool aEnableAudio ) = 0; 
   504                                            TBool aEnableAudio ) = 0; 
   499                                            
   505                                            
   500     /**
   506     /**
   501      * Used for disabling or enabling feedback in the application.
   507      * Used for disabling/enabling audio/vibra feedback in
       
   508      * the application.
   502      *
   509      *
   503      * This is identical with the overload which has only one parameter, 
   510      * This is identical with the overload which has only one parameter, 
   504      * with the exception that one can disable audio and vibra feedback 
   511      * with the exception that one can disable audio and vibra feedback 
   505      * separately with this version.
   512      * separately with this version.
   506      *
   513      *
   511      * @param aAudioEnabled - Give ETrue as parameter for enabling audio 
   518      * @param aAudioEnabled - Give ETrue as parameter for enabling audio 
   512      *                        feedback, and EFalse for disabling audio
   519      *                        feedback, and EFalse for disabling audio
   513      *                        feedback for this application.
   520      *                        feedback for this application.
   514      */
   521      */
   515     virtual void SetFeedbackEnabledForThisApp( TBool aVibraEnabled,
   522     virtual void SetFeedbackEnabledForThisApp( TBool aVibraEnabled,
   516                                                TBool aAudioEnabled ) = 0;                                                 
   523                                                TBool aAudioEnabled ) = 0;
       
   524 
       
   525 
       
   526     /**
       
   527      * Used to check whether audio or vibra feedback is enabled for this application.
       
   528      *
       
   529      * Notice that this function only returns what was given as parameter
       
   530      * to SetFeedbackEnabledForThisApp -function. I.e. this function
       
   531      * can return ETrue even if  feedback would be currently disabled
       
   532      * from settings.
       
   533      *
       
   534      * @since S60 5.2
       
   535      * @param aFeedbackType - Feedback type.
       
   536      * @return ETrue if asked feedback type is enabled for this application.
       
   537      */
       
   538     virtual TBool FeedbackEnabledForThisApp( TTouchFeedbackType aFeedbackType ) = 0;
       
   539     
       
   540     /**
       
   541      * Starts continuous feedback if given control has not disabled it.
       
   542      *
       
   543      * Only one continuous feedback per control can be played simultaneously.
       
   544      * Started feedback will be stopped automatically if application loses 
       
   545      * key focus or application crashes or some other control starts
       
   546      * continuous feedback.     
       
   547      * 
       
   548      * If StartFeedback is called again for the same control, then feedback
       
   549      * type and intensity are modified accordingly. This may cause a break
       
   550      * in the feedback effect in case feedback type changes.          
       
   551      *
       
   552      * EnableFeedbackForControl also affects to this function so that
       
   553      * feedback is not given if EnableFeedbackForControl
       
   554      * function has been called with second and third parameter EFalse.
       
   555      * 
       
   556      * @since S60 5.2
       
   557      * @param aControl      - The control, who wishes to play feedback.
       
   558      * @param aType         - The continuous feedback type to play.
       
   559      * @param aPointerEvent - Pointer event which triggered this feedback
       
   560      *                        (give NULL as parameter if no related pointer
       
   561      *                         event available)     
       
   562      * @param aIntensity    - Feedback intensity to begin with. range 0-100%. 
       
   563      *                        Use 50% if no reason to use other value.     
       
   564      * @param aTimeout      - Timeout value to automatically stop continuous 
       
   565      *                        feedback if there's no new Start call within the
       
   566      *                        timeout. Use value 0 if timeout is not used.
       
   567      */
       
   568     virtual void StartFeedback( const CCoeControl* aControl,
       
   569                                 TTouchContinuousFeedback aType,
       
   570                                 const TPointerEvent* aPointerEvent,
       
   571                                 TInt aIntensity,
       
   572                                 TTimeIntervalMicroSeconds32 aTimeout ) = 0;
       
   573 
       
   574                                 
       
   575     /**
       
   576      * This function modifies intensity of continuous feedback on the fly.
       
   577      *
       
   578      * @since S60 5.2
       
   579      * @param aControl      - The control which continuous feedback is modified.
       
   580      * @param aIntensity    - New intensity value. range 0-100%
       
   581      */
       
   582     virtual void ModifyFeedback( const CCoeControl* aControl,
       
   583                                  TInt aIntensity ) = 0;
       
   584 
       
   585                                  
       
   586     /**
       
   587      * This function stops continuous feedback.
       
   588      *
       
   589      * @since S60 5.2
       
   590      * @param aControl - The control which continuous feedback is stopped.
       
   591      */
       
   592     virtual void StopFeedback( const CCoeControl* aControl ) = 0;
       
   593 
       
   594 
       
   595     /**
       
   596      * This function enables or disables audio or/and vibra feedback in
       
   597      * whole device.
       
   598      * 
       
   599      * Tactile feedback is enabled by default, and thus standard 
       
   600      * S60 components (such as CBA, lists and options menu) automatically 
       
   601      * give feedback even if the application itself would make no effort 
       
   602      * for producing feedback.
       
   603      *
       
   604      * Requires WriteDeviceData capability
       
   605      *
       
   606      * @since S60 5.2
       
   607      * @param aFeedbackType - Feedback types to be enabled/disabled defined as
       
   608      *                        a bitmask combination of enumeration items from
       
   609      *                        TTouchFeedbackType
       
   610      * @return KErrNone, or one of standard Symbian OS error codes
       
   611      *         if user has not WriteDeviceData capability. 
       
   612      */
       
   613     virtual TInt SetFeedbackEnabledForDevice( TTouchFeedbackType aFeedbackType ) = 0;
       
   614 
       
   615 
       
   616     /**
       
   617      * Used to check enabled feedback types for the device.
       
   618      *
       
   619      * Notice that this function only returns what was given as parameter
       
   620      * to SetFeedbackEnabledForDevice -function. I.e. this function
       
   621      * can return ETrue even if  feedback would be currently disabled
       
   622      * from settings.
       
   623      *
       
   624      * @since S60 5.2
       
   625      * @return Enabled/disabled feedback types as bitmask combination.
       
   626      */
       
   627     virtual TTouchFeedbackType FeedbackEnabledForDevice() = 0;
       
   628 
       
   629 
       
   630     /**
       
   631      * Gives direct feedback if given control has not disabled it.
       
   632      *
       
   633      * This overload is recommended when triggered feedback is related
       
   634      * to pointer event. System uses aPointerEvent to avoiding
       
   635      * two (or more) direct feedbacks for the same pointer event.
       
   636      *
       
   637      * @since S60 5.2
       
   638      * @param aControl      - The control, who wishes to play feedback.
       
   639      * @param aType         - The logical feedback type to play.
       
   640      * @param aPointerEvent - pointer event which triggered this feedback.
       
   641      */
       
   642     virtual void InstantFeedback( const CCoeControl* aControl,
       
   643                                   TTouchLogicalFeedback aType,
       
   644                                   const TPointerEvent& aPointerEvent ) = 0;
       
   645 
       
   646 
       
   647     /**
       
   648      * Sets or updates rectangular feedback area to registry.
       
   649      *
       
   650      * This overload allows user to set more than one touch event types to
       
   651      * one feedback area. Otherwise the function behaves in the same way
       
   652      * as the overload with separated feedback type and event type parameters.
       
   653      *
       
   654      * @since S60 5.2
       
   655      * @param aControl        - The control handling pointer events on this
       
   656      *                          feedback area.
       
   657      * @param aIndex          - The index number of the area to be added.
       
   658      * @param aRect           - The feedback area rectangle.
       
   659      * @param aFeedbackSpec   - The specification how this feedback area 
       
   660      *                          triggers feedback for different touch events.     
       
   661      * @return KErrNone, or one of standard Symbian OS error codes
       
   662      *         if setting of area to registry failed. 
       
   663      *         Some specific error codes:
       
   664      *         KErrArgument - A NULL pointer was given as first parameter, or
       
   665      *                        the given control does not have any window
       
   666      *                        associated to it.
       
   667      *         KErrNotSupported - Unsupported predefined feedback profile
       
   668      *                            was given as parameter.
       
   669      */
       
   670     virtual TInt SetFeedbackArea( const CCoeControl* aControl, 
       
   671                                   TUint32 aIndex,
       
   672                                   TRect aRect, 
       
   673                                   CFeedbackSpec* aFeedbackSpec ) = 0;
       
   674 
       
   675     /**
       
   676      * Gives direct feedback if given control has not disabled it.
       
   677      *
       
   678      * This overload is recommended when triggered feedback is related
       
   679      * to pointer event. System uses aPointerEvent to avoiding
       
   680      * two (or more) direct feedbacks for the same pointer event. Using this 
       
   681      * overload it is also possible to disable unwanted feedback (vibra/audio)
       
   682      * by giving only wanted feedback type as parameter.
       
   683      *
       
   684      * @since S60 5.2
       
   685      * @param aControl      - The control, who wishes to play feedback.
       
   686      * @param aType         - The logical feedback type to play.
       
   687      * @param aFeedbackType - Feedback types to be played as a bitmask 
       
   688      *                        combination of enumeration items from
       
   689      *                        TTouchFeedbackType
       
   690      * @param aPointerEvent - Pointer event, which triggered this feedback.
       
   691      */
       
   692     virtual void InstantFeedback( const CCoeControl* aControl,
       
   693                                   TTouchLogicalFeedback aType,
       
   694                                   TTouchFeedbackType aFeedbackType,
       
   695                                   const TPointerEvent& aPointerEvent ) = 0;
       
   696 
       
   697 
       
   698 
   517     };
   699     };
   518 
   700 
   519 
   701 
   520 
   702 
   521 #endif //  M_TOUCHFEEDBACK_H
   703 #endif //  M_TOUCHFEEDBACK_H