textinput/peninputarc/src/peninputserverapp/rpeninputanim.cpp
changeset 0 eb1f2e154e89
child 8 6ceef9a83b1a
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for class RPeninputAnim
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <w32std.h>
       
    21 
       
    22 #include "rpeninputanim.h"
       
    23 #include "peninputcmd.h"
       
    24 #include "peninputcmdparam.h"
       
    25 #include "peninputcmdparamext.h"
       
    26 #include "peninputclientserver.h"
       
    27 
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // RPeninputAnim::RPeninputAnim
       
    34 // Default consturctor to allow RPeninputAnim to be defined
       
    35 // as non pointer member. To properly initialize this class
       
    36 // use the other overload.
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 RPeninputAnim::RPeninputAnim() : RAnim() 
       
    40     {
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // RPeninputAnim::RAnim
       
    45 // Constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 RPeninputAnim::RPeninputAnim(RAnimDll& aDll) : RAnim( aDll )
       
    49     {
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // RPeninputAnim::Construct
       
    54 // Second phase constructor.
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void RPeninputAnim::ConstructL( const RWsSprite& aDevice )
       
    58     {
       
    59     User::LeaveIfError( RAnim::Construct( aDevice, 0, KNullDesC8() ) );
       
    60     FinishConstructionL();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // RPeninputAnim::Activate
       
    65 // send activate command
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void RPeninputAnim::Activate()
       
    69     {
       
    70     CommandReply( EPeninputOpActivate );
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // RPeninputAnim::Deactivate
       
    75 // Send deactive command
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void RPeninputAnim::Deactivate()
       
    79     {
       
    80     CommandReply( EPeninputOpDeactivate );
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // RPeninputAnim::FinishConstructionL
       
    85 // Send finishing construction command
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void RPeninputAnim::FinishConstructionL()
       
    89     {    
       
    90     User::LeaveIfError( CommandReply( EPeninputOpFinishConstructionL) );
       
    91     }
       
    92 
       
    93     
       
    94 // ---------------------------------------------------------------------------
       
    95 // RPeniputAnim::LayoutSizeChangedL
       
    96 // Send size change message
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 TInt RPeninputAnim::LayoutSizeChangedL(const TSize& aSize)
       
   100     {
       
   101     TInt err;
       
   102     TIpcArgs args (TIpcArgs::ENothing,0);        
       
   103     TPckgC<TSize> msg(aSize);
       
   104     
       
   105     args.Set(KMsgSlot1,&msg);
       
   106     err = CommandReply(EPeninputOpLayoutSizeChangedWithSize,KNullDesC8,args);
       
   107     return err;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // RPeniputAnim::SetUiLayoutPos
       
   112 // Get ui layout position
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 TInt RPeninputAnim::SetUiLayoutPos(const TPoint& aPt)
       
   116     {    
       
   117     TPckgC<TPoint> msg(aPt);
       
   118     TIpcArgs args(TIpcArgs::ENothing);     
       
   119     args.Set(KMsgSlot1,&msg);    
       
   120     return CommandReply(EPeninputOpSetLayoutPos,KNullDesC8,args);
       
   121     }   
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // RPeniputAnim::UpdateArea
       
   125 // Update screen
       
   126 // ---------------------------------------------------------------------------
       
   127 //    
       
   128 void RPeninputAnim::UpdateArea(const TRect& aRect,TBool aFullUpdate)    
       
   129     {
       
   130     TPckgC<TBool> flagMsg(aFullUpdate);    
       
   131     TPckgC<TRect> rectMsg(aRect);
       
   132     
       
   133     TIpcArgs args (TIpcArgs::ENothing);        
       
   134     /*TUpdateDataArea s;
       
   135     s.iRect = aRect;
       
   136     s.iUpdateFlag = aFullUpdate;
       
   137     
       
   138     TPckgC<TUpdateDataArea> pkg(s);
       
   139     */
       
   140     args.Set(KMsgSlot1,&rectMsg);
       
   141     args.Set(KMsgSlot2,&flagMsg);
       
   142     
       
   143     //args.Set(KMsgSlot1,&pkg);    
       
   144     CommandReply(EPeninputOpLayoutUpdateArea,KNullDesC8,args);
       
   145     //Command(EPeninputOpLayoutUpdateArea,pkg);    
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // RPeniputAnim::UpdateArea
       
   150 // Update screen
       
   151 // ---------------------------------------------------------------------------
       
   152 //    
       
   153 void RPeninputAnim::UpdateArea(const RArray<TUpdateArea>& aArea)
       
   154     {
       
   155     TInt num = aArea.Count();    
       
   156     TUpdateArea* area = new TUpdateArea[num];
       
   157     
       
   158     if (!area)
       
   159         return;
       
   160 
       
   161     for(TInt i = 0; i < num; ++i)
       
   162         {
       
   163         area[i] = aArea[i];
       
   164         }
       
   165     
       
   166     TPtrC8 areaMsg(reinterpret_cast<const TUint8*>(area), num*sizeof(TUpdateArea));
       
   167     
       
   168     TIpcArgs args (TIpcArgs::ENothing);        
       
   169     
       
   170     TPckgC<TInt> numMsg(num);    
       
   171     args.Set(KMsgSlot1,&numMsg);
       
   172     args.Set(KMsgSlot2,&areaMsg);
       
   173     
       
   174     //args.Set(KMsgSlot1,&pkg);    
       
   175     CommandReply(EPeninputOpLayoutUpdateAreaRegion, KNullDesC8, args);
       
   176     
       
   177     delete []area;
       
   178     }
       
   179     
       
   180 // ---------------------------------------------------------------------------
       
   181 // RPeniputAnim::CapturePointer
       
   182 // Inform pen input animation dll to capture the pointer
       
   183 // ---------------------------------------------------------------------------
       
   184 //      
       
   185 void RPeninputAnim::CapturePointer(TBool aFlag, TInt aCaptureCtrlID)
       
   186     {
       
   187     TIpcArgs args (TIpcArgs::ENothing);        
       
   188     TPckgC<TBool> msgCaptureFlagData(aFlag);
       
   189     TPckgC<TInt> msgCaptureCtrlIDData(aCaptureCtrlID);
       
   190     args.Set(KMsgSlot1,&msgCaptureFlagData);
       
   191     args.Set(KMsgSlot2,&msgCaptureCtrlIDData);
       
   192     //Command(EPeninputOpCapturePointer,msgData);            
       
   193     CommandReply(EPeninputOpCapturePointer,KNullDesC8,args);
       
   194     }    
       
   195     
       
   196 // ---------------------------------------------------------------------------
       
   197 // RPeniputAnim::SimulateEvent
       
   198 // ---------------------------------------------------------------------------
       
   199 //      
       
   200 void RPeninputAnim::SimulateEvent(const TRawEvent& aEvent)
       
   201     {
       
   202     TIpcArgs args (TIpcArgs::ENothing);        
       
   203     TPckgC<TRawEvent> msgData(aEvent);
       
   204     args.Set(KMsgSlot1,&msgData);
       
   205     CommandReply(EPeninputOpSimulateEvent,KNullDesC8,args);
       
   206     //Command(EPeninputOpSimulateEvent,msgData);            
       
   207     }        
       
   208 
       
   209 #ifdef RD_TACTILE_FEEDBACK     
       
   210 // ---------------------------------------------------------------------------
       
   211 // RPeniputAnim::DoFeedbackAreaOpL
       
   212 // ---------------------------------------------------------------------------
       
   213 //       
       
   214 void RPeninputAnim::DoFeedbackAreaOpL(const TTactileFeedbackArea* aArea, 
       
   215                                               TInt aCount,TPeninputOpcodes aOp)
       
   216     {    
       
   217     for(TInt i = 0 ; i < aCount; ++i)
       
   218         {
       
   219         TTactileFeedbackArea oneArea = aArea[i];
       
   220         TPckgC<TTactileFeedbackArea> msgData(oneArea);
       
   221         Command(aOp,msgData);        
       
   222         }        
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // RPeniputAnim::DoFeedbackAreaOpReplyL
       
   227 // ---------------------------------------------------------------------------
       
   228 //       
       
   229 void RPeninputAnim::DoFeedbackAreaOpReplyL(const TTactileFeedbackArea* aArea, 
       
   230                                               TInt aCount,TPeninputOpcodes aOp)
       
   231     {    
       
   232     TIpcArgs args (TIpcArgs::ENothing);           
       
   233     TPckgC<TInt> areaNum(aCount);        
       
   234     args.Set(KMsgSlot1,&areaNum);
       
   235     
       
   236     TInt memByteLen = aCount*sizeof(TTactileFeedbackArea);
       
   237     
       
   238     TUint8 *buf = new(ELeave) TUint8[memByteLen];
       
   239     
       
   240     TTactileFeedbackArea *areaBuf = reinterpret_cast<TTactileFeedbackArea *>(buf);
       
   241     for(TInt i = 0; i < aCount; ++i)
       
   242         {
       
   243         areaBuf[i] = aArea[i];
       
   244         }
       
   245         
       
   246     TPtrC msgData(reinterpret_cast<TUint16*>(buf),memByteLen/2);
       
   247 
       
   248     args.Set(KMsgSlot2,&msgData);  
       
   249     
       
   250     CommandReply(aOp,KNullDesC8,args);
       
   251     delete []buf;
       
   252 
       
   253     }
       
   254 
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // RPeniputAnim::AddFeedbackAreaL
       
   258 // ---------------------------------------------------------------------------
       
   259 //       
       
   260 void RPeninputAnim::AddFeedbackAreaL(const TTactileFeedbackArea* aArea, 
       
   261                                               TInt aCount,TBool aReplyFlag)
       
   262     {
       
   263     if(aReplyFlag)
       
   264         DoFeedbackAreaOpReplyL(aArea,aCount,EPeninputOpRegisterFeedbackArea);    
       
   265     else
       
   266         DoFeedbackAreaOpL(aArea,aCount,EPeninputOpRegisterFeedbackArea);    
       
   267     }
       
   268     
       
   269 // ---------------------------------------------------------------------------
       
   270 // RPeniputAnim::RemoveFeedbackAreaL
       
   271 // ---------------------------------------------------------------------------
       
   272 //           
       
   273 void RPeninputAnim::RemoveFeedbackAreaL(const TTactileFeedbackArea* aArea,
       
   274                                              TInt aCount,TBool aReplyFlag)
       
   275     {
       
   276     if(aReplyFlag)
       
   277         DoFeedbackAreaOpReplyL(aArea,aCount,EPeninputOpDeRegisterFeedbackArea);    
       
   278     else
       
   279         DoFeedbackAreaOpL(aArea,aCount,EPeninputOpDeRegisterFeedbackArea);        
       
   280     }    
       
   281     
       
   282 // ---------------------------------------------------------------------------
       
   283 // RPeniputAnim::ChangeFeedbackAreaL
       
   284 // ---------------------------------------------------------------------------
       
   285 //               
       
   286 void RPeninputAnim::ChangeFeedbackAreaL(const TTactileFeedbackArea* aArea, 
       
   287                                              TInt aCount,TBool aReplyFlag)
       
   288     {
       
   289     if(aReplyFlag)
       
   290         DoFeedbackAreaOpReplyL(aArea,aCount,EPeninputOpChangeFeedbackArea);    
       
   291     else
       
   292         DoFeedbackAreaOpL(aArea,aCount,EPeninputOpChangeFeedbackArea);    
       
   293     }   
       
   294 // ---------------------------------------------------------------------------
       
   295 // RPeniputAnim::ChangeFeedbackTypeL
       
   296 // ---------------------------------------------------------------------------
       
   297 // 
       
   298 void RPeninputAnim::ChangeFeedbackTypeL(const TTactileFeedbackArea* aArea, 
       
   299 											 TInt aCount,TBool aReplyFlag)
       
   300 	{
       
   301     if(aReplyFlag)
       
   302         DoFeedbackAreaOpReplyL(aArea,aCount,EPeninputOpChangeFeedbackType);    
       
   303     else
       
   304         DoFeedbackAreaOpL(aArea,aCount,EPeninputOpChangeFeedbackType);
       
   305 	}
       
   306 
       
   307 #endif // RD_TACTILE_FEEDBACK 
       
   308     
       
   309 void RPeninputAnim::EnableSprite(TBool aFlag)
       
   310     {
       
   311     TPckgC<TBool> msgData(aFlag);
       
   312     Command(EPeninputOpEnalbeSprite,msgData);
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // RPeniputAnim::GetDSAState
       
   317 // ---------------------------------------------------------------------------
       
   318 //      
       
   319 void RPeninputAnim::GetDSAState(TBool& aState)
       
   320     {
       
   321     TIpcArgs args (TIpcArgs::ENothing);        
       
   322     TPckg<TBool> msgData(aState);
       
   323     args.Set(KMsgSlot1,&msgData);
       
   324     CommandReply(EPeninputOpRequestDSAState,KNullDesC8,args);
       
   325     //Command(EPeninputOpSimulateEvent,msgData);            
       
   326     }        
       
   327     
       
   328 // End of File