First public contribution.
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // HotKey user interface to the PC-sampling Profiler engine in E32utils
22 class CKeys : public CActive, private MProfilerController
26 enum {KAllModifiers = EModifierFunc|EModifierCtrl|EModifierShift};
31 inline void CaptureL(RWindowGroup& aWg, TUint aKey)
32 {iCapture=User::LeaveIfError(aWg.CaptureKey(aKey,KAllModifiers,KAllModifiers));}
33 inline void Release(RWindowGroup& aWg)
34 {if (iCapture != -1) aWg.CancelCaptureKey(iCapture);}
39 IMPORT_C static MProfilerController* NewL(TInt aPriority, MProfilerEngine& aEngine);
41 CKeys(TInt aPriority, MProfilerEngine& aEngine);
64 EXPORT_C MProfilerController* CKeys::NewL(TInt aPriority, MProfilerEngine& aEngine)
66 CKeys* self = new(ELeave) CKeys(aPriority, aEngine);
67 CleanupStack::PushL(self);
73 CKeys::CKeys(TInt aPriority, MProfilerEngine& aEngine)
74 :CActive(aPriority), MProfilerController(aEngine)
76 CActiveScheduler::Add(this);
79 void CKeys::ConstructL()
81 User::LeaveIfError(iWs.Connect());
83 User::LeaveIfError(iWg.Construct(0,EFalse));
84 iWg.AutoForeground(EFalse);
85 iStartKey.CaptureL(iWg, '1');
86 iStopKey.CaptureL(iWg, '2');
87 iCloseKey.CaptureL(iWg, '3');
88 iUnloadKey.CaptureL(iWg, '4');
89 iTestKey.CaptureL(iWg, '0');
96 iStartKey.Release(iWg);
97 iStopKey.Release(iWg);
98 iCloseKey.Release(iWg);
99 iUnloadKey.Release(iWg);
100 iTestKey.Release(iWg);
105 void CKeys::Release()
112 iWs.EventReady(&iStatus);
120 if (ev.Type() == EEventKey)
122 switch (ev.Key()->iCode)
126 _LIT(KTestPrint,"Profiler is ");
127 static const TText* const KStates[] = {_S("running"),_S("waiting"),_S("loaded"),_S("?")};
128 TBuf<60> info(KTestPrint);
129 info.Append(TPtrC(KStates[GetState()]));
130 User::InfoPrint(info);
137 Control(Profiler::TState(ev.Key()->iCode - '1'));
144 void CKeys::DoCancel()
146 iWs.EventReadyCancel();