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