piprofiler/plugins/BUPplugin/src/TouchEventAnimDll.cpp
branchRCL_3
changeset 13 da2cedce4920
equal deleted inserted replaced
12:d27dfa8884ad 13:da2cedce4920
       
     1 /*
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <e32cons.h>
       
    22 #include <w32std.h>
       
    23 #include <in_sock.h>
       
    24 #include <txtfrmat.h>
       
    25 #include <e32property.h>
       
    26 #include <piprofiler/ProfilerTraces.h>
       
    27 
       
    28 // user includes
       
    29 #include "TouchEventAnimDll.h"
       
    30 
       
    31 // control commands
       
    32 static const TInt KActivate   = 70002;
       
    33 static const TInt KDeactivate = 70003;
       
    34 
       
    35 // touch events
       
    36 static const TInt KTouchEventDown = 69999;
       
    37 static const TInt KTouchEventUp = 70000;
       
    38 
       
    39 static const TInt KUpEventOffset = 70000;
       
    40 
       
    41 _LIT( KTouchEventServer, "PIProfilerTouchEvent server" );
       
    42 enum TAnimationPanics
       
    43     {
       
    44     EProfilerTouchEventServerPanic = 100
       
    45     };
       
    46 
       
    47 const TUid KProfilerKeyEventPropertyCat={0x2001E5AD};
       
    48 enum TProfilerKeyEventPropertyKeys
       
    49 	{
       
    50 	EProfilerKeyEventPropertySample = 7
       
    51 	};
       
    52 
       
    53 /*
       
    54 *
       
    55 * Implementation of CProfilerTouchEventAnim
       
    56 *
       
    57 */
       
    58 CProfilerTouchEventAnim::CProfilerTouchEventAnim() : iState(EFalse)
       
    59     {
       
    60 	LOGTEXT(_L("CProfilerTouchEventAnim::CProfilerTouchEventAnim - entry"));
       
    61     }
       
    62 
       
    63 CProfilerTouchEventAnim::~CProfilerTouchEventAnim()
       
    64     {
       
    65 	LOGTEXT(_L("CProfilerTouchEventAnim::~CProfilerTouchEventAnim - entry"));
       
    66 	//iFunctions->GetRawEvents( EFalse );	// disable capture
       
    67 	LOGTEXT(_L("CProfilerTouchEventAnim::~CProfilerTouchEventAnim - exit"));
       
    68     }
       
    69 
       
    70 void CProfilerTouchEventAnim::ConstructL(TAny* /*aArgs*/, TBool /*aHasFocus*/)
       
    71     {
       
    72 	LOGTEXT(_L("CProfilerTouchEventAnim::ConstructL - entry"));
       
    73     iFunctions->GetRawEvents( ETrue );
       
    74 	LOGTEXT(_L("CProfilerTouchEventAnim::ConstructL - exit"));
       
    75     }
       
    76 
       
    77 void CProfilerTouchEventAnim::Command(TInt /*aOpcode*/, TAny* /*aArgs*/)
       
    78     {
       
    79 
       
    80     }
       
    81 
       
    82 TInt CProfilerTouchEventAnim::CommandReplyL(TInt aOpcode, TAny* /*aArgs*/)
       
    83     {
       
    84 	LOGSTRING2("CProfilerTouchEventAnim::CommandReplyL - entry, aOpcode: %d", aOpcode);
       
    85 	switch(aOpcode)
       
    86 	    {
       
    87 		case KActivate:	// activate
       
    88 			iState = ETrue;
       
    89 			LOGTEXT(_L("CProfilerTouchEventAnim::CommandReplyL - activate"));
       
    90 			break;
       
    91 		case KDeactivate: // deactivate
       
    92 			iState = EFalse;
       
    93 			iFunctions->GetRawEvents( EFalse );	// disable capture
       
    94 			LOGTEXT(_L("CProfilerTouchEventAnim::CommandReplyL - deactivate"));
       
    95 			break;
       
    96 		default:
       
    97 			User::Panic( KTouchEventServer, EProfilerTouchEventServerPanic );
       
    98 			LOGSTRING2("CProfilerTouchEventAnim::CommandReplyL - panic, code %d", EProfilerTouchEventServerPanic);
       
    99 			return EProfilerTouchEventServerPanic;
       
   100 
       
   101         }
       
   102 	return KErrNone;
       
   103     }
       
   104 
       
   105 
       
   106 TBool CProfilerTouchEventAnim::OfferRawEvent(const TRawEvent& aRawEvent)
       
   107     {
       
   108 	LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - entry"));
       
   109 	if(iState == EFalse)
       
   110 		return EFalse; // if not activated yet just pass through
       
   111 	
       
   112 
       
   113 	switch(aRawEvent.Type())
       
   114 	    {
       
   115         // handle the pointer events here
       
   116         case TRawEvent::EButton1Down:
       
   117             {
       
   118             LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - pointer down"));
       
   119             return HandlePointerDown(aRawEvent.Pos());
       
   120             }
       
   121         case TRawEvent::EButton1Up:
       
   122             {
       
   123             LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - pointer up"));
       
   124             return HandlePointerUp(aRawEvent.Pos());
       
   125             }
       
   126                 
       
   127             // handle the key events here, replacing the BUP trace functionality
       
   128         case TRawEvent::EKeyDown:
       
   129             {
       
   130             TInt scan = aRawEvent.ScanCode() & 0xFFFF;
       
   131                     return HandleKeyDown(scan);
       
   132             }
       
   133         case TRawEvent::EKeyUp:
       
   134             {
       
   135             TInt scan = (aRawEvent.ScanCode() & 0xFFFF)+KUpEventOffset;	// 
       
   136                     return HandleKeyUp(scan);
       
   137             }
       
   138             default:
       
   139                 return EFalse;	// no action
       
   140         }
       
   141     }
       
   142 
       
   143 TBool CProfilerTouchEventAnim::HandlePointerDown( TPoint /*aPoint*/ )
       
   144     {
       
   145 	RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, KTouchEventDown);
       
   146 	return EFalse;
       
   147     }
       
   148 
       
   149 TBool CProfilerTouchEventAnim::HandlePointerUp( TPoint /*aPoint*/ )
       
   150     {
       
   151 	RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, KTouchEventUp);
       
   152 	return EFalse;
       
   153     }
       
   154 
       
   155 TBool CProfilerTouchEventAnim::HandleKeyDown( TInt aScanCode )
       
   156     {
       
   157 	LOGSTRING2("CProfilerTouchEventAnim::HandleKeyDown - scancode = %d", aScanCode);
       
   158 	RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, aScanCode);
       
   159 	return EFalse;
       
   160     }
       
   161 
       
   162 TBool CProfilerTouchEventAnim::HandleKeyUp( TInt aScanCode )
       
   163     {
       
   164 	LOGSTRING2("CProfilerTouchEventAnim::HandleKeyUp - scancode = %d", aScanCode);
       
   165 	RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, aScanCode);
       
   166 	return EFalse;
       
   167     }
       
   168 
       
   169 
       
   170 void CProfilerTouchEventAnim::Animate(TDateTime* /*aDateTime*/)
       
   171     {
       
   172     }
       
   173 
       
   174 void CProfilerTouchEventAnim::Redraw()
       
   175     {
       
   176     }
       
   177 
       
   178 void CProfilerTouchEventAnim::FocusChanged(TBool /*aState*/)
       
   179     {
       
   180     }
       
   181 
       
   182 
       
   183 /*
       
   184 *
       
   185 * Implementation of CProfilerTouchEventAnimDll
       
   186 *
       
   187 */
       
   188 CProfilerTouchEventAnimDll::CProfilerTouchEventAnimDll() : CAnimDll()
       
   189     {
       
   190     }
       
   191 
       
   192 CAnim* CProfilerTouchEventAnimDll::CreateInstanceL(TInt /*aType*/)
       
   193     {
       
   194 	LOGTEXT(_L("CProfilerTouchEventAnimDll::CreateInstanceL - entry"));
       
   195 	return (new (ELeave) CProfilerTouchEventAnim());
       
   196     }
       
   197 
       
   198 
       
   199 // DLL entry
       
   200 EXPORT_C CAnimDll* CreateCAnimDllL()
       
   201     {
       
   202 	return (new (ELeave) CProfilerTouchEventAnimDll);
       
   203     }
       
   204 
       
   205