textinput/peninputarc/src/peninputanim/penpointereventsuppressor.cpp
branchRCL_3
changeset 22 bd83ceabce89
parent 0 eb1f2e154e89
equal deleted inserted replaced
21:ecbabf52600f 22:bd83ceabce89
    19 
    19 
    20 const TInt KPenPointerEventSuppressorDefaultMaxTapDuration = 400000;	// 0.4 seconds
    20 const TInt KPenPointerEventSuppressorDefaultMaxTapDuration = 400000;	// 0.4 seconds
    21 const TInt KPenPointerEventSuppressorDefaultMinInterDragInterval = 0;
    21 const TInt KPenPointerEventSuppressorDefaultMinInterDragInterval = 0;
    22 const TInt KPenPointerEventSuppressorDefaultMovement = 6;
    22 const TInt KPenPointerEventSuppressorDefaultMovement = 6;
    23 
    23 
       
    24 const TInt KPenPointerEventSuppressorDefaultMaxDownUpDuration = 400000; // 0.4 seconds
       
    25 const TInt KPenPointerEventSuppressorDefaultDownUpMovement = 7;
       
    26 
    24 CPenPointerEventSuppressor* CPenPointerEventSuppressor::NewL()
    27 CPenPointerEventSuppressor* CPenPointerEventSuppressor::NewL()
    25 	{
    28 	{
    26 	return new (ELeave) CPenPointerEventSuppressor;
    29 	return new (ELeave) CPenPointerEventSuppressor;
    27 	}
    30 	}
    28 
    31 
    30 	{
    33 	{
    31 	
    34 	
    32 	}
    35 	}
    33 
    36 
    34 CPenPointerEventSuppressor::CPenPointerEventSuppressor()
    37 CPenPointerEventSuppressor::CPenPointerEventSuppressor()
    35 : iMaxTapDuration(KPenPointerEventSuppressorDefaultMaxTapDuration),
    38 : iMaxTapDuration( KPenPointerEventSuppressorDefaultMaxTapDuration ),
    36   iMinInterDragInterval(KPenPointerEventSuppressorDefaultMinInterDragInterval),
    39   iMinInterDragInterval( KPenPointerEventSuppressorDefaultMinInterDragInterval ),
    37   iTap(EFalse)
    40   iTap( EFalse ),
       
    41   iMaxDownUpDuration( KPenPointerEventSuppressorDefaultMaxDownUpDuration )
    38   	{
    42   	{
    39   	// default move limit is 6 units, which seems to be a forgiving value for finger touch
    43   	// default move limit is 6 units, which seems to be a forgiving value for finger touch
    40   	iMaxTapMove.iWidth = KPenPointerEventSuppressorDefaultMovement;
    44   	iMaxTapMove.iWidth = KPenPointerEventSuppressorDefaultMovement;
    41 	iMaxTapMove.iHeight = KPenPointerEventSuppressorDefaultMovement;
    45 	iMaxTapMove.iHeight = KPenPointerEventSuppressorDefaultMovement;
       
    46 	
       
    47 	iMaxDownUpMove.iWidth = KPenPointerEventSuppressorDefaultDownUpMovement;
       
    48 	iMaxDownUpMove.iHeight = KPenPointerEventSuppressorDefaultDownUpMovement;
    42   	}
    49   	}
    43 
    50 
    44 TBool CPenPointerEventSuppressor::SuppressPointerEvent(
    51 TBool CPenPointerEventSuppressor::SuppressPointerEvent( TPointerEvent& aPointerEvent )
    45         const TPointerEvent& aPointerEvent)
       
    46 	{
    52 	{
    47 	switch ( aPointerEvent.iType )
    53 	switch ( aPointerEvent.iType )
    48 		{
    54 		{
    49 		case TPointerEvent::EButton1Down:
    55 		case TPointerEvent::EButton1Down:
    50 		    {
    56 		    {
    86 			// this drag event should be handled
    92 			// this drag event should be handled
    87 			iLastEventTime = now;
    93 			iLastEventTime = now;
    88 			break;
    94 			break;
    89 			}
    95 			}
    90 		case TPointerEvent::EButton1Up:
    96 		case TPointerEvent::EButton1Up:
    91 		    {
    97             {
       
    98             TTime now;
       
    99             now.HomeTime();
       
   100             TPoint delta = aPointerEvent.iPosition - iDownPos;
       
   101             if ( now.MicroSecondsFrom( iDownTime ) < iMaxDownUpDuration 
       
   102                  && Abs( delta.iX ) < iMaxDownUpMove.iWidth 
       
   103                  && Abs( delta.iY ) < iMaxDownUpMove.iHeight )
       
   104                 {
       
   105                 //within maximum movement and timeout, so move to position of down
       
   106                 aPointerEvent.iPosition = iDownPos;
       
   107                 }
    92 			iTap = EFalse;
   108 			iTap = EFalse;
    93 			break;
   109 			break;
    94 		    }
   110 		    }
    95 		case TPointerEvent::ENullType:
   111 		case TPointerEvent::ENullType:
    96 		    break;
   112 		    break;
   116 void CPenPointerEventSuppressor::SetMinInterDragInterval(
   132 void CPenPointerEventSuppressor::SetMinInterDragInterval(
   117         TTimeIntervalMicroSeconds aInterval)
   133         TTimeIntervalMicroSeconds aInterval)
   118 	{
   134 	{
   119 	iMinInterDragInterval = aInterval;
   135 	iMinInterDragInterval = aInterval;
   120 	}
   136 	}
       
   137 
       
   138 void CPenPointerEventSuppressor::SetMaxDownUpMove( TSize aMaxDownUpMove ) 
       
   139     { 
       
   140     iMaxDownUpMove = aMaxDownUpMove; 
       
   141     }
       
   142 
       
   143 void CPenPointerEventSuppressor::SetMaxDownUpDuration( TTimeIntervalMicroSeconds aDuration ) 
       
   144     {
       
   145     iMaxDownUpDuration = aDuration; 
       
   146     }