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: Functional implentation of key event service. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CKEYEVENTHANDLER_H |
|
20 #define CKEYEVENTHANDLER_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <HtiServicePluginInterface.h> |
|
25 #include <w32std.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * Functional implentation of key event service. |
|
33 */ |
|
34 class CKeyEventHandler : public CActive |
|
35 { |
|
36 public: |
|
37 |
|
38 static CKeyEventHandler* NewL(); |
|
39 |
|
40 // Interface implementation |
|
41 void ProcessMessageL( const TDesC8& aMessage, |
|
42 THtiMessagePriority aPriority ); |
|
43 |
|
44 virtual ~CKeyEventHandler(); |
|
45 |
|
46 void SetDispatcher( MHtiDispatcher* aDispatcher ); |
|
47 |
|
48 enum TError |
|
49 { |
|
50 EMissingCommand = 0x01, |
|
51 EUnrecognizedCommand = 0x02, |
|
52 ENotReadyCommand = 0x03, |
|
53 EInvalidScancode = 0x80, |
|
54 EEmptyUnicodeCharArray = 0x90, |
|
55 EInvalidUnicodeCharArray = 0x91 |
|
56 }; |
|
57 |
|
58 enum TCommand |
|
59 { |
|
60 EPressKey = 0x01, |
|
61 EKeyDown = 0x02, |
|
62 EKeyUp = 0x03, |
|
63 ETypeText = 0x04, |
|
64 ELongKeyPress = 0x05, |
|
65 ETypeTextPassword = 0x06, |
|
66 EPressKeySequence = 0x07, |
|
67 EPointer = 0x10, |
|
68 EResultOk = 0xFF // only for response message |
|
69 }; |
|
70 |
|
71 protected: |
|
72 |
|
73 void RunL(); |
|
74 TInt RunError(TInt aError); |
|
75 void DoCancel(); |
|
76 |
|
77 private: |
|
78 |
|
79 CKeyEventHandler(); |
|
80 void ConstructL(); |
|
81 |
|
82 private: // helpers |
|
83 |
|
84 void HandleTypeTextFuncL( const TDesC8& aUnicodeChars ); |
|
85 void HandleKeyboardFuncL( const TDesC8& aData ); |
|
86 void HandleLongKeyPressFuncL( const TDesC8& aData ); |
|
87 void HandlePressKeySequenceFuncL( const TDesC8& aData ); |
|
88 |
|
89 void SendOkMsgL(); |
|
90 void SendErrorMessageL( TInt aError, const TDesC8& aDescription ); |
|
91 |
|
92 void TypeTextWithDelay( TInt aNextIndex ); |
|
93 void SimulateKeyEventL( const TDesC8& aUnicodeChars, TInt aIndex ); |
|
94 void PressKeySequenceKeyL(); |
|
95 |
|
96 void KeyUp( TUint aCode ); |
|
97 void KeyDown( TUint aCode ); |
|
98 |
|
99 private: |
|
100 |
|
101 RWsSession iWsSession; |
|
102 MHtiDispatcher* iDispatcher; // referenced |
|
103 |
|
104 // Typetext specialities: |
|
105 RTimer iTimer; |
|
106 TInt iFocusedWindowGroup; |
|
107 HBufC8* iUnicodeChars; |
|
108 TInt iUnicodeCharIndex; |
|
109 |
|
110 TBool iReady; |
|
111 TUint8 iCommand; |
|
112 TUint iHoldingScanCode; |
|
113 TTimeIntervalMicroSeconds32 iKeySequenceHoldTime; |
|
114 TTimeIntervalMicroSeconds32 iKeySequenceInterval; |
|
115 TBool iHoldingKey; |
|
116 }; |
|
117 |
|
118 #endif // CKEYEVENTHANDLER_H |
|