htiui/HtiServicePlugins/HtiKeyEventServicePlugin/src/PointerEventHandler.cpp
changeset 11 4df3a095718c
parent 10 e6e3e87d58b4
equal deleted inserted replaced
10:e6e3e87d58b4 11:4df3a095718c
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include "HtiKeyEventServicePlugin.h"
    19 #include "HtiKeyEventServicePlugin.h"
    20 #include "PointerEventHandler.h"
    20 #include "PointerEventHandler.h"
    21 
    21 
       
    22 
    22 #include <HtiDispatcherInterface.h>
    23 #include <HtiDispatcherInterface.h>
    23 #include <HtiLogging.h>
    24 #include <HtiLogging.h>
    24 
    25 
    25 
    26 
    26 // CONSTANTS
    27 // CONSTANTS
    54 
    55 
    55 // ----------------------------------------------------------------------------
    56 // ----------------------------------------------------------------------------
    56 // CPointerEventHandler::CPointerEventHandler()
    57 // CPointerEventHandler::CPointerEventHandler()
    57 // ----------------------------------------------------------------------------
    58 // ----------------------------------------------------------------------------
    58 CPointerEventHandler::CPointerEventHandler()
    59 CPointerEventHandler::CPointerEventHandler()
    59     : CActive( CActive::EPriorityStandard ), iReady( ETrue ), iCommand( 0 ),
    60     : CActive( CActive::EPriorityStandard ), iReady( ETrue ), iCommand( 0 ), iMultiTouchHandler(NULL),
    60       iState( EPointerUp )
    61       iState( EPointerUp )
    61     {
    62     {
    62     }
    63     }
    63 
    64 
    64 // ----------------------------------------------------------------------------
    65 // ----------------------------------------------------------------------------
    73     if ( iCoords )
    74     if ( iCoords )
    74         {
    75         {
    75         iCoords->Close();
    76         iCoords->Close();
    76         }
    77         }
    77     delete iCoords;
    78     delete iCoords;
       
    79     delete iMultiTouchHandler;
    78 	
    80 	
    79 	iAdvancedPointers.ResetAndDestroy();
    81 	iAdvancedPointers.ResetAndDestroy();
    80 	iDelayArray.ResetAndDestroy();  
    82 	iDelayArray.ResetAndDestroy();  
    81 	iAdvPointerMoveArray.ResetAndDestroy(); 
    83 	iAdvPointerMoveArray.ResetAndDestroy(); 
    82     }
    84     }
   132         else
   134         else
   133             {
   135             {
   134             MoveToNextPointL(); // Continuing current line
   136             MoveToNextPointL(); // Continuing current line
   135             }
   137             }
   136         }
   138         }
       
   139     
   137     else if ( iCommand == EPinchZoom )
   140     else if ( iCommand == EPinchZoom )
   138         {
   141         {
   139         PointerMove();
   142         PointerMove();
   140         if ( !AdvancedStartDelay())
   143         if ( !AdvancedStartDelay())
   141             {
   144             {
   142             PointerUp();
   145             PointerUp();
   143             SendOkMsgL();
   146             SendOkMsgL();
       
   147             iAdvPointerMoveArray.ResetAndDestroy(); 
   144             iReady = ETrue;
   148             iReady = ETrue;
   145             }
   149             }
       
   150         }		
       
   151     
       
   152     else if ( iCommand == EMultiTouch )
       
   153         {
       
   154         SendOkMsgL();
       
   155         iMultiTouchHandler->Clear();
       
   156         iReady = ETrue;
   146         }		
   157         }		
   147     HTI_LOG_FUNC_OUT( "CPointerEventHandler::RunL" );
   158     HTI_LOG_FUNC_OUT( "CPointerEventHandler::RunL" );
   148     }
   159     }
   149 
   160 
   150 // ----------------------------------------------------------------------------
   161 // ----------------------------------------------------------------------------
   214 		    HandleAdvancedTapScreenL( aMessage.Right( aMessage.Length() - 1 ) );
   225 		    HandleAdvancedTapScreenL( aMessage.Right( aMessage.Length() - 1 ) );
   215             break;		
   226             break;		
   216 		case EPinchZoom: 
   227 		case EPinchZoom: 
   217 		    HandlePinchZoomL( aMessage.Right( aMessage.Length() - 1 ) );
   228 		    HandlePinchZoomL( aMessage.Right( aMessage.Length() - 1 ) );
   218             break;
   229             break;
   219 		
   230 		case EMultiTouch:
       
   231 			HandleMultiTouchL(aMessage.Right( aMessage.Length() - 1 ));
       
   232 			break;
   220         default:
   233         default:
   221             SendErrorMessageL( EUnrecognizedCommand,
   234             SendErrorMessageL( EUnrecognizedCommand,
   222                 KErrorUnrecognizedCommand );
   235                 KErrorUnrecognizedCommand );
   223             break;
   236             break;
   224         }
   237         }
   523 	TInt offset = 0;
   536 	TInt offset = 0;
   524 	
   537 	
   525 	TTimeIntervalMicroSeconds32 eventDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
   538 	TTimeIntervalMicroSeconds32 eventDelay = ( aData[offset] + ( aData[offset+1] << 8 ) ) * 1000;
   526 	offset += 2;
   539 	offset += 2;
   527     HTI_LOG_FORMAT( "Event time = %d", eventDelay.Int() );
   540     HTI_LOG_FORMAT( "Event time = %d", eventDelay.Int() );
   528 	
   541     
       
   542     if (eventDelay.Int()<=0)
       
   543         {
       
   544         SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
       
   545         return;        
       
   546         }
       
   547     
   529     TInt stepCount = aData[offset] + ( aData[offset+1] << 8 );
   548     TInt stepCount = aData[offset] + ( aData[offset+1] << 8 );
   530     offset += 2;
   549     offset += 2;
   531     HTI_LOG_FORMAT( "Step Count = %d", stepCount );
   550     HTI_LOG_FORMAT( "Step Count = %d", stepCount );
   532         
   551         
   533 	TInt pointerCount = aData[offset] + ( aData[offset+1] << 8 );
   552 	TInt pointerCount = aData[offset] + ( aData[offset+1] << 8 );
   539     // Read integers from aData to the array, all integers are 2 bytes
   558     // Read integers from aData to the array, all integers are 2 bytes
   540     for ( TInt i = 0; i < pointerCount; i++ )
   559     for ( TInt i = 0; i < pointerCount; i++ )
   541         {
   560         {
   542         TInt pointNumber,X1, Y1, Z1,X2,Y2, Z2 ;
   561         TInt pointNumber,X1, Y1, Z1,X2,Y2, Z2 ;
   543         
   562         
       
   563         // invalid pointer array 
       
   564         if ((dataLength-offset)<3*2*2+1)
       
   565             {
       
   566             SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
       
   567             return;        
       
   568             }        
   544         // start point	
   569         // start point	
   545 		pointNumber = aData[offset];
   570 		pointNumber = aData[offset];
   546 		offset += 1;
   571 		offset += 1;
   547 		HTI_LOG_FORMAT( "%d Pointer Start", pointNumber );
   572 		HTI_LOG_FORMAT( "%d Pointer Start", pointNumber );
   548 		
   573 		
   586         return;        
   611         return;        
   587         }
   612         }
   588 
   613 
   589     HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandlePinchZoomL" );
   614     HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandlePinchZoomL" );
   590     }	
   615     }	
   591 
   616 // ----------------------------------------------------------------------------
       
   617 // void CPointerEventHandler::HandleMultiTouchL()
       
   618 // ----------------------------------------------------------------------------
       
   619 void CPointerEventHandler::HandleMultiTouchL( const TDesC8& aData )
       
   620 	{
       
   621 	HTI_LOG_FUNC_IN( "CPointerEventHandler::HandleMultiTouchL" );	
       
   622 	
       
   623 	if (iMultiTouchHandler == NULL)
       
   624 		iMultiTouchHandler=CMultiTouchPointerEventHandler::NewL(*this);	
       
   625 	
       
   626     if ( !iMultiTouchHandler->HandleMultiTouchL ( aData ) )
       
   627     	{
       
   628 		iMultiTouchHandler->Clear();
       
   629 		SendErrorMessageL( EInvalidParameters, KErrorInvalidParameters );
       
   630     	}
       
   631     else
       
   632 		iReady = EFalse;
       
   633 	
       
   634 	HTI_LOG_FUNC_OUT( "CPointerEventHandler::HandleMultiTouchL" );
       
   635 	}
       
   636 // ----------------------------------------------------------------------------
       
   637 // void CPointerEventHandler::NotifyMultiTouchComplete()
       
   638 // ----------------------------------------------------------------------------
       
   639 void CPointerEventHandler::NotifyMultiTouchComplete()
       
   640     {
       
   641     HTI_LOG_FUNC_IN("CPointerEventHandler::NotifyMultiTouchComplete"); 
       
   642     
       
   643     // wait for 1000 microsecond then clear multi touch and send ok msg 
       
   644     TTimeIntervalMicroSeconds32 time(1000);
       
   645     iTimer.After( iStatus, time );
       
   646     SetActive();    
       
   647     
       
   648     HTI_LOG_FUNC_OUT("CPointerEventHandler::NotifyMultiTouchComplete");
       
   649     }
   592 // ----------------------------------------------------------------------------
   650 // ----------------------------------------------------------------------------
   593 // CPointerEventHandler::AdvancedStartDelay()
   651 // CPointerEventHandler::AdvancedStartDelay()
   594 // ----------------------------------------------------------------------------
   652 // ----------------------------------------------------------------------------
   595 TBool CPointerEventHandler::AdvancedStartDelay()
   653 TBool CPointerEventHandler::AdvancedStartDelay()
   596     {
   654     {