htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/PointerEventHandler.h
branchRCL_3
changeset 20 48060abbbeaf
parent 19 d40e813b23c0
child 21 b3cee849fa46
equal deleted inserted replaced
19:d40e813b23c0 20:48060abbbeaf
     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:  Functional implentation of pointer event service.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CPOINTEREVENTHANDLER_H
       
    19 #define CPOINTEREVENTHANDLER_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <HtiServicePluginInterface.h>
       
    23 #include <w32std.h>
       
    24 #include "MultiTouchPointerEventHandler.h"
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // DATA TYPES
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 
       
    38 /**
       
    39 *  Functional implentation of pointer event service.
       
    40 */
       
    41 class CPointerEventHandler : 
       
    42 	public CActive,
       
    43 	public MHtiMultiTouchObserver
       
    44     {
       
    45     public:
       
    46 
       
    47         enum TError
       
    48             {
       
    49             EMissingCommand          = 0x01,
       
    50             EUnrecognizedCommand     = 0x02,
       
    51             ENotReadyCommand         = 0x03,
       
    52             EInvalidParameters       = 0x9A
       
    53             };
       
    54 
       
    55         enum TCommand
       
    56             {
       
    57             ETapScreen = 0x10,
       
    58             ETapAndDrag = 0x11,
       
    59             ETapAndDragMultipoint = 0x12,
       
    60             EPressPointerDown = 0x13,
       
    61             ELiftPointerUp = 0x14,
       
    62 			EAdvancedTapScreen = 0x15, //for advanced pointer
       
    63 			EPinchZoom = 0x16, //for advanced pointer
       
    64 			EMultiTouch = 0x17, //for advanced pointer
       
    65             EResultOk = 0xFF // only for response message
       
    66             };
       
    67 
       
    68         enum TPointerState
       
    69             {
       
    70             EPointerUp,
       
    71             EPointerDown,
       
    72             EPointerMoving
       
    73             };
       
    74 
       
    75         struct TAdvancedPointer
       
    76             {
       
    77             TUint8 PointerNum;
       
    78             TInt   X;
       
    79             TInt   Y;
       
    80             TInt   Z;            
       
    81             };			
       
    82 
       
    83 			
       
    84 
       
    85         /**
       
    86         * Two-phased constructor.
       
    87         */
       
    88         static CPointerEventHandler* NewL();
       
    89 
       
    90         /**
       
    91         * Destructor.
       
    92         */
       
    93         virtual ~CPointerEventHandler();
       
    94 
       
    95         /**
       
    96         * Called by the HtiKeyEventServicePlugin when a pointer event
       
    97         * command is received.
       
    98         * @param aMessage message body destinated to the servive
       
    99         * @param aPriority message priority
       
   100         */
       
   101         void ProcessMessageL( const TDesC8& aMessage,
       
   102             THtiMessagePriority aPriority );
       
   103 
       
   104         /**
       
   105         * Sets the dispatcher to send outgoing messages to.
       
   106         * @param aDispatcher pointer to dispatcher instance
       
   107         */
       
   108         void SetDispatcher( MHtiDispatcher* aDispatcher );
       
   109 
       
   110 
       
   111     protected: // Functions from base classes
       
   112 
       
   113         // From CActive
       
   114         void RunL();
       
   115         TInt RunError(TInt aError);
       
   116         void DoCancel();
       
   117         
       
   118         // From MHtiMultiTouchObserver
       
   119         void NotifyMultiTouchComplete();
       
   120 
       
   121     private:
       
   122 
       
   123         /**
       
   124         * C++ default constructor.
       
   125         */
       
   126         CPointerEventHandler();
       
   127 
       
   128         /**
       
   129         * 2nd phase constructor.
       
   130         */
       
   131         void ConstructL();
       
   132 
       
   133         // Helper methods
       
   134         void HandleTapScreenL( const TDesC8& aData );
       
   135         void HandleTapAndDragL( const TDesC8& aData );
       
   136         void HandleTapAndDragMultipointL( const TDesC8& aData );
       
   137         void HandlePointerDownOrUpL( const TDesC8& aData );
       
   138         
       
   139         //for advanced pointer
       
   140 		void HandleAdvancedTapScreenL( const TDesC8& aData ); 
       
   141         void HandlePinchZoomL( const TDesC8& aData ); 
       
   142         void HandleMultiTouchL( const TDesC8& aData );
       
   143 
       
   144         void SendOkMsgL();
       
   145         void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
       
   146 
       
   147         void ChangePointerStateL();
       
   148         void MoveToNextPointL();
       
   149         void PointerDown();
       
   150         void PointerUp();
       
   151         void PointerMove();
       
   152         void SimulatePointerEvent( TRawEvent::TType aType );
       
   153         TBool IsMultitouch();
       
   154         void AdvanceAddMiddlePointL(TInt aPointNumber,TInt aX1,TInt aY1, TInt aZ1,TInt aX2,TInt aY2, TInt aZ2 , TInt aStepCount );
       
   155         void AdvancedAddDelayArray(TTimeIntervalMicroSeconds32 aDelay , TInt aStepCount );
       
   156         TBool AdvancedStartDelay();
       
   157 
       
   158 
       
   159     private: // data
       
   160 
       
   161         RWsSession iWsSession;
       
   162         MHtiDispatcher* iDispatcher; // referenced
       
   163 
       
   164         RTimer iTimer;
       
   165         TBool  iReady;
       
   166         TUint8 iCommand;
       
   167         TInt   iX;
       
   168         TInt   iY;
       
   169         TInt   iTapCount;
       
   170         TTimeIntervalMicroSeconds32 iEventDelay;
       
   171         TTimeIntervalMicroSeconds32 iActionDelay;
       
   172         TPointerState iState;
       
   173         RArray<TInt>* iCoords;
       
   174 		RPointerArray<TAdvancedPointer> iAdvancedPointers;
       
   175 		
       
   176 		RPointerArray<TAdvancedPointer> iAdvPointerMoveArray;
       
   177 		RPointerArray<TTimeIntervalMicroSeconds32> iDelayArray;
       
   178 		
       
   179 		CMultiTouchPointerEventHandler* iMultiTouchHandler;
       
   180 		};
       
   181 
       
   182 #endif // CKEYEVENTHANDLER_H