akntouchgesturefw/inc/akntouchgesturefwrecognitionengine.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Touch gesture recognition engine.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_AKNTOUCHGESTUREFWRECOGNITIONENGINE_H
       
    19 #define C_AKNTOUCHGESTUREFWRECOGNITIONENGINE_H
       
    20 
       
    21 #include <akntouchgesturefwevents.h>
       
    22 #include <touchfeedback.h>
       
    23 
       
    24 #include "akntouchgesturefwutils.h"
       
    25 
       
    26 namespace AknTouchGestureFw {
       
    27 
       
    28 class MAknTouchGestureFwObserver;
       
    29 class CAknTouchGestureFwPointerState;
       
    30 class CAknTouchGestureFwBaseRecognizer;
       
    31 class CAknTouchGestureFwSettings;
       
    32 
       
    33 /**
       
    34  *  Touch gesture recognition engine.
       
    35  *
       
    36  *  @lib akntouchgesturefw
       
    37  *  @since S60 v5.2
       
    38  */
       
    39 NONSHARABLE_CLASS( CAknTouchGestureFwRecognitionEngine ) : public CBase
       
    40     {
       
    41 
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Two-phased constructor.
       
    46      *
       
    47      * @param  aObserver  Gesture observer to which the gesture events are
       
    48      *                    sent when a gesture is recognized.
       
    49      * @param  aControl   Control receiving the gesture pointer events.                    
       
    50      */
       
    51     static CAknTouchGestureFwRecognitionEngine* NewL(
       
    52             MAknTouchGestureFwObserver& aObserver,
       
    53             CCoeControl* aControl );
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      *
       
    58      * @param  aObserver  Gesture observer to which the gesture events are
       
    59      *                    sent when a gesture is recognized.
       
    60      * @param  aControl   Control receiving the gesture pointer events.                    
       
    61      */
       
    62     static CAknTouchGestureFwRecognitionEngine* NewLC(
       
    63             MAknTouchGestureFwObserver& aObserver,
       
    64             CCoeControl* aControl );
       
    65 
       
    66     /**
       
    67      * Destructor.
       
    68      */
       
    69     virtual ~CAknTouchGestureFwRecognitionEngine();
       
    70 
       
    71     /**
       
    72      * Notifies observer of a gesture.
       
    73      *
       
    74      * @param  aEvent  Gesture event.
       
    75      */
       
    76     void NotifyObserverL( MAknTouchGestureFwEvent& aEvent );
       
    77 
       
    78     /**
       
    79      * Sets client gesture interest.
       
    80      *
       
    81      * @param  aGestureGroups  New client gesture interest.
       
    82      */
       
    83     void SetGestureInterestL( TUint aGestureGroups );
       
    84 
       
    85     /**
       
    86      * Provides client gesture interest.
       
    87      *
       
    88      * @return Client gesture interest.
       
    89      */
       
    90     TUint GestureInterest() const;
       
    91 
       
    92     /**
       
    93      * Cancels all gesture recognition.
       
    94      */
       
    95     void CancelRecognizing();
       
    96 
       
    97     /**
       
    98      * Handles gesture control targeted pointer event received
       
    99      * from window server.
       
   100      *
       
   101      * @param  aPointerData  Pointer event related data.
       
   102      */
       
   103     void HandlePointerEventL( const TPointerEventData& aPointerData );
       
   104 
       
   105     /**
       
   106      * Returns a reference to the Central Repository settings provider.
       
   107      *
       
   108      * @return Settings provider.
       
   109      */
       
   110     CAknTouchGestureFwSettings& Settings() const;
       
   111 
       
   112     /**
       
   113      * Enables testing features.
       
   114      */ 
       
   115     void EnableTestingFeatures();
       
   116     
       
   117     /**
       
   118      * Gives immediate direct feedback.
       
   119      *
       
   120      * @param aLogicalFeedback - The logical feedback type to play.
       
   121      * @param aFeedbackType - Feedback types to be played as a bitmask 
       
   122      *                        combination of enumeration items from
       
   123      *                        TTouchFeedbackType.  
       
   124      */
       
   125     void ImmediateFeedback(
       
   126         TTouchLogicalFeedback aLogicalFeedback,
       
   127         TTouchFeedbackType aFeedbackType );
       
   128     
       
   129     /**
       
   130      * Starts continuous feedback.
       
   131      *
       
   132      * @param aType         - The continuous feedback type to play.
       
   133      * @param aIntensity    - Intensity of continuous feedback.
       
   134      * @param aTimeout      - Timeout value to automatically stop continuous 
       
   135      *                        feedback if there's no new Start call within the
       
   136      *                        timeout. Use value 0 if timeout is not used.
       
   137      */
       
   138     void StartContinuousFeedback(
       
   139         TTouchContinuousFeedback aContinuousFeedback,
       
   140         TInt aIntensity,
       
   141         TTimeIntervalMicroSeconds32 aTimeout );
       
   142          
       
   143     /**
       
   144      * Modifies continuous feedback.
       
   145      *
       
   146      * @param aIntensity     - New intensity value for feedback.
       
   147      */    
       
   148     void ModifyContinuousFeedback( TInt aIntensity );
       
   149     
       
   150     /**
       
   151      * Stops continuous feedback.
       
   152      */
       
   153     void StopContinuousFeedback();     
       
   154       
       
   155     /**
       
   156      * Defines gesture groups, which trigger tactile feedback automatically.
       
   157      *
       
   158      * @param aGestureGroups - Those gesture groups, which trigger tactile
       
   159      *                         feedback automatically as touch gestures
       
   160      *                         are recognized or being in the process
       
   161      *                         of recognizing.   
       
   162      */ 
       
   163     void SetFeedbackForGroupsL( TUint aGestureGroups );
       
   164 
       
   165     /**
       
   166      * Sets gesture types which generate tactile and audio feedback.
       
   167      * 
       
   168      * @param aGestureGroup - Gesture group, which tactile- and audio feedback
       
   169      *                        is affected by this function call.     
       
   170      * @param  aGestureTypesForTactile Gesture types with tactile feedback
       
   171      * @param  aGestureTypesForAudio   Gesture types with audio feedback
       
   172      */
       
   173     void SetFeedbackForTypesL(
       
   174         TAknTouchGestureFwGroup aGestureGroup,
       
   175         TUint aGestureTypesForTactile,
       
   176         TUint aGestureTypesForAudio );
       
   177     
       
   178 
       
   179 private:
       
   180 
       
   181     /**
       
   182      * C++ constructor.
       
   183      *
       
   184      * @param  aObserver  Gesture observer to which the gesture events are
       
   185      *                    sent when a gesture is recognized.
       
   186      * @param  aControl   Control receiving the gesture pointer events.
       
   187      */
       
   188     CAknTouchGestureFwRecognitionEngine(
       
   189             MAknTouchGestureFwObserver& aObserver,
       
   190             CCoeControl* aControl );
       
   191 
       
   192     /**
       
   193      * Symbian second-phase constructor.
       
   194      */
       
   195     void ConstructL();
       
   196 
       
   197     /**
       
   198      * Enables or disables the gesture recognizers on the recognizer array
       
   199      * based on the client's gesture interest.
       
   200      *
       
   201      * @param  aGestureInterest  Current gesture interest.
       
   202      */
       
   203     void UpdateRecognizersForInterest( TUint aGestureInterest );
       
   204 
       
   205     /**
       
   206      * Creates new gesture recognizer according to the gesture group.
       
   207      *
       
   208      * @param  aGroup   Gesture group.
       
   209      *
       
   210      * @return Pointer to the created recognizer.
       
   211      */
       
   212     CAknTouchGestureFwBaseRecognizer* CreateRecognizerL(
       
   213             TAknTouchGestureFwGroup aGroup );
       
   214     
       
   215     /**
       
   216      * returns existing gesture recognizer according to the gesture group.
       
   217      *
       
   218      * @param  aGroup   Gesture group.
       
   219      *
       
   220      * @return Pointer to the existing recognizer or NULL if not found.
       
   221      */
       
   222     CAknTouchGestureFwBaseRecognizer* Recognizer(
       
   223             TAknTouchGestureFwGroup aGroup );
       
   224 
       
   225     /**
       
   226      * Sends pointer event to recognizers.
       
   227      *
       
   228      * @param  aMultiPointer  @c ETrue if event is multi pointer event.
       
   229      * @param  aPointerData   Pointer event related data.
       
   230      */
       
   231     void SendPointerEventToRecognizersL(
       
   232             TBool aMultiPointer,
       
   233             const TPointerEventData& aPointerData );
       
   234 
       
   235 private: // data
       
   236 
       
   237     /**
       
   238      * Observer for gestures being deduced from pointer events.
       
   239      * Not own.
       
   240      */
       
   241     MAknTouchGestureFwObserver& iObserver;
       
   242 
       
   243     /**
       
   244      * Pointer state.
       
   245      * Own.
       
   246      */
       
   247     CAknTouchGestureFwPointerState* iPointerState;
       
   248 
       
   249     /**
       
   250      * CenRep settings provider.
       
   251      * Own.
       
   252      */
       
   253     CAknTouchGestureFwSettings* iSettings;
       
   254 
       
   255     /**
       
   256      * Flags determing which gesture groups should be recognized.
       
   257      */
       
   258     TUint iGestureInterest;
       
   259 
       
   260     /**
       
   261      * Boolean flag to indicate if single touch recognition is ongoing.
       
   262      */
       
   263     TBool iSingleRecognizing;
       
   264 
       
   265     /**
       
   266      * Boolean flag to indicate if multi touch recognition is ongoing.
       
   267      */
       
   268     TBool iMultiRecognizing;
       
   269 
       
   270     /**
       
   271      * Array for recognizers.
       
   272      */
       
   273     RPointerArray<CAknTouchGestureFwBaseRecognizer> iRecognizers;
       
   274 
       
   275     /**
       
   276      * ETrue if testing features are enabled.
       
   277      */
       
   278     TBool iTestingEnabled;
       
   279     
       
   280     /**
       
   281      * Subcriber control.
       
   282      * Not own.
       
   283      */
       
   284     CCoeControl* iControl;
       
   285     
       
   286     /**
       
   287      * Touch feedback instance.
       
   288      * Not own.
       
   289      */
       
   290     MTouchFeedback* iFeedBack;    
       
   291     
       
   292     };
       
   293 
       
   294 } // namespace AknTouchGestureFw
       
   295 
       
   296 #endif // C_AKNTOUCHGESTUREFWRECOGNITIONENGINE_H