|
1 /* |
|
2 * Copyright (c) 2002-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: Key sound window server plug-in class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __AKNANIMKEYSOUND_H__ |
|
19 #define __AKNANIMKEYSOUND_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <w32adll.h> |
|
23 #include <kefprovider.h> |
|
24 |
|
25 // FORWARD DECLARATION |
|
26 class CKefMap; |
|
27 class CAknKeyRotator; |
|
28 class CRepository; |
|
29 class CAknPendingKeyEvent; |
|
30 class CHWRMLight; |
|
31 class MTactileFeedbackServer; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Sound server session. |
|
37 */ |
|
38 class REikSrvSoundServerSession : public RSessionBase |
|
39 { |
|
40 public: // New functions |
|
41 /** |
|
42 * Connects to sound server. |
|
43 * @return error code. |
|
44 */ |
|
45 TInt Connect(); |
|
46 |
|
47 /** |
|
48 * Informs sound server of key press. |
|
49 * @param aKey key pressed. |
|
50 * @param aRepeat ETrue if repeat, EFalse otherwise. |
|
51 * Asynch |
|
52 */ |
|
53 void KeyPressed( TInt aKey, TRequestStatus& aStatus, TBool aRepeat = EFalse ); |
|
54 }; |
|
55 |
|
56 /** |
|
57 * Asynchronous tone player. |
|
58 */ |
|
59 NONSHARABLE_CLASS(CAknAsynchTonePlayer) : public CActive |
|
60 { |
|
61 public: |
|
62 CAknAsynchTonePlayer() : CActive(CActive::EPriorityHigh) |
|
63 { |
|
64 CActiveScheduler::Add(this); |
|
65 iSoundSession.Connect(); |
|
66 } |
|
67 |
|
68 ~CAknAsynchTonePlayer() |
|
69 { |
|
70 iSoundSession.Close(); |
|
71 } |
|
72 |
|
73 void RunL() |
|
74 {} // we could close & null sound session handle here in case error returned.. |
|
75 |
|
76 void DoCancel() |
|
77 {} |
|
78 |
|
79 void KeyPressed( TInt aKey, TBool aRepeat = EFalse ) |
|
80 { |
|
81 if ( (!IsActive() || iStatus != KRequestPending) && iSoundSession.Handle() ) |
|
82 { |
|
83 Cancel(); |
|
84 SetActive(); |
|
85 iSoundSession.KeyPressed(aKey, iStatus, aRepeat); |
|
86 } |
|
87 } |
|
88 |
|
89 REikSrvSoundServerSession iSoundSession; |
|
90 }; |
|
91 |
|
92 /** |
|
93 * Key sound plug-in. |
|
94 */ |
|
95 class CAknAnimKeySound : public CWindowAnim, public MKefProvider |
|
96 { |
|
97 public: // Constructor and destructor |
|
98 /** |
|
99 * Constructor. |
|
100 */ |
|
101 CAknAnimKeySound(); |
|
102 |
|
103 /** |
|
104 * Destructor. |
|
105 */ |
|
106 ~CAknAnimKeySound(); |
|
107 |
|
108 public: // Functions from base classes |
|
109 // From CAnim |
|
110 virtual TInt CommandReplyL( TInt aOpcode, TAny *aArgs ); |
|
111 virtual void Command( TInt aOpcode, TAny *aArgs ); |
|
112 virtual void Animate( TDateTime *aDateTime ); |
|
113 |
|
114 // From CWindowAnim |
|
115 virtual void ConstructL( TAny *aArgs, TBool aHasFocus ); |
|
116 virtual void Redraw(); |
|
117 virtual void FocusChanged( TBool aState ); |
|
118 |
|
119 // From MEventHandler |
|
120 virtual TBool OfferRawEvent( const TRawEvent &aRawEvent ); |
|
121 |
|
122 // From MKefProvider |
|
123 void KefPostRawEvent(const TRawEvent& aRawEvent) const; |
|
124 void KefPostKeyEvent(const TKeyEvent& aKeyEvent) const; |
|
125 void KefGenerateKeySound( TInt aKey ); |
|
126 void KefGenerateFeedback( TUint16 aFeedback ); |
|
127 |
|
128 public: |
|
129 /** |
|
130 * Checks if key code is in blocked. |
|
131 * @param key code to be checked. |
|
132 * @return ETrue if blocked. |
|
133 */ |
|
134 static TBool IsBlockedKeyCode( TInt aScanCode ); |
|
135 |
|
136 /** |
|
137 * Checks if key code is non-blocked. |
|
138 * @param key code to be checked. |
|
139 * @return ETrue if non-blocked. |
|
140 */ |
|
141 static TBool NonBlockedKeyCode( TInt aScanCode ); |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * Checks key and pointer event interaction |
|
147 * @paran aRawEvent Event to be checked |
|
148 * @return ETrue if event should be blocked |
|
149 */ |
|
150 TBool IsBlockedEvent( const TRawEvent &aRawEvent ); |
|
151 |
|
152 /** |
|
153 * Checks key and pointer event interaction |
|
154 * @paran aScanCode Scan code of key pressed |
|
155 * @return ETrue if key event should be handled |
|
156 */ |
|
157 TBool IsAlwaysAcceptedKey( TInt aScanCode ); |
|
158 |
|
159 private: |
|
160 // ETrue if connected to sound server successfully. |
|
161 TBool iConnected; |
|
162 |
|
163 // Key pressed. |
|
164 TInt iKeyPressed; |
|
165 |
|
166 // Key block enabled. |
|
167 TBool iEnableKeyBlock; |
|
168 |
|
169 // If pointer down is received while the lights are out |
|
170 // (this is checked with HWRMLight interface), |
|
171 // this is set to true. The next pointer down sets this |
|
172 // to false. |
|
173 // |
|
174 // When iBlockedPointerDown is true, all pointer events are blocked. |
|
175 // |
|
176 // See TSW Error TSUN-7E9BGR and CR 403-11166. |
|
177 TBool iBlockedPointerDown; |
|
178 |
|
179 // Library for key rotator. |
|
180 RLibrary iRotateLibrary; |
|
181 |
|
182 // Key rotator instance. |
|
183 CAknKeyRotator* iKeyRotator; |
|
184 |
|
185 // Library for KEF. |
|
186 RLibrary iKefLibrary; |
|
187 |
|
188 // Key event map instance. |
|
189 CKefMap* iKeyEventMap; |
|
190 |
|
191 // ETrue if no separate power key (end/power key sends power key events). |
|
192 TBool iFeatureNoPowerKey; |
|
193 |
|
194 // Event delivered down scan code when no power key enabled. |
|
195 TInt iNoPowerKeyScanCode; |
|
196 |
|
197 CAknAsynchTonePlayer* iSoundSession; // to make keytone playing asynch |
|
198 |
|
199 CAknPendingKeyEvent* iPendingEvent; |
|
200 |
|
201 // Extension for window group information. |
|
202 MAnimGeneralFunctionsWindowExtension* iExt; |
|
203 |
|
204 // Pointer event handling ongoing, block key events |
|
205 TBool iBlockKeyEvents; |
|
206 |
|
207 // Key event handling ongoing, block pointer events |
|
208 TBool iBlockPointerEvents; |
|
209 |
|
210 |
|
211 CHWRMLight* iLight; |
|
212 MTactileFeedbackServer* iFeedback; |
|
213 }; |
|
214 |
|
215 #endif // __AKNANIMKEYSOUND_H__ |
|
216 |
|
217 // End of File |