htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/PointerEventHandler.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:51:38 +0200
branchRCL_3
changeset 3 2703485a934c
parent 0 d6fe6244b863
child 11 4df3a095718c
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Functional implentation of pointer event service.
*
*/

#ifndef CPOINTEREVENTHANDLER_H
#define CPOINTEREVENTHANDLER_H

// INCLUDES
#include <HtiServicePluginInterface.h>
#include <w32std.h>

// CONSTANTS

// MACROS

// DATA TYPES

// FUNCTION PROTOTYPES

// FORWARD DECLARATIONS

// CLASS DECLARATION


/**
*  Functional implentation of pointer event service.
*/
class CPointerEventHandler : public CActive
    {
    public:

        enum TError
            {
            EMissingCommand          = 0x01,
            EUnrecognizedCommand     = 0x02,
            ENotReadyCommand         = 0x03,
            EInvalidParameters       = 0x9A
            };

        enum TCommand
            {
            ETapScreen = 0x10,
            ETapAndDrag = 0x11,
            ETapAndDragMultipoint = 0x12,
            EPressPointerDown = 0x13,
            ELiftPointerUp = 0x14,
			EAdvancedTapScreen = 0x15, //for advanced
			EPinchZoom = 0x16, //for advanced
            EResultOk = 0xFF // only for response message
            };

        enum TPointerState
            {
            EPointerUp,
            EPointerDown,
            EPointerMoving
            };

        struct TAdvancedPointer
            {
            TUint8 PointerNum;
            TInt   X;
            TInt   Y;
            TInt   Z;            
            };			

			

        /**
        * Two-phased constructor.
        */
        static CPointerEventHandler* NewL();

        /**
        * Destructor.
        */
        virtual ~CPointerEventHandler();

        /**
        * Called by the HtiKeyEventServicePlugin when a pointer event
        * command is received.
        * @param aMessage message body destinated to the servive
        * @param aPriority message priority
        */
        void ProcessMessageL( const TDesC8& aMessage,
            THtiMessagePriority aPriority );

        /**
        * Sets the dispatcher to send outgoing messages to.
        * @param aDispatcher pointer to dispatcher instance
        */
        void SetDispatcher( MHtiDispatcher* aDispatcher );


    protected: // Functions from base classes

        // From CActive
        void RunL();
        TInt RunError(TInt aError);
        void DoCancel();

    private:

        /**
        * C++ default constructor.
        */
        CPointerEventHandler();

        /**
        * 2nd phase constructor.
        */
        void ConstructL();

        // Helper methods
        void HandleTapScreenL( const TDesC8& aData );
        void HandleTapAndDragL( const TDesC8& aData );
        void HandleTapAndDragMultipointL( const TDesC8& aData );
        void HandlePointerDownOrUpL( const TDesC8& aData );
		void HandleAdvancedTapScreenL( const TDesC8& aData ); //for advanced
        void HandlePinchZoomL( const TDesC8& aData ); //for advanced

        void SendOkMsgL();
        void SendErrorMessageL( TInt aError, const TDesC8& aDescription );

        void ChangePointerStateL();
        void MoveToNextPointL();
        void PointerDown();
        void PointerUp();
        void PointerMove();
        void SimulatePointerEvent( TRawEvent::TType aType );
        TBool IsMultitouch();
        void AdvanceAddMiddlePointL(TInt aPointNumber,TInt aX1,TInt aY1, TInt aZ1,TInt aX2,TInt aY2, TInt aZ2 , TInt aStepCount );
        void AdvancedAddDelayArray(TTimeIntervalMicroSeconds32 aDelay , TInt aStepCount );
        TBool AdvancedStartDelay();


    private: // data

        RWsSession iWsSession;
        MHtiDispatcher* iDispatcher; // referenced

        RTimer iTimer;
        TBool  iReady;
        TUint8 iCommand;
        TInt   iX;
        TInt   iY;
        TInt   iTapCount;
        TTimeIntervalMicroSeconds32 iEventDelay;
        TTimeIntervalMicroSeconds32 iActionDelay;
        TPointerState iState;
        RArray<TInt>* iCoords;
		RPointerArray<TAdvancedPointer> iAdvancedPointers;
		
		RPointerArray<TAdvancedPointer> iAdvPointerMoveArray;
		RPointerArray<TTimeIntervalMicroSeconds32> iDelayArray;
		};

#endif // CKEYEVENTHANDLER_H