|
1 /* |
|
2 * Copyright (c) 2005-2006 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: CPeninputAnim & CPeninputAnimDll from peninputanim.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CPENINPUTANIMDLL_H |
|
21 #define C_CPENINPUTANIMDLL_H |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <w32adll.h> // for CSpriteAnim and CAnimDll |
|
26 #include <e32msgqueue.h> |
|
27 #include <e32property.h> |
|
28 #include <akncapserverclient.h> |
|
29 |
|
30 #include "peninputmsgqueue.h" |
|
31 |
|
32 class CSubscriber; |
|
33 #include "peninputcmdparamext.h" |
|
34 /** |
|
35 * Animation DLL creation class. |
|
36 * |
|
37 * |
|
38 * @since S60 v4.0 |
|
39 */ |
|
40 class CPeninputAnimDll : public CAnimDll |
|
41 { |
|
42 public: |
|
43 //from base class CAnimDll |
|
44 |
|
45 /** |
|
46 * From CAnimDll |
|
47 * Create instance |
|
48 * |
|
49 * @since S60 v4.0 |
|
50 * @param aType Identifies an animation class to be constructed |
|
51 */ |
|
52 CAnim *CreateInstanceL(TInt aType); |
|
53 }; |
|
54 //end of class CPeninputAnimDll |
|
55 |
|
56 //Advanced Tactile feedback REQ417-47932 |
|
57 struct TTactileControlInfo |
|
58 { |
|
59 TInt iId; |
|
60 TRect iArea; |
|
61 TInt iTactileType; |
|
62 |
|
63 TTactileControlInfo(TInt aId, TRect aArea, TInt aTactileType) |
|
64 { |
|
65 iId = aId; |
|
66 iArea = aArea; |
|
67 iTactileType = aTactileType; |
|
68 } |
|
69 }; |
|
70 |
|
71 class MTactileFeedbackServer; |
|
72 |
|
73 // Modify for bug ETMA-7X2C5Y begin |
|
74 class CPenPointerEventSuppressor; |
|
75 // Modify for bug ETMA-7X2C5Y end |
|
76 /** |
|
77 * CPeninputAnim |
|
78 * |
|
79 * CSpriteAnim derived class handling the semi-transparent UI of the PENINPUT. |
|
80 * |
|
81 * @since S60 v4.0 |
|
82 */ |
|
83 class CPeninputAnim : public CSpriteAnim |
|
84 { |
|
85 public: |
|
86 // Constructors and destructor |
|
87 /** |
|
88 * Constructor |
|
89 * |
|
90 * @since S60 v4.0 |
|
91 */ |
|
92 CPeninputAnim(); |
|
93 /** |
|
94 * Destructor. Frees all used resources. |
|
95 * |
|
96 * @since S60 v4.0 |
|
97 */ |
|
98 virtual ~CPeninputAnim(); |
|
99 |
|
100 // from base class MEventHandler |
|
101 |
|
102 /** |
|
103 * From MEventHandler. |
|
104 * Handles the raw events received from the window server |
|
105 * |
|
106 * @since S60 v4.0 |
|
107 * @param aRawEvent description of the event |
|
108 * @return ETrue if event was handled by this function, EFalse otherwise |
|
109 */ |
|
110 TBool OfferRawEvent(const TRawEvent &aRawEvent); |
|
111 |
|
112 //from base class CAnim |
|
113 |
|
114 /** |
|
115 * From CAnim. |
|
116 * 2nd phrase constructor |
|
117 * |
|
118 * @since S60 v4.0 |
|
119 * @param aArgs Construct data |
|
120 */ |
|
121 void ConstructL(TAny *aArgs); |
|
122 |
|
123 /** |
|
124 * From CAnim. |
|
125 * Main animation function called by the window server. |
|
126 * |
|
127 * @since S60 v4.0 |
|
128 * @param aDateTime time. See CAnim::Animate |
|
129 */ |
|
130 void Animate(TDateTime *aDateTime); |
|
131 |
|
132 /** |
|
133 * From CAnim. |
|
134 * The window server calls this function in response to application |
|
135 * call to the client side command function RAnim::Command() |
|
136 * |
|
137 * @since S60 v4.0 |
|
138 * @param aOpCode command code |
|
139 * @param aArgs command data |
|
140 */ |
|
141 void Command(TInt aOpcode, TAny *aArgs); |
|
142 |
|
143 /** |
|
144 * From CAnim. |
|
145 * The window server calls this function in response to application call |
|
146 * to the client side command function RAnim::CommandReplyL(). |
|
147 * |
|
148 * @since S60 v4.0 |
|
149 * @param aOpCode command code |
|
150 * @param aArgs command data |
|
151 * @return KErrNone if command handled correctly. |
|
152 */ |
|
153 TInt CommandReplyL(TInt aOpcode, TAny *aArgs); |
|
154 |
|
155 /** |
|
156 * From CAnim. |
|
157 */ |
|
158 void HandleNotification(const TWsEvent& aEvent); |
|
159 private: |
|
160 |
|
161 /** |
|
162 * Makes PENINPUT window visible |
|
163 * |
|
164 * @since S60 v4.0 |
|
165 */ |
|
166 void Activate(); |
|
167 |
|
168 /** |
|
169 * Makes PENINPUT window invisible |
|
170 * |
|
171 * @since S60 v4.0 |
|
172 */ |
|
173 void Deactivate(); |
|
174 |
|
175 |
|
176 /** |
|
177 * Sets new sprite position. |
|
178 * |
|
179 * @since S60 v4.0 |
|
180 * @param aNewPos The new sprite position |
|
181 * @return Current position |
|
182 */ |
|
183 TPoint SetPosition(const TPoint& aNewPos); |
|
184 |
|
185 /** |
|
186 * Update screen |
|
187 * |
|
188 * @since S60 v4.0 |
|
189 * @param aRect The rect to be updated |
|
190 * @param aFullUpdate Flag tells whether whole sprite neeeds updating |
|
191 */ |
|
192 void UpdateArea(const TRect& aRect,TBool aFullUpdate); |
|
193 |
|
194 /** |
|
195 * Send event to pen input server. Usually it's buffered in the msg queue |
|
196 * |
|
197 * @since S60 v4.0 |
|
198 * @param aRawEvent the event to be sent |
|
199 */ |
|
200 void SendRawEvent(const TRawEvent &aRawEvent); |
|
201 |
|
202 /** |
|
203 * Initial and start timer |
|
204 */ |
|
205 void StartTimer(); |
|
206 |
|
207 /** |
|
208 * Cancel timer |
|
209 */ |
|
210 void StopTimer(); |
|
211 |
|
212 /** |
|
213 * Process raw event, if handled retrun ETrue, or EFalse |
|
214 * |
|
215 * @since S60 v4.0 |
|
216 * @param aRawEvent the event to be processed |
|
217 * @return ETrue if the event is handled. |
|
218 */ |
|
219 TBool OnRawKeyEvent(const TRawEvent& aRawEvent); |
|
220 TBool OnRawButton1Down(const TRawEvent& aRawEvent); |
|
221 TBool OnRawButton1Up(const TRawEvent& aRawEvent); |
|
222 TBool OnRawPointerMove(const TRawEvent& aRawEvent); |
|
223 |
|
224 /** |
|
225 * Send all events in the buffer to the pen input server, and empty event buffer. |
|
226 * |
|
227 * @since S60 v4.0 |
|
228 */ |
|
229 TInt FlushRawEventBuffer(); |
|
230 |
|
231 /** |
|
232 * Timer call back function for periodic timer. |
|
233 * |
|
234 * @since S60 v4.0 |
|
235 * @param aPtr The data sends to callback function |
|
236 * @return KErrNone if no error. |
|
237 */ |
|
238 static TInt FlushTimerCallBack(TAny *aPtr); |
|
239 |
|
240 /** |
|
241 * Save event to buffer. The event is sent to pen input server when |
|
242 * buffer overflowed. |
|
243 * |
|
244 * @since S60 v4.0 |
|
245 * @param aRawEvent the event to be saved |
|
246 */ |
|
247 void PostRawEvent(const TRawEvent& aRawEvent); |
|
248 |
|
249 #ifdef RD_TACTILE_FEEDBACK |
|
250 /** |
|
251 * Compare two TTactileControlInfo Item. |
|
252 * |
|
253 * @TTactileControlInfo& aFirst |
|
254 * @const TTactileControlInfo& aSecond |
|
255 */ |
|
256 static TBool MatchItemByControlID(const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond); |
|
257 |
|
258 /** |
|
259 * Compare two TTactileControlInfo Item. |
|
260 * |
|
261 * @TTactileControlInfo& aFirst |
|
262 * @const TTactileControlInfo& aSecond |
|
263 */ |
|
264 static TBool MatchItemByControlIDAndArea(const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond); /** |
|
265 |
|
266 * give tactile feedback |
|
267 * |
|
268 * @since S60 v4.0 |
|
269 * @param aPos the event position. It's screen coordinator. |
|
270 */ |
|
271 void DoTactileFeedBack(const TPoint &aPos); |
|
272 #endif // RD_TACTILE_FEEDBACK |
|
273 |
|
274 /** |
|
275 * Panic current client if its request without parameter |
|
276 * |
|
277 * @since S60 v4.0 |
|
278 * @param aParam The param to be checked |
|
279 */ |
|
280 inline void PanicClientIfNoParam(TAny* aParams) |
|
281 { |
|
282 if(!aParams) |
|
283 { |
|
284 iFunctions->Panic(); |
|
285 } |
|
286 } |
|
287 |
|
288 #ifdef RD_TACTILE_FEEDBACK |
|
289 // Advanced Tactile feedback REQ417-47932 |
|
290 void GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray, |
|
291 const RMessagePtr2* msg, |
|
292 RArray<TRect>* aPrevRectArray = NULL); |
|
293 |
|
294 #endif // RD_TACTILE_FEEDBACK |
|
295 |
|
296 void SetDSAState(TBool aFlag); |
|
297 //For discreetPop |
|
298 static TInt DiscreetPopChangeNotification(TAny* aObj); |
|
299 void HandleDiscreetPopNotification(); |
|
300 |
|
301 void Refresh(); |
|
302 private: // Data |
|
303 /** |
|
304 * Current state |
|
305 */ |
|
306 TBool iIsActive; |
|
307 |
|
308 /** |
|
309 * Current position of the sprite |
|
310 */ |
|
311 TPoint iSpritePosition; |
|
312 |
|
313 /** |
|
314 * Current sprite size |
|
315 */ |
|
316 TSize iSpriteSize; |
|
317 |
|
318 /** |
|
319 * Flag tells whether pen input server needs the pointer event |
|
320 */ |
|
321 TBool iIsPointerCaptured; |
|
322 |
|
323 /** |
|
324 * Flag tells whether the pen has been down inside the ui layout |
|
325 */ |
|
326 TBool iIsPenDown; |
|
327 |
|
328 /** |
|
329 * Simulated event flag |
|
330 */ |
|
331 TBool iIsSimulatedEvent; |
|
332 |
|
333 /** |
|
334 * message buffer for pointer and key event. |
|
335 */ |
|
336 RMsgQueue<TRawEventBuffer> iMsgBufQueue; |
|
337 |
|
338 /** |
|
339 * Message buffer for key response. Key event must get the response immediately |
|
340 */ |
|
341 RMsgQueue<TBool> iKeyMsgResponseQueue; |
|
342 |
|
343 /** |
|
344 * Event buffer for pointer. |
|
345 */ |
|
346 TRawEventBuffer iEventBuffer; |
|
347 |
|
348 /** |
|
349 * Semaphore for key handling. |
|
350 */ |
|
351 RSemaphore iResponseQueueSemaphore; |
|
352 |
|
353 /** |
|
354 * Timer to send pointer event to pen input server |
|
355 */ |
|
356 CPeriodic* iFlushTimer; |
|
357 |
|
358 #ifdef RD_TACTILE_FEEDBACK |
|
359 /** |
|
360 * Flag for tactile feedback support |
|
361 */ |
|
362 TBool iTactileSupported; |
|
363 |
|
364 |
|
365 /** |
|
366 * Tactile Feedback instance |
|
367 */ |
|
368 MTactileFeedbackServer* iFeedback; |
|
369 |
|
370 /** |
|
371 * Array of the Control info |
|
372 * Advanced Tactile feedback REQ417-47932 |
|
373 */ |
|
374 RArray<TTactileControlInfo> iTactileControl; |
|
375 |
|
376 /** |
|
377 * Array of the backup Control info |
|
378 * Advanced Tactile feedback REQ417-47932 |
|
379 */ |
|
380 RArray<TTactileControlInfo> iBackupTactileControl; |
|
381 |
|
382 |
|
383 #endif // RD_TACTILE_FEEDBACK |
|
384 TBool iEnableSprite; |
|
385 TBool iDSAState; |
|
386 |
|
387 /** |
|
388 * Pointer event suppressor to improve tap accuracy |
|
389 */ |
|
390 CPenPointerEventSuppressor* iPointerEventSuppressor; |
|
391 |
|
392 /** |
|
393 * Pointer number of primary touch device. |
|
394 * Any pointer event with different pointer number( TRawEvent.PointerNumber() ), |
|
395 * is treated as multi-touch event and will be disabled. |
|
396 */ |
|
397 TUint8 iPrimaryTouchPtNum; |
|
398 |
|
399 /** |
|
400 * Flag to detect primary touch device at startup |
|
401 */ |
|
402 TBool iPrimaryTouchPtDetected; |
|
403 CSubscriber* iDiscreetPopSubscriber; |
|
404 RProperty iDiscreetPopProperty; |
|
405 TBool iDiscreetPoped; |
|
406 TBool iDiscreetPopedCapture; |
|
407 TRect iDiscreetPopArea; |
|
408 RAknUiServer iAknUiSrv; |
|
409 TBool iDirty; |
|
410 }; |
|
411 |
|
412 |
|
413 |
|
414 class CSubscriber : public CActive |
|
415 { |
|
416 public: |
|
417 CSubscriber(TCallBack aCallBack, RProperty& aProperty); |
|
418 ~CSubscriber(); |
|
419 |
|
420 public: // New functions |
|
421 void SubscribeL(); |
|
422 void StopSubscribe(); |
|
423 |
|
424 private: // from CActive |
|
425 void RunL(); |
|
426 void DoCancel(); |
|
427 |
|
428 private: |
|
429 TCallBack iCallBack; |
|
430 RProperty& iProperty; |
|
431 }; |
|
432 #endif //C_CPENINPUTANIMDLL_H |
|
433 // End of File |