textinput/peninputarc/src/peninputanim/peninputanim.cpp
branchRCL_3
changeset 44 ecbabf52600f
parent 43 ebd48d2de13c
child 46 bd83ceabce89
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
    29 //INCLUDE
    29 //INCLUDE
    30 #include "peninputanim.h" 
    30 #include "peninputanim.h" 
    31 #include "peninputcmdparam.h"
    31 #include "peninputcmdparam.h"
    32 #include "peninputcmdparamext.h"
    32 #include "peninputcmdparamext.h"
    33 #include "peninputcmd.h"
    33 #include "peninputcmd.h"
    34 // Modify for bug ETMA-7X2C5Y begin
       
    35 #include "penpointereventsuppressor.h"
    34 #include "penpointereventsuppressor.h"
    36 // Modify for bug ETMA-7X2C5Y end
       
    37 // ----------- Touch feedback additions start
    35 // ----------- Touch feedback additions start
    38 #ifdef RD_TACTILE_FEEDBACK
    36 #ifdef RD_TACTILE_FEEDBACK
    39 #include <coecntrl.h>
    37 #include <coecntrl.h>
    40 #include <tactilefeedbackserver.h>
    38 #include <tactilefeedbackserver.h>
    41 #include <featmgr.h>
    39 #include <featmgr.h>
    42 #endif //RD_TACTILE_FEEDBACK
    40 #endif //RD_TACTILE_FEEDBACK
    43 // ----------- Touch feedback additions start
    41 // ----------- Touch feedback additions start
    44 
    42 
    45 #include <avkondomainpskeys.h>
    43 #include <avkondomainpskeys.h>
    46 //CONSTANT
    44 //CONSTANT
    47 const TInt KMsgSlot1 = 1;	//msg slot 2 in IPC
    45 const TInt KMsgSlot1 = 1;     //msg slot 2 in IPC
    48 const TInt KMsgSlot2 = 2; 	//msg slot 2 in IPC
    46 const TInt KMsgSlot2 = 2;     //msg slot 2 in IPC
    49 const TInt KFlushTimerPeriod = 1000;		//1/1000 second
    47 const TInt KFlushTimerPeriod = 1000 * 10;          //1/100 second
    50 const TInt KResponseQueueWaitTime = 100000;		//1/10 second
    48 const TInt KResponseQueueWaitTime = 100000;        //1/10 second
    51 
    49 
    52 // ======== GLOBAL FUNCTIONS ========
    50 // ======== GLOBAL FUNCTIONS ========
    53 
    51 
    54 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    55 // CreateCAnimDllL
    53 // CreateCAnimDllL
    57 // client, to construct the CAnimDll derived server side DLL class.
    55 // client, to construct the CAnimDll derived server side DLL class.
    58 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    59 //
    57 //
    60 EXPORT_C CAnimDll *CreateCAnimDllL()
    58 EXPORT_C CAnimDll *CreateCAnimDllL()
    61     {
    59     {
    62 	return(new (ELeave) CPeninputAnimDll()); 
    60     return(new (ELeave) CPeninputAnimDll()); 
    63     }
    61     }
    64 
    62 
    65 // ======== MEMBER FUNCTIONS ========
    63 // ======== MEMBER FUNCTIONS ========
    66 
    64 
    67 // class CAnimDll
    65 // class CAnimDll
    71 // Factory function for animation DLL.
    69 // Factory function for animation DLL.
    72 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    73 //
    71 //
    74 CAnim* CPeninputAnimDll::CreateInstanceL(TInt /*aType*/)
    72 CAnim* CPeninputAnimDll::CreateInstanceL(TInt /*aType*/)
    75     {
    73     {
    76 	return new(ELeave) CPeninputAnim();
    74     return new(ELeave) CPeninputAnim();
    77     }
    75     }
    78 
    76 
    79 // class CPeninputAnim
    77 // class CPeninputAnim
    80 
    78 
    81 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    83 // Constructor
    81 // Constructor
    84 // ---------------------------------------------------------------------------
    82 // ---------------------------------------------------------------------------
    85 //
    83 //
    86 CPeninputAnim::CPeninputAnim()
    84 CPeninputAnim::CPeninputAnim()
    87     {
    85     {
    88 	iIsActive = EFalse;
    86     iIsActive = EFalse;
    89 	//iSpritePosition and iSpriteSize are initialized to 0 by default constructor
    87     //iSpritePosition and iSpriteSize are initialized to 0 by default constructor
    90 	//iSpritePosition = TPoint(0, 0);
    88     //iSpritePosition = TPoint(0, 0);
    91 	//iSpriteSize = TSize(0, 0);
    89     //iSpriteSize = TSize(0, 0);
    92 	iIsPointerCaptured = EFalse;
    90     iIsPointerCaptured = EFalse;
    93 	iIsPenDown = EFalse;
    91     iIsPenDown = EFalse;
    94 	
    92     
    95 	iPrimaryTouchPtNum = 0;
    93     iPrimaryTouchPtNum = 0;
    96 	iPrimaryTouchPtDetected = EFalse;
    94     iPrimaryTouchPtDetected = EFalse;
    97 
    95 
    98 	
    96     
    99 #ifdef RD_TACTILE_FEEDBACK	
    97 #ifdef RD_TACTILE_FEEDBACK    
   100 	TRAPD( err, FeatureManager::InitializeLibL() );
    98     TRAPD( err, FeatureManager::InitializeLibL() );
   101     if( err == KErrNone )
    99     if( err == KErrNone )
   102         {
   100         {
   103         iTactileSupported =  FeatureManager::FeatureSupported( KFeatureIdTactileFeedback );
   101         iTactileSupported =  FeatureManager::FeatureSupported( KFeatureIdTactileFeedback );
   104         }
   102         }
   105 	iFeedback = MTactileFeedbackServer::Instance();
   103     iFeedback = MTactileFeedbackServer::Instance();
   106 #endif // RD_TACTILE_FEEDBACK	
   104 #endif // RD_TACTILE_FEEDBACK    
   107     
   105     
   108     iEnableSprite = ETrue;	
   106     iEnableSprite = ETrue;    
   109     iDSAState = EFalse;	
   107     iDSAState = EFalse;    
   110     }
   108     }
   111 
   109 
   112 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   113 // CPeninputAnim::~CPeninputAnim
   111 // CPeninputAnim::~CPeninputAnim
   114 // Destructor
   112 // Destructor
   115 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   116 //
   114 //
   117 CPeninputAnim::~CPeninputAnim()
   115 CPeninputAnim::~CPeninputAnim()
   118     {
   116     {
   119 	Deactivate();
   117     Deactivate();
   120 
   118 
   121 	iMsgBufQueue.Close();
   119     iMsgBufQueue.Close();
   122 	iKeyMsgResponseQueue.Close();
   120     iKeyMsgResponseQueue.Close();
   123 	iResponseQueueSemaphore.Close();
   121     iResponseQueueSemaphore.Close();
   124 	
   122     
   125 	delete iFlushTimer;
   123     delete iFlushTimer;
   126 #ifdef RD_TACTILE_FEEDBACK	
   124 #ifdef RD_TACTILE_FEEDBACK    
   127 	FeatureManager::UnInitializeLib();
   125     FeatureManager::UnInitializeLib();
   128 	iTactileControl.Close();
   126     iTactileControl.Close();
   129 	iBackupTactileControl.Close();
   127     iBackupTactileControl.Close();
   130 #endif // RD_TACTILE_FEEDBACK	
   128 #endif // RD_TACTILE_FEEDBACK    
   131 	// Modify for bug ETMA-7X2C5Y begin
   129     delete iPointerEventSuppressor;
   132 	delete iPointerEventSuppressor;
       
   133 	// Modify for bug ETMA-7X2C5Y end
       
   134 	if (iDiscreetPopSubscriber)
       
   135 	    {
       
   136 	    iDiscreetPopSubscriber->StopSubscribe();
       
   137 	    }
       
   138 	iDiscreetPopProperty.Close();
       
   139 	delete iDiscreetPopSubscriber;
       
   140 	iAknUiSrv.Close();
       
   141     }
   130     }
   142 
   131 
   143 // ---------------------------------------------------------------------------
   132 // ---------------------------------------------------------------------------
   144 // CPeninputAnim::ConstructL
   133 // CPeninputAnim::ConstructL
   145 // Second phase constructor
   134 // Second phase constructor
   146 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   147 //
   136 //
   148 void CPeninputAnim::ConstructL(TAny* /*aParameters*/)
   137 void CPeninputAnim::ConstructL(TAny* /*aParameters*/)
   149     {
   138     {
   150 	// the animation feature is not used
   139     // the animation feature is not used
   151 	iFunctions->SetInterval(0);
   140     iFunctions->SetInterval(0);
   152 	iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard);
   141     iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard);
   153 	
   142     
   154     iFunctions->RegisterForNotifications(EDirectScreenAccess);
   143     iFunctions->RegisterForNotifications(EDirectScreenAccess);
   155 	// Modify for bug ETMA-7X2C5Y begin
       
   156     iPointerEventSuppressor = CPenPointerEventSuppressor::NewL();
   144     iPointerEventSuppressor = CPenPointerEventSuppressor::NewL();
   157     // Modify for bug ETMA-7X2C5Y end
       
   158     User::LeaveIfError(iDiscreetPopProperty.Attach(KPSUidAvkonDomain, 
       
   159                                          KAknGlobalDiscreetPopupNumChanged));
       
   160     iDiscreetPopSubscriber = new (ELeave) CSubscriber(
       
   161 			TCallBack( DiscreetPopChangeNotification, this), 
       
   162 			iDiscreetPopProperty);
       
   163     iDiscreetPopSubscriber->SubscribeL();
       
   164 	
       
   165 	User::LeaveIfError(iAknUiSrv.Connect());
       
   166 	iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
       
   167     if(iDiscreetPopArea.Size().iWidth > 0)
       
   168     	{
       
   169 		iDiscreetPoped = ETrue;
       
   170     	}
       
   171     }
   145     }
   172 
   146 
   173 
   147 
   174 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   175 // CPeninputAnim::Animate
   149 // CPeninputAnim::Animate
   223 //
   197 //
   224 TBool CPeninputAnim::OfferRawEvent(const TRawEvent& aRawEvent)
   198 TBool CPeninputAnim::OfferRawEvent(const TRawEvent& aRawEvent)
   225     {
   199     {
   226     if( iIsSimulatedEvent )
   200     if( iIsSimulatedEvent )
   227         {
   201         {
   228     	return EFalse;
   202         return EFalse;
   229         }
   203         }
   230     
   204     
   231     // Suppress multi-touch events
   205     // Suppress multi-touch events
   232     switch ( aRawEvent.Type() )
   206     switch ( aRawEvent.Type() )
   233         {
   207         {
   252         default:
   226         default:
   253             break;
   227             break;
   254         }
   228         }
   255 
   229 
   256     
   230     
   257 	// Suppress unexpected drag events, refer to error ETMA-7X2C5Y
   231     // Suppress unexpected drag events
   258     TPointerEvent pointerEvent;
   232     TPointerEvent pointerEvent;
   259     switch ( aRawEvent.Type() )
   233     switch ( aRawEvent.Type() )
   260         {
   234         {
   261         case TRawEvent::EButton1Down:
   235         case TRawEvent::EButton1Down:
   262             {
   236             {
   284         {
   258         {
   285         return ETrue;
   259         return ETrue;
   286         }
   260         }
   287 
   261 
   288     
   262     
   289 	switch(aRawEvent.Type())
   263     switch(aRawEvent.Type())
   290 	    {
   264         {
   291 		case TRawEvent::EKeyUp:
   265         case TRawEvent::EKeyUp:
   292 		case TRawEvent::EKeyDown:
   266         case TRawEvent::EKeyDown:
   293 		    {
   267             {
   294 			return OnRawKeyEvent(aRawEvent);        	
   268             return OnRawKeyEvent(aRawEvent);            
   295 		    }
   269             }
   296 		case TRawEvent::EButton1Down:
   270         case TRawEvent::EButton1Down:
   297 		    {
   271             {
   298 			return OnRawButton1Down(aRawEvent);
   272             TBool used = OnRawButton1Down(aRawEvent);
   299 		    }
   273             
   300 		case TRawEvent::EButton1Up:
   274             if ( used )
   301 		    {
   275                 {
   302 			return OnRawButton1Up(aRawEvent);
   276                 StartTimer();
   303 		    }
   277                 }
   304 		case TRawEvent::EPointerMove:
   278             
   305 		    {
   279             return used;
   306 			return OnRawPointerMove(aRawEvent);
   280             }
   307 		    }
   281         case TRawEvent::EButton1Up:
   308 		default:
   282             {
   309 		    {
   283             TBool used = OnRawButton1Up(aRawEvent);
   310 			return EFalse;
   284             StopTimer();
   311 		    }            
   285             return used;
   312 	    }	
   286             }
       
   287         case TRawEvent::EPointerMove:
       
   288             {
       
   289             return OnRawPointerMove(aRawEvent);
       
   290             }
       
   291         default:
       
   292             {
       
   293             return EFalse;
       
   294             }            
       
   295         }    
   313     }
   296     }
   314 
   297 
   315 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   316 // CPeninputAnim::Command
   299 // CPeninputAnim::Command
   317 // The window server calls this function in response to application 
   300 // The window server calls this function in response to application 
   320 //
   303 //
   321 void CPeninputAnim::Command(TInt aOpcode, TAny* aParams)
   304 void CPeninputAnim::Command(TInt aOpcode, TAny* aParams)
   322     {
   305     {
   323     switch(aOpcode)
   306     switch(aOpcode)
   324         {
   307         {
   325 		case EPeninputOpActivate:
   308         case EPeninputOpActivate:
   326             {
   309             {
   327             Activate();
   310             Activate();
   328             break;
   311             break;
   329             }        
   312             }        
   330         case EPeninputOpDeactivate:
   313         case EPeninputOpDeactivate:
   332             Deactivate();
   315             Deactivate();
   333             break;
   316             break;
   334             }        
   317             }        
   335         case EPeninputOpLayoutUpdateArea:
   318         case EPeninputOpLayoutUpdateArea:
   336             {
   319             {
   337             PanicClientIfNoParam(aParams);	                
   320             PanicClientIfNoParam(aParams);                    
   338 			TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams);
   321             TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams);
   339 			iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag );
   322             iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag );
   340 			break;
   323             break;
   341 		    }			
   324             }            
   342         case EPeninputOpCapturePointer:
   325         case EPeninputOpCapturePointer:
   343             {
   326             {
   344             PanicClientIfNoParam(aParams);            
   327             PanicClientIfNoParam(aParams);            
   345 	        iIsPointerCaptured = *(static_cast<TBool*>(aParams));
   328             iIsPointerCaptured = *(static_cast<TBool*>(aParams));
   346 	        break;
   329             break;
   347             }
   330             }
   348         case EPeninputOpSimulateEvent:
   331         case EPeninputOpSimulateEvent:
   349             {
   332             {
   350             PanicClientIfNoParam(aParams);
   333             PanicClientIfNoParam(aParams);
   351             TRawEvent event = *(static_cast<TRawEvent*>(aParams));
   334             TRawEvent event = *(static_cast<TRawEvent*>(aParams));
   380                 iTactileControl.Reset();
   363                 iTactileControl.Reset();
   381                 break;
   364                 break;
   382                 }
   365                 }
   383             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
   366             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
   384             TInt idx = iTactileControl.Find(controlitem, 
   367             TInt idx = iTactileControl.Find(controlitem, 
   385             		TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   368                     TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   386             if(idx != KErrNotFound)
   369             if(idx != KErrNotFound)
   387                 {  
   370                 {  
   388                 iTactileControl.Remove(idx);
   371                 iTactileControl.Remove(idx);
   389                 }
   372                 }
   390             }
   373             }
   402                 iTactileControl[idx].iArea = area.iNewRect;
   385                 iTactileControl[idx].iArea = area.iNewRect;
   403                 }  
   386                 }  
   404             }
   387             }
   405             break; 
   388             break; 
   406         case EPeninputOpChangeFeedbackType:
   389         case EPeninputOpChangeFeedbackType:
   407         	{
   390             {
   408         	PanicClientIfNoParam(aParams);
   391             PanicClientIfNoParam(aParams);
   409             TTactileFeedbackArea area = *(static_cast<TTactileFeedbackArea*>(aParams));
   392             TTactileFeedbackArea area = *(static_cast<TTactileFeedbackArea*>(aParams));
   410             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
   393             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
   411             TInt idx = iTactileControl.Find(controlitem,                    
   394             TInt idx = iTactileControl.Find(controlitem,                    
   412 					TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   395                     TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   413             if(idx != KErrNotFound)
   396             if(idx != KErrNotFound)
   414                 {                                
   397                 {                                
   415                 //change the tactile type
   398                 //change the tactile type
   416                 iTactileControl[idx].iTactileType = area.iTactileType;
   399                 iTactileControl[idx].iTactileType = area.iTactileType;
   417                 }        	
   400                 }            
   418         	}
   401             }
   419             break;
   402             break;
   420 #endif // RD_TACTILE_FEEDBACK
   403 #endif // RD_TACTILE_FEEDBACK
   421         case EPeninputOpEnalbeSprite:
   404         case EPeninputOpEnalbeSprite:
   422             {
   405             {
   423             PanicClientIfNoParam(aParams);
   406             PanicClientIfNoParam(aParams);
   430             {
   413             {
   431             //panic the client for unknown command
   414             //panic the client for unknown command
   432             iFunctions->Panic();
   415             iFunctions->Panic();
   433             break;
   416             break;
   434             }
   417             }
   435 	    }
   418         }
   436     }
   419     }
   437 
   420 
   438 
   421 
   439 // ---------------------------------------------------------------------------
   422 // ---------------------------------------------------------------------------
   440 // CPeninputAnim::CommandReplyL
   423 // CPeninputAnim::CommandReplyL
   456             retValue = iMsgBufQueue.OpenGlobal(KMsgEventBufferQueue);
   439             retValue = iMsgBufQueue.OpenGlobal(KMsgEventBufferQueue);
   457             //event queue for key event response from pen input servers
   440             //event queue for key event response from pen input servers
   458             iKeyMsgResponseQueue.OpenGlobal(KMsgEventResponseQueue);
   441             iKeyMsgResponseQueue.OpenGlobal(KMsgEventResponseQueue);
   459             iResponseQueueSemaphore.OpenGlobal(KAnimKeyEventSemaphore);
   442             iResponseQueueSemaphore.OpenGlobal(KAnimKeyEventSemaphore);
   460 
   443 
   461 			break;
   444             break;
   462             }
   445             }
   463 
   446 
   464         case EPeninputOpActivate:
   447         case EPeninputOpActivate:
   465             {
   448             {
   466             Activate();
   449             Activate();
   472             Deactivate();
   455             Deactivate();
   473             break;
   456             break;
   474             }       
   457             }       
   475             
   458             
   476         case EPeninputOpLayoutUpdateArea:
   459         case EPeninputOpLayoutUpdateArea:
   477         	{
   460             {
   478         	//TUpdateDataArea s;
   461             //TUpdateDataArea s;
   479 			//TPckg<TUpdateDataArea> pkg(s);        	
   462             //TPckg<TUpdateDataArea> pkg(s);            
   480 			TRect rect;
   463             TRect rect;
   481 			TBool flag;
   464             TBool flag;
   482 		    TPckg<TRect> rectMsg(rect);			
   465             TPckg<TRect> rectMsg(rect);            
   483 		    TPckg<TBool> flagMsg(flag);    
   466             TPckg<TBool> flagMsg(flag);    
   484 			
   467             
   485 			msg->ReadL(KMsgSlot1,rectMsg);
   468             msg->ReadL(KMsgSlot1,rectMsg);
   486 			msg->ReadL(KMsgSlot2,flagMsg);
   469             msg->ReadL(KMsgSlot2,flagMsg);
   487 			iSpriteFunctions->UpdateMember(0, rect,flag);			
   470             iSpriteFunctions->UpdateMember(0, rect,flag);            
   488         	  }
   471               }
   489         	  break;
   472               break;
   490         case EPeninputOpLayoutUpdateAreaRegion:
   473         case EPeninputOpLayoutUpdateAreaRegion:
   491             {
   474             {
   492             TInt num;
   475             TInt num;
   493             TPckg<TInt> numMsg(num);    
   476             TPckg<TInt> numMsg(num);    
   494             msg->ReadL(KMsgSlot1,numMsg);
   477             msg->ReadL(KMsgSlot1,numMsg);
   505                 {
   488                 {
   506                 iSpriteFunctions->UpdateMember(0, area[i].iRect,area[i].iFullUpdateFlag);
   489                 iSpriteFunctions->UpdateMember(0, area[i].iRect,area[i].iFullUpdateFlag);
   507                 }
   490                 }
   508 
   491 
   509             CleanupStack::PopAndDestroy( buf );
   492             CleanupStack::PopAndDestroy( buf );
   510         	}
   493             }
   511         	break;
   494             break;
   512         case EPeninputOpSetLayoutPos:
   495         case EPeninputOpSetLayoutPos:
   513             {
   496             {
   514             TPoint pt;
   497             TPoint pt;
   515             TPckg<TPoint> msgData(pt);
   498             TPckg<TPoint> msgData(pt);
   516             msg->ReadL(KMsgSlot1,msgData);
   499             msg->ReadL(KMsgSlot1,msgData);
   519             break;
   502             break;
   520             
   503             
   521         case EPeninputOpCapturePointer:
   504         case EPeninputOpCapturePointer:
   522             {
   505             {
   523             TInt captureCtrlID;
   506             TInt captureCtrlID;
   524 			TPckg<TBool> msgData(iIsPointerCaptured);
   507             TPckg<TBool> msgData(iIsPointerCaptured);
   525 			TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID);
   508             TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID);
   526             
   509             
   527             msg->ReadL(KMsgSlot1,msgData);
   510             msg->ReadL(KMsgSlot1,msgData);
   528             msg->ReadL(KMsgSlot2,msgCaptureCtrlIDData);
   511             msg->ReadL(KMsgSlot2,msgCaptureCtrlIDData);
   529 #ifdef RD_TACTILE_FEEDBACK
   512 #ifdef RD_TACTILE_FEEDBACK
   530 			// When pointer is captured by some ctrl,
   513             // When pointer is captured by some ctrl,
   531 			// only the captured ctrl has tactile feedback ablity,
   514             // only the captured ctrl has tactile feedback ablity,
   532 			// disable all other one's.
   515             // disable all other one's.
   533             if (iIsPointerCaptured)
   516             if (iIsPointerCaptured)
   534             	{
   517                 {
   535             	// Back up all the tactile area
   518                 // Back up all the tactile area
   536             	iBackupTactileControl.Reset();        	
   519                 iBackupTactileControl.Reset();            
   537 		        TInt count = iTactileControl.Count();
   520                 TInt count = iTactileControl.Count();
   538 		        for(TInt i = 0; i < count; ++i)
   521                 for(TInt i = 0; i < count; ++i)
   539 		            {
   522                     {
   540 		            iBackupTactileControl.Append(iTactileControl[i]);
   523                     iBackupTactileControl.Append(iTactileControl[i]);
   541 		            }
   524                     }
   542 		        
   525                 
   543 		        // Clean up the original tactile area
   526                 // Clean up the original tactile area
   544 		        iTactileControl.Reset();		       
   527                 iTactileControl.Reset();               
   545 		        
   528                 
   546 		        // Find the captured ctrl, restore its tactile ablity
   529                 // Find the captured ctrl, restore its tactile ablity
   547 		        for(TInt i = 0; i < count; ++i)
   530                 for(TInt i = 0; i < count; ++i)
   548 		            {
   531                     {
   549 		            if (iBackupTactileControl[i].iId == captureCtrlID)
   532                     if (iBackupTactileControl[i].iId == captureCtrlID)
   550 		            	{
   533                         {
   551 		            	iTactileControl.Append(iBackupTactileControl[i]);
   534                         iTactileControl.Append(iBackupTactileControl[i]);
   552 		            	}
   535                         }
   553 		            }
   536                     }
   554 
   537 
   555             	}
   538                 }
   556             // When pointer released captured, 
   539             // When pointer released captured, 
   557             // restore all original tactile area.
   540             // restore all original tactile area.
   558             else 
   541             else 
   559             	{
   542                 {
   560             	if (iBackupTactileControl.Count() != 0)
   543                 if (iBackupTactileControl.Count() != 0)
   561             		{
   544                     {
   562             		iTactileControl.Reset();			       
   545                     iTactileControl.Reset();                   
   563 	            	
   546                     
   564 			        TInt count = iBackupTactileControl.Count();
   547                     TInt count = iBackupTactileControl.Count();
   565 			        for(TInt i = 0; i < count; ++i)
   548                     for(TInt i = 0; i < count; ++i)
   566 			            {
   549                         {
   567 			            iTactileControl.Append(iBackupTactileControl[i]);
   550                         iTactileControl.Append(iBackupTactileControl[i]);
   568 			            }
   551                         }
   569 			        iBackupTactileControl.Reset();
   552                     iBackupTactileControl.Reset();
   570             		}
   553                     }
   571             	}
   554                 }
   572 #endif            	
   555 #endif                
   573             }
   556             }
   574             break;
   557             break;
   575         case EPeninputOpLayoutSizeChangedWithSize:
   558         case EPeninputOpLayoutSizeChangedWithSize:
   576                 {
   559                 {
   577                 TPckg<TSize> msgData(iSpriteSize);
   560                 TPckg<TSize> msgData(iSpriteSize);
   591             }
   574             }
   592             break;    
   575             break;    
   593             
   576             
   594 #ifdef RD_TACTILE_FEEDBACK             
   577 #ifdef RD_TACTILE_FEEDBACK             
   595         case EPeninputOpRegisterFeedbackArea:
   578         case EPeninputOpRegisterFeedbackArea:
   596             {						
   579             {                        
   597             GetFeedbackAreaDataL(iTactileControl,msg);            
   580             GetFeedbackAreaDataL(iTactileControl,msg);            
   598             }
   581             }
   599             break;
   582             break;
   600             
   583             
   601         case EPeninputOpDeRegisterFeedbackArea:
   584         case EPeninputOpDeRegisterFeedbackArea:
   607             GetFeedbackAreaDataL(controlarray,msg);
   590             GetFeedbackAreaDataL(controlarray,msg);
   608             
   591             
   609             //remove all registered feedback area
   592             //remove all registered feedback area
   610             const TInt KRemoveAllId = -1;           
   593             const TInt KRemoveAllId = -1;           
   611             if(controlarray.Count() && controlarray[0].iId == KRemoveAllId && 
   594             if(controlarray.Count() && controlarray[0].iId == KRemoveAllId && 
   612 										controlarray[0].iArea == TRect(0,0,0,0))
   595                                         controlarray[0].iArea == TRect(0,0,0,0))
   613                 {
   596                 {
   614                 //remove all
   597                 //remove all
   615                 iTactileControl.Reset();
   598                 iTactileControl.Reset();
   616                 }
   599                 }
   617             else
   600             else
   619                 //remove the area
   602                 //remove the area
   620                 for(TInt i = 0; i < controlarray.Count(); ++i)
   603                 for(TInt i = 0; i < controlarray.Count(); ++i)
   621                     {
   604                     {
   622                     //find id first
   605                     //find id first
   623                     TInt idx = iTactileControl.Find(controlarray[i], 
   606                     TInt idx = iTactileControl.Find(controlarray[i], 
   624 								TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   607                                 TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   625                     
   608                     
   626                     if(idx != KErrNotFound)
   609                     if(idx != KErrNotFound)
   627                         {
   610                         {
   628                         iTactileControl.Remove(idx);                       
   611                         iTactileControl.Remove(idx);                       
   629                         }
   612                         }
   648             //change the area one by one            
   631             //change the area one by one            
   649             for(TInt i = 0; i < controlarray.Count(); ++i)
   632             for(TInt i = 0; i < controlarray.Count(); ++i)
   650                 {
   633                 {
   651                 //find id first
   634                 //find id first
   652                 TInt idx = iTactileControl.Find(controlarray[i], 
   635                 TInt idx = iTactileControl.Find(controlarray[i], 
   653                 		   TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   636                            TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   654                                     
   637                                     
   655                 if(idx != KErrNotFound)
   638                 if(idx != KErrNotFound)
   656                     {
   639                     {
   657                     //check the rect
   640                     //check the rect
   658                     if(prevArea[i] == iTactileControl[idx].iArea)
   641                     if(prevArea[i] == iTactileControl[idx].iArea)
   678             GetFeedbackAreaDataL(controlarray,msg);
   661             GetFeedbackAreaDataL(controlarray,msg);
   679             //change the area one by one
   662             //change the area one by one
   680             for(TInt i = 0; i < controlarray.Count(); ++i)
   663             for(TInt i = 0; i < controlarray.Count(); ++i)
   681                 {
   664                 {
   682                 //find id first
   665                 //find id first
   683                 TInt idx = iTactileControl.Find(controlarray[i],                 		   
   666                 TInt idx = iTactileControl.Find(controlarray[i],                            
   684 						   TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   667                            TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
   685                 if(idx != KErrNotFound)
   668                 if(idx != KErrNotFound)
   686                     {
   669                     {
   687                     //change the tactile feedback type
   670                     //change the tactile feedback type
   688 					iTactileControl[idx].iTactileType = controlarray[i].iTactileType;
   671                     iTactileControl[idx].iTactileType = controlarray[i].iTactileType;
   689                     break;
   672                     break;
   690                     }
   673                     }
   691                 }
   674                 }
   692             
   675             
   693             CleanupStack::PopAndDestroy( 1, &controlarray );
   676             CleanupStack::PopAndDestroy( 1, &controlarray );
   696             break;
   679             break;
   697             
   680             
   698 #endif // RD_TACTILE_FEEDBACK 
   681 #endif // RD_TACTILE_FEEDBACK 
   699         case EPeninputOpRequestDSAState:                        
   682         case EPeninputOpRequestDSAState:                        
   700             {
   683             {
   701 		    TPckgC<TBool> flagMsg(iDSAState);    
   684             TPckgC<TBool> flagMsg(iDSAState);    
   702 			
   685             
   703 			msg->WriteL(KMsgSlot1,flagMsg);
   686             msg->WriteL(KMsgSlot1,flagMsg);
   704             
   687             
       
   688             }
       
   689             break;
       
   690         case EPeninputOpSetDiscreeptPop:
       
   691             {
       
   692             TRect area;
       
   693             TPckg<TRect> msgData(area);
       
   694             msg->ReadL(KMsgSlot1,msgData);
       
   695             SetDiscreeptPop(area); 
   705             }
   696             }
   706             break;
   697             break;
   707         default:
   698         default:
   708             // unsupported opcode, panic the client
   699             // unsupported opcode, panic the client
   709             {                
   700             {                
   721 // Makes PENINPUT window visible
   712 // Makes PENINPUT window visible
   722 // ---------------------------------------------------------------------------
   713 // ---------------------------------------------------------------------------
   723 //
   714 //
   724 void CPeninputAnim::Activate()
   715 void CPeninputAnim::Activate()
   725     {
   716     {
   726 	if(!iIsActive)
   717     if(!iIsActive)
   727 	    {
   718         {
   728 		iSpriteFunctions->SetPosition(iSpritePosition);
   719         iSpriteFunctions->SetPosition(iSpritePosition);
   729 		if(iEnableSprite)
   720         if(iEnableSprite)
   730 		    iSpriteFunctions->Activate(ETrue);
   721             iSpriteFunctions->Activate(ETrue);
   731 		iFunctions->GetRawEvents(ETrue);
   722         iFunctions->GetRawEvents(ETrue);
   732 		iIsActive = ETrue;		
   723         iIsActive = ETrue;        
   733 
   724         }        
   734 		StartTimer();
       
   735 	    }        
       
   736     }
   725     }
   737 
   726 
   738 // ---------------------------------------------------------------------------
   727 // ---------------------------------------------------------------------------
   739 // CPeninputAnim::Deactivate
   728 // CPeninputAnim::Deactivate
   740 // Makes PENINPUT window invisible
   729 // Makes PENINPUT window invisible
   741 // ---------------------------------------------------------------------------
   730 // ---------------------------------------------------------------------------
   742 //
   731 //
   743 void CPeninputAnim::Deactivate()
   732 void CPeninputAnim::Deactivate()
   744     {
   733     {
   745 	if(iIsActive)
   734     if(iIsActive)
   746 	    {
   735         {
   747 	    if(iEnableSprite)
   736         if(iEnableSprite)
   748 		    iSpriteFunctions->Activate(EFalse);
   737             iSpriteFunctions->Activate(EFalse);
   749 		iFunctions->GetRawEvents(EFalse);        
   738         iFunctions->GetRawEvents(EFalse);        
   750 		iIsActive = EFalse;
   739         iIsActive = EFalse;
   751 		
   740         
   752 		StopTimer();
   741         StopTimer();
   753 	    }        
   742         }        
   754     }
   743     }
   755     
   744     
   756 #ifdef RD_TACTILE_FEEDBACK
   745 #ifdef RD_TACTILE_FEEDBACK
   757 // ---------------------------------------------------------------------------
   746 // ---------------------------------------------------------------------------
   758 // CPeninputAnim::DoTactileFeedBack
   747 // CPeninputAnim::DoTactileFeedBack
   759 // Give tactile feedback
   748 // Give tactile feedback
   760 // ---------------------------------------------------------------------------
   749 // ---------------------------------------------------------------------------
   761 //						
   750 //                        
   762 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos)
   751 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos)
   763     {
   752     {
   764     if ( iFeedback ) 
   753     if ( iFeedback ) 
   765         {
   754         {
   766         TInt count = iTactileControl.Count();
   755         TInt count = iTactileControl.Count();
   769             if(iTactileControl[i].iArea.Contains(aPos))
   758             if(iTactileControl[i].iArea.Contains(aPos))
   770                 {
   759                 {
   771                 iFeedback->InstantFeedback((TTouchLogicalFeedback)iTactileControl[i].iTactileType);
   760                 iFeedback->InstantFeedback((TTouchLogicalFeedback)iTactileControl[i].iTactileType);
   772                 return;
   761                 return;
   773                 }                 
   762                 }                 
   774         	}           
   763             }           
   775         }
   764         }
   776     }
   765     }
   777 #endif // RD_TACTILE_FEEDBACK
   766 #endif // RD_TACTILE_FEEDBACK
   778 
   767 
   779 // ---------------------------------------------------------------------------
   768 // ---------------------------------------------------------------------------
   784 // ---------------------------------------------------------------------------
   773 // ---------------------------------------------------------------------------
   785 //
   774 //
   786 
   775 
   787 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent)
   776 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent)
   788     {
   777     {
   789 	if(iIsSimulatedEvent)
   778     if(iIsSimulatedEvent)
   790 	    {
   779         {
   791 		return EFalse;
   780         return EFalse;
   792 	    }
   781         }
   793 		
   782         
   794     if(iDirty )
   783     
   795         {
   784     if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos()))
   796         Refresh();
   785         {
   797         }
   786         iDiscreetPopedCapture = ETrue;
   798     
   787         return EFalse;
   799 	if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos()))
   788         }
   800 		{
   789     TRect rect(iSpritePosition, iSpriteSize);        
   801 		iDiscreetPopedCapture = ETrue;
   790     if(rect.Contains(aRawEvent.Pos()))
   802 		return EFalse;
   791         {                
   803 		}
   792 #ifdef RD_TACTILE_FEEDBACK            
   804 	TRect rect(iSpritePosition, iSpriteSize);        
   793         //give tactile feedback        
   805 	if(rect.Contains(aRawEvent.Pos()))
   794         if(iTactileSupported)
   806 	    {                
       
   807 #ifdef RD_TACTILE_FEEDBACK		    
       
   808 	    //give tactile feedback	    
       
   809 	    if(iTactileSupported)
       
   810             DoTactileFeedBack(aRawEvent.Pos() - rect.iTl);
   795             DoTactileFeedBack(aRawEvent.Pos() - rect.iTl);
   811 #endif // RD_TACTILE_FEEDBACK	
   796 #endif // RD_TACTILE_FEEDBACK    
   812 		iIsPenDown = ETrue;
   797         iIsPenDown = ETrue;
   813 		PostRawEvent(aRawEvent); 
   798 
   814 		return ETrue;
   799         // When button downing event is happened, iIsMove is reset to EFalse
   815 	    }
   800         iIsMove = EFalse;              
   816 
   801 
   817 	if(iIsPointerCaptured)
   802         // Recording pointer that button is pressing down in at this time
   818 	    {                    
   803         iPointerDown = aRawEvent.Pos();  
   819 		PostRawEvent(aRawEvent);
   804         //
   820 		return ETrue;
   805 
   821 	    }
   806         PostRawEvent(aRawEvent); 
   822 
   807         return ETrue;
   823 	//pointer outside of input area,inform layout
   808         }
   824 	SendRawEvent(aRawEvent);
   809 
   825 
   810     if(iIsPointerCaptured)
   826 	return EFalse;
   811         {                    
       
   812         PostRawEvent(aRawEvent);
       
   813         return ETrue;
       
   814         }
       
   815 
       
   816     //pointer outside of input area,inform layout
       
   817     SendRawEvent(aRawEvent);
       
   818 
       
   819     return EFalse;
   827     }
   820     }
   828 
   821 
   829 TBool CPeninputAnim::OnRawButton1Up(const TRawEvent& aRawEvent)
   822 TBool CPeninputAnim::OnRawButton1Up(const TRawEvent& aRawEvent)
   830     {
   823     {
   831 	if(iIsSimulatedEvent)
   824     if(iIsSimulatedEvent)
   832 	    {
   825         {
   833 		return EFalse;
   826         return EFalse;
   834 	    }
   827         }
   835 
   828 
   836 	//For discreetPop
   829     //For discreetPop
   837 	if(iDiscreetPopedCapture )
   830     if(iDiscreetPopedCapture )
   838 		{
   831         {
   839 		iDiscreetPopedCapture = EFalse;
   832         iDiscreetPopedCapture = EFalse;
   840 		return EFalse;
   833         return EFalse;
   841 		}
   834         }
   842 	if(iIsPenDown)
   835     if(iIsPenDown)
   843 	    {      
   836         {      
   844 		iIsPenDown = EFalse;
   837   
   845 		
   838         // When the control key pressing down in is different with the control key pressing up 
   846 		TRect rect(iSpritePosition, iSpriteSize);        
   839         // and pointer moving event isn¡¯t happened,
   847 		if(rect.Contains(aRawEvent.Pos()))
   840         // pointer moving event will is supplied 
   848 		    {
   841         if(iPointerDown != aRawEvent.Pos() && !iIsMove)
   849 			//send pen up event immediately
   842           {
   850 			SendRawEvent(aRawEvent);
   843           TRawEvent rawEvent = aRawEvent;
   851 			return ETrue;                    
   844           rawEvent.Set( TRawEvent::EPointerMove );
   852 		    }
   845           OnRawPointerMove(rawEvent);
   853 	    }
   846           }
   854 	
   847         //
   855 	if(iIsPointerCaptured)
   848 
   856 	    {                    
   849         iIsPenDown = EFalse;
   857 		PostRawEvent(aRawEvent);
   850         
   858 		return ETrue;
   851         TRect rect(iSpritePosition, iSpriteSize);        
   859 	    }
   852         if(rect.Contains(aRawEvent.Pos()))
   860     
   853             {
   861 	//pointer outside of input area,inform layout
   854             //send pen up event immediately
   862 	SendRawEvent(aRawEvent);
   855             SendRawEvent(aRawEvent);
   863 
   856             
   864 	return EFalse;	
   857             // When key pressing up event is completed, iIsMove is reset to EFalse.
       
   858             iIsMove = EFalse;   
       
   859             //
       
   860 
       
   861             return ETrue;                    
       
   862             }
       
   863         }
       
   864     
       
   865     if(iIsPointerCaptured)
       
   866         {                    
       
   867         PostRawEvent(aRawEvent);
       
   868         return ETrue;
       
   869         }
       
   870     
       
   871     //pointer outside of input area,inform layout
       
   872     SendRawEvent(aRawEvent);
       
   873 
       
   874     return EFalse;    
   865     }
   875     }
   866 
   876 
   867 TBool CPeninputAnim::OnRawPointerMove(const TRawEvent& aRawEvent)
   877 TBool CPeninputAnim::OnRawPointerMove(const TRawEvent& aRawEvent)
   868     {
   878     {
   869 	if(iIsSimulatedEvent)
   879     if(iIsSimulatedEvent)
   870 	    {
   880         {
   871 		return EFalse;
   881         return EFalse;
   872 	    }
   882         }
   873 	if(iDiscreetPopedCapture)
   883     if(iDiscreetPopedCapture)
   874 	    {
   884         {
   875 	    return EFalse;
   885         return EFalse;
   876 	    }
   886         }
   877 #ifdef RD_TACTILE_FEEDBACK		    
   887 #ifdef RD_TACTILE_FEEDBACK            
   878 	TRect rect(iSpritePosition, iSpriteSize);        
   888     TRect rect(iSpritePosition, iSpriteSize);        
   879 	if( iIsPenDown && iIsPointerCaptured)
   889     if( iIsPenDown && iIsPointerCaptured)
   880 	    {                
   890         {                
   881 	    //give tactile feedback	    
   891         //give tactile feedback        
   882 
   892         // When pointer moving event is happened, iIsMove is set to ETrue
   883 		PostRawEvent(aRawEvent); 
   893         iIsMove = ETrue;        
   884 		return ETrue;
   894         //
   885 	    }
   895 
   886 #endif // RD_TACTILE_FEEDBACK	
   896         PostRawEvent(aRawEvent); 
   887 
   897         return ETrue;
   888 	if(iIsPointerCaptured || iIsPenDown)
   898         }
   889 	    {                    
   899 #endif // RD_TACTILE_FEEDBACK    
   890 		PostRawEvent(aRawEvent);
   900 
   891 		return ETrue;
   901     if(iIsPointerCaptured || iIsPenDown)
   892 	    }
   902         {                    
   893 	
   903         // When pointer moving event is happened, iIsMove is set to ETrue
   894 	return EFalse;
   904         iIsMove = ETrue;        
       
   905         //
       
   906 
       
   907         PostRawEvent(aRawEvent);
       
   908         return ETrue;
       
   909         }
       
   910     
       
   911     return EFalse;
   895     }
   912     }
   896 
   913 
   897 // ---------------------------------------------------------------------------
   914 // ---------------------------------------------------------------------------
   898 // CPeninputAnim::SetPosition
   915 // CPeninputAnim::SetPosition
   899 // called when sprite has been moved
   916 // called when sprite has been moved
   900 // ---------------------------------------------------------------------------
   917 // ---------------------------------------------------------------------------
   901 //
   918 //
   902 
   919 
   903 TPoint CPeninputAnim::SetPosition(const TPoint& aNewPos)
   920 TPoint CPeninputAnim::SetPosition(const TPoint& aNewPos)
   904     {
   921     {
   905 	if(aNewPos != iSpritePosition)
   922     if(aNewPos != iSpritePosition)
   906 	    {
   923         {
   907 		iSpritePosition = aNewPos;
   924         iSpritePosition = aNewPos;
   908 		iSpriteFunctions->SetPosition(iSpritePosition);	
   925         iSpriteFunctions->SetPosition(iSpritePosition);    
   909 	    }
   926         }
   910 	return iSpritePosition;
   927     return iSpritePosition;
   911     }
   928     }
   912 
   929 
   913 // ---------------------------------------------------------------------------
   930 // ---------------------------------------------------------------------------
   914 // CPeninputAnim::UpdateArea
   931 // CPeninputAnim::UpdateArea
   915 // Update sprite rect
   932 // Update sprite rect
   916 // ---------------------------------------------------------------------------
   933 // ---------------------------------------------------------------------------
   917 //
   934 //
   918 void CPeninputAnim::UpdateArea(const TRect& aRect, TBool aFullUpdate)
   935 void CPeninputAnim::UpdateArea(const TRect& aRect, TBool aFullUpdate)
   919     {
   936     {
   920 	if(iIsActive)
   937     if(iIsActive)
   921         {
   938         {
   922 	    // if function is called without specifying the parameter aRect
   939         // if function is called without specifying the parameter aRect
   923 	    // (using default param value) the whole area drawn to is updated
   940         // (using default param value) the whole area drawn to is updated
   924 	    iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate);
   941         iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate);
   925         }
   942         }
   926     }
   943     }
   927 
   944 
   928 // ---------------------------------------------------------------------------
   945 // ---------------------------------------------------------------------------
   929 // CPeninputAnim::TimerCallBack
   946 // CPeninputAnim::TimerCallBack
   959 void CPeninputAnim::PostRawEvent(const TRawEvent& aRawEvent)
   976 void CPeninputAnim::PostRawEvent(const TRawEvent& aRawEvent)
   960     {
   977     {
   961     if(iEventBuffer.iNum >= KMaxEvent)
   978     if(iEventBuffer.iNum >= KMaxEvent)
   962         {
   979         {
   963         FlushRawEventBuffer();
   980         FlushRawEventBuffer();
   964 	    }
   981         }
   965 	
   982     
   966     iEventBuffer.iEvent[iEventBuffer.iNum] = aRawEvent;
   983     iEventBuffer.iEvent[iEventBuffer.iNum] = aRawEvent;
   967     iEventBuffer.iNum++;
   984     iEventBuffer.iNum++;
   968     }
   985     }
   969 
   986 
   970 // ---------------------------------------------------------------------------
   987 // ---------------------------------------------------------------------------
   972 // Send pointer event to pen input serrver, and return error code
   989 // Send pointer event to pen input serrver, and return error code
   973 // ---------------------------------------------------------------------------
   990 // ---------------------------------------------------------------------------
   974 //
   991 //
   975 TInt CPeninputAnim::FlushRawEventBuffer()
   992 TInt CPeninputAnim::FlushRawEventBuffer()
   976     {
   993     {
   977 	TInt ret = KErrNone;
   994     TInt ret = KErrNone;
   978 	
   995     
   979     if(iEventBuffer.iNum > 0)
   996     if(iEventBuffer.iNum > 0)
   980 	    {
   997         {
   981         ret = iMsgBufQueue.Send(iEventBuffer);
   998         ret = iMsgBufQueue.Send(iEventBuffer);
   982        	iEventBuffer.iNum = 0;        	
   999            iEventBuffer.iNum = 0;            
   983         }
  1000         }
   984     
  1001     
   985     return ret;
  1002     return ret;
   986     }
  1003     }
   987 
  1004 
   991 // Wait until it's processed or timer out
  1008 // Wait until it's processed or timer out
   992 // ---------------------------------------------------------------------------
  1009 // ---------------------------------------------------------------------------
   993 //    
  1010 //    
   994 TBool CPeninputAnim::OnRawKeyEvent(const TRawEvent& aRawEvent)
  1011 TBool CPeninputAnim::OnRawKeyEvent(const TRawEvent& aRawEvent)
   995     {
  1012     {
   996 	TInt ret = KErrNone;
  1013     TInt ret = KErrNone;
   997 	
  1014     
   998 	//first sends all buffered event out
  1015     //first sends all buffered event out
   999     FlushRawEventBuffer();
  1016     FlushRawEventBuffer();
  1000     
  1017     
  1001     //clear the signal and the response msg queue
  1018     //clear the signal and the response msg queue
  1002     TBool isHandled = EFalse;
  1019     TBool isHandled = EFalse;
  1003     ret = iKeyMsgResponseQueue.Receive(isHandled);
  1020     ret = iKeyMsgResponseQueue.Receive(isHandled);
  1004     while(ret == KErrNone)
  1021     while(ret == KErrNone)
  1005 	    {
  1022         {
  1006         iResponseQueueSemaphore.Wait();
  1023         iResponseQueueSemaphore.Wait();
  1007         ret = iKeyMsgResponseQueue.Receive(isHandled);
  1024         ret = iKeyMsgResponseQueue.Receive(isHandled);
  1008         }
  1025         }
  1009 
  1026 
  1010 	//send the event directly        
  1027     //send the event directly        
  1011     iEventBuffer.iNum = 1;
  1028     iEventBuffer.iNum = 1;
  1012     iEventBuffer.iEvent[0] = aRawEvent;
  1029     iEventBuffer.iEvent[0] = aRawEvent;
  1013     ret = FlushRawEventBuffer();
  1030     ret = FlushRawEventBuffer();
  1014     
  1031     
  1015     isHandled = EFalse;
  1032     isHandled = EFalse;
  1016     if(ret == KErrNone) 
  1033     if(ret == KErrNone) 
  1017         {
  1034         {
  1018 	    //wait for the key event processed.    
  1035         //wait for the key event processed.    
  1019 	    ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime);
  1036         ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime);
  1020 	    if(ret == KErrNone)
  1037         if(ret == KErrNone)
  1021 	        {        
  1038             {        
  1022 	        //read the response from msg queue
  1039             //read the response from msg queue
  1023 	        iKeyMsgResponseQueue.Receive(isHandled);
  1040             iKeyMsgResponseQueue.Receive(isHandled);
  1024 	        }
  1041             }
  1025         }
  1042         }
  1026 
  1043 
  1027     return isHandled;
  1044     return isHandled;
  1028     }
  1045     }
  1029 
  1046 
  1032 // Initial and start timer
  1049 // Initial and start timer
  1033 // ---------------------------------------------------------------------------
  1050 // ---------------------------------------------------------------------------
  1034 // 
  1051 // 
  1035 void CPeninputAnim::StartTimer()
  1052 void CPeninputAnim::StartTimer()
  1036     {
  1053     {
  1037 	iFlushTimer->Start(
  1054     if ( iIsActive && !iFlushTimer->IsActive())
  1038 		KFlushTimerPeriod, 
  1055         {
  1039 		KFlushTimerPeriod, 
  1056         iFlushTimer->Start(
  1040 		TCallBack(FlushTimerCallBack, this));	
  1057             KFlushTimerPeriod, 
  1041     }
  1058             KFlushTimerPeriod, 
  1042 	
  1059             TCallBack(FlushTimerCallBack, this));
       
  1060         }
       
  1061     }
       
  1062     
  1043 // ---------------------------------------------------------------------------
  1063 // ---------------------------------------------------------------------------
  1044 // CPeninputAnim::StopTimer
  1064 // CPeninputAnim::StopTimer
  1045 // Cancel timer
  1065 // Cancel timer
  1046 // ---------------------------------------------------------------------------
  1066 // ---------------------------------------------------------------------------
  1047 // 
  1067 // 
  1048 void CPeninputAnim::StopTimer()
  1068 void CPeninputAnim::StopTimer()
  1049     {
  1069     {
  1050 	iFlushTimer->Cancel();	
  1070     iFlushTimer->Cancel();
       
  1071     FlushRawEventBuffer();
  1051     }
  1072     }
  1052 
  1073 
  1053 #ifdef RD_TACTILE_FEEDBACK
  1074 #ifdef RD_TACTILE_FEEDBACK
  1054 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray,
  1075 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray,
  1055 										 const RMessagePtr2* msg, 
  1076                                          const RMessagePtr2* msg, 
  1056                                          RArray<TRect>* aPrevRectArray)
  1077                                          RArray<TRect>* aPrevRectArray)
  1057     {
  1078     {
  1058     TInt num;
  1079     TInt num;
  1059     TPckg<TInt> numBuf(num);
  1080     TPckg<TInt> numBuf(num);
  1060     msg->ReadL(KMsgSlot1,numBuf);
  1081     msg->ReadL(KMsgSlot1,numBuf);
  1067             
  1088             
  1068     for(TInt i = 0 ; i < num; ++i)
  1089     for(TInt i = 0 ; i < num; ++i)
  1069         {
  1090         {
  1070         //Advanced Tactile feedback REQ417-47932
  1091         //Advanced Tactile feedback REQ417-47932
  1071         aTactileControlArray.Append(TTactileControlInfo(area[i].iId,
  1092         aTactileControlArray.Append(TTactileControlInfo(area[i].iId,
  1072 									area[i].iNewRect,area[i].iTactileType));      
  1093                                     area[i].iNewRect,area[i].iTactileType));      
  1073         //aRectArray.Append(area[i].iNewRect);                
  1094         //aRectArray.Append(area[i].iNewRect);                
  1074         if(aPrevRectArray)
  1095         if(aPrevRectArray)
  1075             aPrevRectArray->Append(area[i].iPrevRect);                    
  1096             aPrevRectArray->Append(area[i].iPrevRect);                    
  1076         }
  1097         }
  1077 
  1098 
  1082 // CPeninputAnim::MatchItemByControlID
  1103 // CPeninputAnim::MatchItemByControlID
  1083 // Compare the Item by ID
  1104 // Compare the Item by ID
  1084 // ---------------------------------------------------------------------------
  1105 // ---------------------------------------------------------------------------
  1085 // 
  1106 // 
  1086 TBool CPeninputAnim::MatchItemByControlID (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
  1107 TBool CPeninputAnim::MatchItemByControlID (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
  1087 	{
  1108     {
  1088 	if (aFirst.iId == aSecond.iId)
  1109     if (aFirst.iId == aSecond.iId)
  1089 		return ETrue;
  1110         return ETrue;
  1090 	return EFalse;
  1111     return EFalse;
  1091 	}
  1112     }
  1092 
  1113 
  1093 // ---------------------------------------------------------------------------
  1114 // ---------------------------------------------------------------------------
  1094 // CPeninputAnim::MatchItemByControlIDAndArea
  1115 // CPeninputAnim::MatchItemByControlIDAndArea
  1095 // Compare the Item by ID and Area
  1116 // Compare the Item by ID and Area
  1096 // ---------------------------------------------------------------------------
  1117 // ---------------------------------------------------------------------------
  1097 // 
  1118 // 
  1098 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
  1119 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
  1099 	{
  1120     {
  1100 	if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
  1121     if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
  1101 		return ETrue;
  1122         return ETrue;
  1102 	return EFalse;
  1123     return EFalse;
  1103 	}
  1124     }
  1104 #endif // RD_TACTILE_FEEDBACK    
  1125 #endif // RD_TACTILE_FEEDBACK    
  1105 TInt CPeninputAnim::DiscreetPopChangeNotification(TAny* aObj)
  1126 
  1106     {
  1127 void CPeninputAnim::SetDiscreeptPop(TRect aArea)
  1107     if (aObj)
  1128     {
  1108         {
  1129     iDiscreetPopArea = aArea;
  1109         static_cast<CPeninputAnim*>(aObj)->HandleDiscreetPopNotification();
       
  1110         return KErrNone;
       
  1111         }
       
  1112     else
       
  1113         {
       
  1114         return KErrArgument;
       
  1115         }
       
  1116     }
       
  1117 
       
  1118 void CPeninputAnim::Refresh()
       
  1119     {
       
  1120     iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
       
  1121     if(iDiscreetPopArea.Size().iWidth > 0)
  1130     if(iDiscreetPopArea.Size().iWidth > 0)
  1122         {
  1131         {
  1123         iDiscreetPoped = ETrue;
  1132         iDiscreetPoped = ETrue;
  1124         }    
  1133         }    
  1125     else
  1134     else
  1126         {
  1135         {
  1127         iDiscreetPoped = EFalse;
  1136         iDiscreetPoped = EFalse;
  1128         iDiscreetPopedCapture = EFalse;
  1137         iDiscreetPopedCapture = EFalse;
  1129         }
  1138         }
  1130     iDirty = EFalse;
       
  1131     }
       
  1132 
       
  1133 void CPeninputAnim::HandleDiscreetPopNotification()
       
  1134     {
       
  1135     iDirty = ETrue;
       
  1136     }
       
  1137     
       
  1138 CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty)
       
  1139     :
       
  1140     CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
       
  1141     {
       
  1142     CActiveScheduler::Add(this);
       
  1143     }
       
  1144 
       
  1145 CSubscriber::~CSubscriber()
       
  1146     {
       
  1147     Cancel();
       
  1148     }
       
  1149 
       
  1150 void CSubscriber::SubscribeL()
       
  1151     {
       
  1152     if (!IsActive())
       
  1153         {
       
  1154         iProperty.Subscribe(iStatus);
       
  1155         SetActive();
       
  1156         }
       
  1157     }
       
  1158 
       
  1159 void CSubscriber::StopSubscribe()
       
  1160     {
       
  1161     Cancel();
       
  1162     }
       
  1163 
       
  1164 void CSubscriber::RunL()
       
  1165     {
       
  1166     if (iStatus.Int() == KErrNone)
       
  1167         {
       
  1168         iCallBack.CallBack();
       
  1169         SubscribeL();
       
  1170         }
       
  1171     }
       
  1172 
       
  1173 void CSubscriber::DoCancel()
       
  1174     {
       
  1175     iProperty.Cancel();
       
  1176     }
  1139     }
  1177 // End of File
  1140 // End of File