40 #endif //RD_TACTILE_FEEDBACK |
40 #endif //RD_TACTILE_FEEDBACK |
41 // ----------- Touch feedback additions start |
41 // ----------- Touch feedback additions start |
42 |
42 |
43 #include <avkondomainpskeys.h> |
43 #include <avkondomainpskeys.h> |
44 //CONSTANT |
44 //CONSTANT |
45 const TInt KMsgSlot1 = 1; //msg slot 2 in IPC |
45 const TInt KMsgSlot1 = 1; //msg slot 2 in IPC |
46 const TInt KMsgSlot2 = 2; //msg slot 2 in IPC |
46 const TInt KMsgSlot2 = 2; //msg slot 2 in IPC |
47 const TInt KFlushTimerPeriod = 1000 * 10; //1/100 second |
47 const TInt KFlushTimerPeriod = 1000 * 10; //1/100 second |
48 const TInt KResponseQueueWaitTime = 100000; //1/10 second |
48 const TInt KResponseQueueWaitTime = 100000; //1/10 second |
49 |
49 |
50 // ======== GLOBAL FUNCTIONS ======== |
50 // ======== GLOBAL FUNCTIONS ======== |
51 |
51 |
52 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
53 // CreateCAnimDllL |
53 // CreateCAnimDllL |
81 // Constructor |
81 // Constructor |
82 // --------------------------------------------------------------------------- |
82 // --------------------------------------------------------------------------- |
83 // |
83 // |
84 CPeninputAnim::CPeninputAnim() |
84 CPeninputAnim::CPeninputAnim() |
85 { |
85 { |
86 iIsActive = EFalse; |
86 iIsActive = EFalse; |
87 //iSpritePosition and iSpriteSize are initialized to 0 by default constructor |
87 //iSpritePosition and iSpriteSize are initialized to 0 by default constructor |
88 //iSpritePosition = TPoint(0, 0); |
88 //iSpritePosition = TPoint(0, 0); |
89 //iSpriteSize = TSize(0, 0); |
89 //iSpriteSize = TSize(0, 0); |
90 iIsPointerCaptured = EFalse; |
90 iIsPointerCaptured = EFalse; |
91 iIsPenDown = EFalse; |
91 iIsPenDown = EFalse; |
92 |
92 |
93 iPrimaryTouchPtNum = 0; |
93 iPrimaryTouchPtNum = 0; |
94 iPrimaryTouchPtDetected = EFalse; |
94 iPrimaryTouchPtDetected = EFalse; |
95 |
95 |
96 |
96 |
97 #ifdef RD_TACTILE_FEEDBACK |
97 #ifdef RD_TACTILE_FEEDBACK |
98 TRAPD( err, FeatureManager::InitializeLibL() ); |
98 TRAPD( err, FeatureManager::InitializeLibL() ); |
99 if( err == KErrNone ) |
99 if( err == KErrNone ) |
100 { |
100 { |
101 iTactileSupported = FeatureManager::FeatureSupported( KFeatureIdTactileFeedback ); |
101 iTactileSupported = FeatureManager::FeatureSupported( KFeatureIdTactileFeedback ); |
102 } |
102 } |
103 iFeedback = MTactileFeedbackServer::Instance(); |
103 iFeedback = MTactileFeedbackServer::Instance(); |
104 #endif // RD_TACTILE_FEEDBACK |
104 #endif // RD_TACTILE_FEEDBACK |
105 |
105 |
106 iEnableSprite = ETrue; |
106 iEnableSprite = ETrue; |
107 iDSAState = EFalse; |
107 iDSAState = EFalse; |
108 } |
108 } |
109 |
109 |
110 // --------------------------------------------------------------------------- |
110 // --------------------------------------------------------------------------- |
111 // CPeninputAnim::~CPeninputAnim |
111 // CPeninputAnim::~CPeninputAnim |
112 // Destructor |
112 // Destructor |
113 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
114 // |
114 // |
115 CPeninputAnim::~CPeninputAnim() |
115 CPeninputAnim::~CPeninputAnim() |
116 { |
116 { |
117 Deactivate(); |
117 Deactivate(); |
118 |
118 |
119 iMsgBufQueue.Close(); |
119 iMsgBufQueue.Close(); |
120 iKeyMsgResponseQueue.Close(); |
120 iKeyMsgResponseQueue.Close(); |
121 iResponseQueueSemaphore.Close(); |
121 iResponseQueueSemaphore.Close(); |
122 |
122 |
123 delete iFlushTimer; |
123 delete iFlushTimer; |
124 #ifdef RD_TACTILE_FEEDBACK |
124 #ifdef RD_TACTILE_FEEDBACK |
125 FeatureManager::UnInitializeLib(); |
125 FeatureManager::UnInitializeLib(); |
126 iTactileControl.Close(); |
126 iTactileControl.Close(); |
127 iBackupTactileControl.Close(); |
127 iBackupTactileControl.Close(); |
128 #endif // RD_TACTILE_FEEDBACK |
128 #endif // RD_TACTILE_FEEDBACK |
129 delete iPointerEventSuppressor; |
129 delete iPointerEventSuppressor; |
130 } |
130 } |
131 |
131 |
132 // --------------------------------------------------------------------------- |
132 // --------------------------------------------------------------------------- |
133 // CPeninputAnim::ConstructL |
133 // CPeninputAnim::ConstructL |
134 // Second phase constructor |
134 // Second phase constructor |
135 // --------------------------------------------------------------------------- |
135 // --------------------------------------------------------------------------- |
136 // |
136 // |
137 void CPeninputAnim::ConstructL(TAny* /*aParameters*/) |
137 void CPeninputAnim::ConstructL(TAny* /*aParameters*/) |
138 { |
138 { |
139 // the animation feature is not used |
139 // the animation feature is not used |
140 iFunctions->SetInterval(0); |
140 iFunctions->SetInterval(0); |
141 iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
141 iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
142 |
142 |
143 iFunctions->RegisterForNotifications(EDirectScreenAccess); |
143 iFunctions->RegisterForNotifications(EDirectScreenAccess); |
144 iPointerEventSuppressor = CPenPointerEventSuppressor::NewL(); |
144 iPointerEventSuppressor = CPenPointerEventSuppressor::NewL(); |
145 } |
145 } |
146 |
146 |
147 |
147 |
258 { |
258 { |
259 return ETrue; |
259 return ETrue; |
260 } |
260 } |
261 |
261 |
262 |
262 |
263 switch(aRawEvent.Type()) |
263 switch(aRawEvent.Type()) |
264 { |
264 { |
265 case TRawEvent::EKeyUp: |
265 case TRawEvent::EKeyUp: |
266 case TRawEvent::EKeyDown: |
266 case TRawEvent::EKeyDown: |
267 { |
267 { |
268 return OnRawKeyEvent(aRawEvent); |
268 return OnRawKeyEvent(aRawEvent); |
269 } |
269 } |
270 case TRawEvent::EButton1Down: |
270 case TRawEvent::EButton1Down: |
271 { |
271 { |
272 return OnRawButton1Down(aRawEvent); |
272 TBool used = OnRawButton1Down(aRawEvent); |
273 } |
273 |
274 case TRawEvent::EButton1Up: |
274 if ( used ) |
275 { |
275 { |
276 return OnRawButton1Up(aRawEvent); |
276 StartTimer(); |
277 } |
277 } |
278 case TRawEvent::EPointerMove: |
278 |
279 { |
279 return used; |
280 return OnRawPointerMove(aRawEvent); |
280 } |
281 } |
281 case TRawEvent::EButton1Up: |
282 default: |
282 { |
283 { |
283 TBool used = OnRawButton1Up(aRawEvent); |
284 return EFalse; |
284 StopTimer(); |
285 } |
285 return used; |
286 } |
286 } |
|
287 case TRawEvent::EPointerMove: |
|
288 { |
|
289 return OnRawPointerMove(aRawEvent); |
|
290 } |
|
291 default: |
|
292 { |
|
293 return EFalse; |
|
294 } |
|
295 } |
287 } |
296 } |
288 |
297 |
289 // --------------------------------------------------------------------------- |
298 // --------------------------------------------------------------------------- |
290 // CPeninputAnim::Command |
299 // CPeninputAnim::Command |
291 // The window server calls this function in response to application |
300 // The window server calls this function in response to application |
306 Deactivate(); |
315 Deactivate(); |
307 break; |
316 break; |
308 } |
317 } |
309 case EPeninputOpLayoutUpdateArea: |
318 case EPeninputOpLayoutUpdateArea: |
310 { |
319 { |
311 PanicClientIfNoParam(aParams); |
320 PanicClientIfNoParam(aParams); |
312 TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams); |
321 TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams); |
313 iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag ); |
322 iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag ); |
314 break; |
323 break; |
315 } |
324 } |
316 case EPeninputOpCapturePointer: |
325 case EPeninputOpCapturePointer: |
317 { |
326 { |
318 PanicClientIfNoParam(aParams); |
327 PanicClientIfNoParam(aParams); |
319 iIsPointerCaptured = *(static_cast<TBool*>(aParams)); |
328 iIsPointerCaptured = *(static_cast<TBool*>(aParams)); |
320 break; |
329 break; |
321 } |
330 } |
322 case EPeninputOpSimulateEvent: |
331 case EPeninputOpSimulateEvent: |
323 { |
332 { |
324 PanicClientIfNoParam(aParams); |
333 PanicClientIfNoParam(aParams); |
325 TRawEvent event = *(static_cast<TRawEvent*>(aParams)); |
334 TRawEvent event = *(static_cast<TRawEvent*>(aParams)); |
376 iTactileControl[idx].iArea = area.iNewRect; |
385 iTactileControl[idx].iArea = area.iNewRect; |
377 } |
386 } |
378 } |
387 } |
379 break; |
388 break; |
380 case EPeninputOpChangeFeedbackType: |
389 case EPeninputOpChangeFeedbackType: |
381 { |
390 { |
382 PanicClientIfNoParam(aParams); |
391 PanicClientIfNoParam(aParams); |
383 TTactileFeedbackArea area = *(static_cast<TTactileFeedbackArea*>(aParams)); |
392 TTactileFeedbackArea area = *(static_cast<TTactileFeedbackArea*>(aParams)); |
384 TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType); |
393 TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType); |
385 TInt idx = iTactileControl.Find(controlitem, |
394 TInt idx = iTactileControl.Find(controlitem, |
386 TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID)); |
395 TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID)); |
387 if(idx != KErrNotFound) |
396 if(idx != KErrNotFound) |
388 { |
397 { |
389 //change the tactile type |
398 //change the tactile type |
390 iTactileControl[idx].iTactileType = area.iTactileType; |
399 iTactileControl[idx].iTactileType = area.iTactileType; |
391 } |
400 } |
392 } |
401 } |
393 break; |
402 break; |
394 #endif // RD_TACTILE_FEEDBACK |
403 #endif // RD_TACTILE_FEEDBACK |
395 case EPeninputOpEnalbeSprite: |
404 case EPeninputOpEnalbeSprite: |
396 { |
405 { |
397 PanicClientIfNoParam(aParams); |
406 PanicClientIfNoParam(aParams); |
446 Deactivate(); |
455 Deactivate(); |
447 break; |
456 break; |
448 } |
457 } |
449 |
458 |
450 case EPeninputOpLayoutUpdateArea: |
459 case EPeninputOpLayoutUpdateArea: |
451 { |
460 { |
452 //TUpdateDataArea s; |
461 //TUpdateDataArea s; |
453 //TPckg<TUpdateDataArea> pkg(s); |
462 //TPckg<TUpdateDataArea> pkg(s); |
454 TRect rect; |
463 TRect rect; |
455 TBool flag; |
464 TBool flag; |
456 TPckg<TRect> rectMsg(rect); |
465 TPckg<TRect> rectMsg(rect); |
457 TPckg<TBool> flagMsg(flag); |
466 TPckg<TBool> flagMsg(flag); |
458 |
467 |
459 msg->ReadL(KMsgSlot1,rectMsg); |
468 msg->ReadL(KMsgSlot1,rectMsg); |
460 msg->ReadL(KMsgSlot2,flagMsg); |
469 msg->ReadL(KMsgSlot2,flagMsg); |
461 iSpriteFunctions->UpdateMember(0, rect,flag); |
470 iSpriteFunctions->UpdateMember(0, rect,flag); |
462 } |
471 } |
463 break; |
472 break; |
464 case EPeninputOpLayoutUpdateAreaRegion: |
473 case EPeninputOpLayoutUpdateAreaRegion: |
465 { |
474 { |
466 TInt num; |
475 TInt num; |
467 TPckg<TInt> numMsg(num); |
476 TPckg<TInt> numMsg(num); |
468 msg->ReadL(KMsgSlot1,numMsg); |
477 msg->ReadL(KMsgSlot1,numMsg); |
493 break; |
502 break; |
494 |
503 |
495 case EPeninputOpCapturePointer: |
504 case EPeninputOpCapturePointer: |
496 { |
505 { |
497 TInt captureCtrlID; |
506 TInt captureCtrlID; |
498 TPckg<TBool> msgData(iIsPointerCaptured); |
507 TPckg<TBool> msgData(iIsPointerCaptured); |
499 TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID); |
508 TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID); |
500 |
509 |
501 msg->ReadL(KMsgSlot1,msgData); |
510 msg->ReadL(KMsgSlot1,msgData); |
502 msg->ReadL(KMsgSlot2,msgCaptureCtrlIDData); |
511 msg->ReadL(KMsgSlot2,msgCaptureCtrlIDData); |
503 #ifdef RD_TACTILE_FEEDBACK |
512 #ifdef RD_TACTILE_FEEDBACK |
504 // When pointer is captured by some ctrl, |
513 // When pointer is captured by some ctrl, |
505 // only the captured ctrl has tactile feedback ablity, |
514 // only the captured ctrl has tactile feedback ablity, |
506 // disable all other one's. |
515 // disable all other one's. |
507 if (iIsPointerCaptured) |
516 if (iIsPointerCaptured) |
508 { |
517 { |
509 // Back up all the tactile area |
518 // Back up all the tactile area |
510 iBackupTactileControl.Reset(); |
519 iBackupTactileControl.Reset(); |
511 TInt count = iTactileControl.Count(); |
520 TInt count = iTactileControl.Count(); |
512 for(TInt i = 0; i < count; ++i) |
521 for(TInt i = 0; i < count; ++i) |
513 { |
522 { |
514 iBackupTactileControl.Append(iTactileControl[i]); |
523 iBackupTactileControl.Append(iTactileControl[i]); |
515 } |
524 } |
516 |
525 |
517 // Clean up the original tactile area |
526 // Clean up the original tactile area |
518 iTactileControl.Reset(); |
527 iTactileControl.Reset(); |
519 |
528 |
520 // Find the captured ctrl, restore its tactile ablity |
529 // Find the captured ctrl, restore its tactile ablity |
521 for(TInt i = 0; i < count; ++i) |
530 for(TInt i = 0; i < count; ++i) |
522 { |
531 { |
523 if (iBackupTactileControl[i].iId == captureCtrlID) |
532 if (iBackupTactileControl[i].iId == captureCtrlID) |
524 { |
533 { |
525 iTactileControl.Append(iBackupTactileControl[i]); |
534 iTactileControl.Append(iBackupTactileControl[i]); |
526 } |
535 } |
527 } |
536 } |
528 |
537 |
529 } |
538 } |
530 // When pointer released captured, |
539 // When pointer released captured, |
531 // restore all original tactile area. |
540 // restore all original tactile area. |
532 else |
541 else |
533 { |
542 { |
534 if (iBackupTactileControl.Count() != 0) |
543 if (iBackupTactileControl.Count() != 0) |
535 { |
544 { |
536 iTactileControl.Reset(); |
545 iTactileControl.Reset(); |
537 |
546 |
538 TInt count = iBackupTactileControl.Count(); |
547 TInt count = iBackupTactileControl.Count(); |
539 for(TInt i = 0; i < count; ++i) |
548 for(TInt i = 0; i < count; ++i) |
540 { |
549 { |
541 iTactileControl.Append(iBackupTactileControl[i]); |
550 iTactileControl.Append(iBackupTactileControl[i]); |
542 } |
551 } |
543 iBackupTactileControl.Reset(); |
552 iBackupTactileControl.Reset(); |
544 } |
553 } |
545 } |
554 } |
546 #endif |
555 #endif |
547 } |
556 } |
548 break; |
557 break; |
549 case EPeninputOpLayoutSizeChangedWithSize: |
558 case EPeninputOpLayoutSizeChangedWithSize: |
550 { |
559 { |
551 TPckg<TSize> msgData(iSpriteSize); |
560 TPckg<TSize> msgData(iSpriteSize); |
652 GetFeedbackAreaDataL(controlarray,msg); |
661 GetFeedbackAreaDataL(controlarray,msg); |
653 //change the area one by one |
662 //change the area one by one |
654 for(TInt i = 0; i < controlarray.Count(); ++i) |
663 for(TInt i = 0; i < controlarray.Count(); ++i) |
655 { |
664 { |
656 //find id first |
665 //find id first |
657 TInt idx = iTactileControl.Find(controlarray[i], |
666 TInt idx = iTactileControl.Find(controlarray[i], |
658 TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID)); |
667 TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID)); |
659 if(idx != KErrNotFound) |
668 if(idx != KErrNotFound) |
660 { |
669 { |
661 //change the tactile feedback type |
670 //change the tactile feedback type |
662 iTactileControl[idx].iTactileType = controlarray[i].iTactileType; |
671 iTactileControl[idx].iTactileType = controlarray[i].iTactileType; |
663 break; |
672 break; |
664 } |
673 } |
665 } |
674 } |
666 |
675 |
667 CleanupStack::PopAndDestroy( 1, &controlarray ); |
676 CleanupStack::PopAndDestroy( 1, &controlarray ); |
670 break; |
679 break; |
671 |
680 |
672 #endif // RD_TACTILE_FEEDBACK |
681 #endif // RD_TACTILE_FEEDBACK |
673 case EPeninputOpRequestDSAState: |
682 case EPeninputOpRequestDSAState: |
674 { |
683 { |
675 TPckgC<TBool> flagMsg(iDSAState); |
684 TPckgC<TBool> flagMsg(iDSAState); |
676 |
685 |
677 msg->WriteL(KMsgSlot1,flagMsg); |
686 msg->WriteL(KMsgSlot1,flagMsg); |
678 |
687 |
679 } |
688 } |
680 break; |
689 break; |
681 case EPeninputOpSetDiscreeptPop: |
690 case EPeninputOpSetDiscreeptPop: |
682 { |
691 { |
683 TRect area; |
692 TRect area; |
684 TPckg<TRect> msgData(area); |
693 TPckg<TRect> msgData(area); |
685 msg->ReadL(KMsgSlot1,msgData); |
694 msg->ReadL(KMsgSlot1,msgData); |
686 SetDiscreeptPop(area); |
695 SetDiscreeptPop(area); |
687 } |
696 } |
688 break; |
697 break; |
689 default: |
698 default: |
690 // unsupported opcode, panic the client |
699 // unsupported opcode, panic the client |
691 { |
700 { |
692 iFunctions->Panic(); |
701 iFunctions->Panic(); |
693 retValue = KErrNotSupported; |
702 retValue = KErrNotSupported; |
703 // Makes PENINPUT window visible |
712 // Makes PENINPUT window visible |
704 // --------------------------------------------------------------------------- |
713 // --------------------------------------------------------------------------- |
705 // |
714 // |
706 void CPeninputAnim::Activate() |
715 void CPeninputAnim::Activate() |
707 { |
716 { |
708 if(!iIsActive) |
717 if(!iIsActive) |
709 { |
718 { |
710 iSpriteFunctions->SetPosition(iSpritePosition); |
719 iSpriteFunctions->SetPosition(iSpritePosition); |
711 if(iEnableSprite) |
720 if(iEnableSprite) |
712 iSpriteFunctions->Activate(ETrue); |
721 iSpriteFunctions->Activate(ETrue); |
713 iFunctions->GetRawEvents(ETrue); |
722 iFunctions->GetRawEvents(ETrue); |
714 iIsActive = ETrue; |
723 iIsActive = ETrue; |
715 |
724 } |
716 StartTimer(); |
|
717 } |
|
718 } |
725 } |
719 |
726 |
720 // --------------------------------------------------------------------------- |
727 // --------------------------------------------------------------------------- |
721 // CPeninputAnim::Deactivate |
728 // CPeninputAnim::Deactivate |
722 // Makes PENINPUT window invisible |
729 // Makes PENINPUT window invisible |
723 // --------------------------------------------------------------------------- |
730 // --------------------------------------------------------------------------- |
724 // |
731 // |
725 void CPeninputAnim::Deactivate() |
732 void CPeninputAnim::Deactivate() |
726 { |
733 { |
727 if(iIsActive) |
734 if(iIsActive) |
728 { |
735 { |
729 if(iEnableSprite) |
736 if(iEnableSprite) |
730 iSpriteFunctions->Activate(EFalse); |
737 iSpriteFunctions->Activate(EFalse); |
731 iFunctions->GetRawEvents(EFalse); |
738 iFunctions->GetRawEvents(EFalse); |
732 iIsActive = EFalse; |
739 iIsActive = EFalse; |
733 |
740 |
734 StopTimer(); |
741 StopTimer(); |
735 } |
742 } |
736 } |
743 } |
737 |
744 |
738 #ifdef RD_TACTILE_FEEDBACK |
745 #ifdef RD_TACTILE_FEEDBACK |
739 // --------------------------------------------------------------------------- |
746 // --------------------------------------------------------------------------- |
740 // CPeninputAnim::DoTactileFeedBack |
747 // CPeninputAnim::DoTactileFeedBack |
741 // Give tactile feedback |
748 // Give tactile feedback |
742 // --------------------------------------------------------------------------- |
749 // --------------------------------------------------------------------------- |
743 // |
750 // |
744 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos) |
751 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos) |
745 { |
752 { |
746 if ( iFeedback ) |
753 if ( iFeedback ) |
747 { |
754 { |
748 TInt count = iTactileControl.Count(); |
755 TInt count = iTactileControl.Count(); |
766 // --------------------------------------------------------------------------- |
773 // --------------------------------------------------------------------------- |
767 // |
774 // |
768 |
775 |
769 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent) |
776 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent) |
770 { |
777 { |
771 if(iIsSimulatedEvent) |
778 if(iIsSimulatedEvent) |
772 { |
779 { |
773 return EFalse; |
780 return EFalse; |
774 } |
781 } |
775 |
782 |
776 |
783 |
777 if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos())) |
784 if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos())) |
778 { |
785 { |
779 iDiscreetPopedCapture = ETrue; |
786 iDiscreetPopedCapture = ETrue; |
780 return EFalse; |
787 return EFalse; |
781 } |
788 } |
782 TRect rect(iSpritePosition, iSpriteSize); |
789 TRect rect(iSpritePosition, iSpriteSize); |
783 if(rect.Contains(aRawEvent.Pos())) |
790 if(rect.Contains(aRawEvent.Pos())) |
784 { |
791 { |
785 #ifdef RD_TACTILE_FEEDBACK |
792 #ifdef RD_TACTILE_FEEDBACK |
786 //give tactile feedback |
793 //give tactile feedback |
787 if(iTactileSupported) |
794 if(iTactileSupported) |
788 DoTactileFeedBack(aRawEvent.Pos() - rect.iTl); |
795 DoTactileFeedBack(aRawEvent.Pos() - rect.iTl); |
789 #endif // RD_TACTILE_FEEDBACK |
796 #endif // RD_TACTILE_FEEDBACK |
790 iIsPenDown = ETrue; |
797 iIsPenDown = ETrue; |
791 |
798 |
792 // When button downing event is happened, iIsMove is reset to EFalse |
799 // When button downing event is happened, iIsMove is reset to EFalse |
793 iIsMove = EFalse; |
800 iIsMove = EFalse; |
794 |
801 |
795 // Recording pointer that button is pressing down in at this time |
802 // Recording pointer that button is pressing down in at this time |
796 iPointerDown = aRawEvent.Pos(); |
803 iPointerDown = aRawEvent.Pos(); |
797 // |
804 // |
798 |
805 |
799 PostRawEvent(aRawEvent); |
806 PostRawEvent(aRawEvent); |
800 return ETrue; |
807 return ETrue; |
801 } |
808 } |
802 |
809 |
803 if(iIsPointerCaptured) |
810 if(iIsPointerCaptured) |
804 { |
811 { |
805 PostRawEvent(aRawEvent); |
812 PostRawEvent(aRawEvent); |
806 return ETrue; |
813 return ETrue; |
807 } |
814 } |
808 |
815 |
809 //pointer outside of input area,inform layout |
816 //pointer outside of input area,inform layout |
810 SendRawEvent(aRawEvent); |
817 SendRawEvent(aRawEvent); |
811 |
818 |
812 return EFalse; |
819 return EFalse; |
813 } |
820 } |
814 |
821 |
815 TBool CPeninputAnim::OnRawButton1Up(const TRawEvent& aRawEvent) |
822 TBool CPeninputAnim::OnRawButton1Up(const TRawEvent& aRawEvent) |
816 { |
823 { |
817 if(iIsSimulatedEvent) |
824 if(iIsSimulatedEvent) |
818 { |
825 { |
819 return EFalse; |
826 return EFalse; |
820 } |
827 } |
821 |
828 |
822 //For discreetPop |
829 //For discreetPop |
823 if(iDiscreetPopedCapture ) |
830 if(iDiscreetPopedCapture ) |
824 { |
831 { |
825 iDiscreetPopedCapture = EFalse; |
832 iDiscreetPopedCapture = EFalse; |
826 return EFalse; |
833 return EFalse; |
827 } |
834 } |
828 if(iIsPenDown) |
835 if(iIsPenDown) |
829 { |
836 { |
830 |
837 |
831 // When the control key pressing down in is different with the control key pressing up |
838 // When the control key pressing down in is different with the control key pressing up |
832 // and pointer moving event isn¡¯t happened, |
839 // and pointer moving event isn¡¯t happened, |
833 // pointer moving event will is supplied |
840 // pointer moving event will is supplied |
834 if(iPointerDown != aRawEvent.Pos() && !iIsMove) |
841 if(iPointerDown != aRawEvent.Pos() && !iIsMove) |
837 rawEvent.Set( TRawEvent::EPointerMove ); |
844 rawEvent.Set( TRawEvent::EPointerMove ); |
838 OnRawPointerMove(rawEvent); |
845 OnRawPointerMove(rawEvent); |
839 } |
846 } |
840 // |
847 // |
841 |
848 |
842 iIsPenDown = EFalse; |
849 iIsPenDown = EFalse; |
843 |
850 |
844 TRect rect(iSpritePosition, iSpriteSize); |
851 TRect rect(iSpritePosition, iSpriteSize); |
845 if(rect.Contains(aRawEvent.Pos())) |
852 if(rect.Contains(aRawEvent.Pos())) |
846 { |
853 { |
847 //send pen up event immediately |
854 //send pen up event immediately |
848 SendRawEvent(aRawEvent); |
855 SendRawEvent(aRawEvent); |
849 |
856 |
850 // When key pressing up event is completed, iIsMove is reset to EFalse. |
857 // When key pressing up event is completed, iIsMove is reset to EFalse. |
851 iIsMove = EFalse; |
858 iIsMove = EFalse; |
852 // |
859 // |
853 |
860 |
854 return ETrue; |
861 return ETrue; |
855 } |
862 } |
856 } |
863 } |
857 |
864 |
858 if(iIsPointerCaptured) |
865 if(iIsPointerCaptured) |
859 { |
866 { |
860 PostRawEvent(aRawEvent); |
867 PostRawEvent(aRawEvent); |
861 return ETrue; |
868 return ETrue; |
862 } |
869 } |
863 |
870 |
864 //pointer outside of input area,inform layout |
871 //pointer outside of input area,inform layout |
865 SendRawEvent(aRawEvent); |
872 SendRawEvent(aRawEvent); |
866 |
873 |
867 return EFalse; |
874 return EFalse; |
868 } |
875 } |
869 |
876 |
870 TBool CPeninputAnim::OnRawPointerMove(const TRawEvent& aRawEvent) |
877 TBool CPeninputAnim::OnRawPointerMove(const TRawEvent& aRawEvent) |
871 { |
878 { |
872 if(iIsSimulatedEvent) |
879 if(iIsSimulatedEvent) |
873 { |
880 { |
874 return EFalse; |
881 return EFalse; |
875 } |
882 } |
876 if(iDiscreetPopedCapture) |
883 if(iDiscreetPopedCapture) |
877 { |
884 { |
878 return EFalse; |
885 return EFalse; |
879 } |
886 } |
880 #ifdef RD_TACTILE_FEEDBACK |
887 #ifdef RD_TACTILE_FEEDBACK |
881 TRect rect(iSpritePosition, iSpriteSize); |
888 TRect rect(iSpritePosition, iSpriteSize); |
882 if( iIsPenDown && iIsPointerCaptured) |
889 if( iIsPenDown && iIsPointerCaptured) |
883 { |
890 { |
884 //give tactile feedback |
891 //give tactile feedback |
885 // When pointer moving event is happened, iIsMove is set to ETrue |
892 // When pointer moving event is happened, iIsMove is set to ETrue |
886 iIsMove = ETrue; |
893 iIsMove = ETrue; |
887 // |
894 // |
888 |
895 |
889 PostRawEvent(aRawEvent); |
896 PostRawEvent(aRawEvent); |
890 return ETrue; |
897 return ETrue; |
891 } |
898 } |
892 #endif // RD_TACTILE_FEEDBACK |
899 #endif // RD_TACTILE_FEEDBACK |
893 |
900 |
894 if(iIsPointerCaptured || iIsPenDown) |
901 if(iIsPointerCaptured || iIsPenDown) |
895 { |
902 { |
896 // When pointer moving event is happened, iIsMove is set to ETrue |
903 // When pointer moving event is happened, iIsMove is set to ETrue |
897 iIsMove = ETrue; |
904 iIsMove = ETrue; |
898 // |
905 // |
899 |
906 |
900 PostRawEvent(aRawEvent); |
907 PostRawEvent(aRawEvent); |
901 return ETrue; |
908 return ETrue; |
902 } |
909 } |
903 |
910 |
904 return EFalse; |
911 return EFalse; |
905 } |
912 } |
906 |
913 |
907 // --------------------------------------------------------------------------- |
914 // --------------------------------------------------------------------------- |
908 // CPeninputAnim::SetPosition |
915 // CPeninputAnim::SetPosition |
909 // called when sprite has been moved |
916 // called when sprite has been moved |
910 // --------------------------------------------------------------------------- |
917 // --------------------------------------------------------------------------- |
911 // |
918 // |
912 |
919 |
913 TPoint CPeninputAnim::SetPosition(const TPoint& aNewPos) |
920 TPoint CPeninputAnim::SetPosition(const TPoint& aNewPos) |
914 { |
921 { |
915 if(aNewPos != iSpritePosition) |
922 if(aNewPos != iSpritePosition) |
916 { |
923 { |
917 iSpritePosition = aNewPos; |
924 iSpritePosition = aNewPos; |
918 iSpriteFunctions->SetPosition(iSpritePosition); |
925 iSpriteFunctions->SetPosition(iSpritePosition); |
919 } |
926 } |
920 return iSpritePosition; |
927 return iSpritePosition; |
921 } |
928 } |
922 |
929 |
923 // --------------------------------------------------------------------------- |
930 // --------------------------------------------------------------------------- |
924 // CPeninputAnim::UpdateArea |
931 // CPeninputAnim::UpdateArea |
925 // Update sprite rect |
932 // Update sprite rect |
926 // --------------------------------------------------------------------------- |
933 // --------------------------------------------------------------------------- |
927 // |
934 // |
928 void CPeninputAnim::UpdateArea(const TRect& aRect, TBool aFullUpdate) |
935 void CPeninputAnim::UpdateArea(const TRect& aRect, TBool aFullUpdate) |
929 { |
936 { |
930 if(iIsActive) |
937 if(iIsActive) |
931 { |
938 { |
932 // if function is called without specifying the parameter aRect |
939 // if function is called without specifying the parameter aRect |
933 // (using default param value) the whole area drawn to is updated |
940 // (using default param value) the whole area drawn to is updated |
934 iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate); |
941 iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate); |
935 } |
942 } |
936 } |
943 } |
937 |
944 |
938 // --------------------------------------------------------------------------- |
945 // --------------------------------------------------------------------------- |
939 // CPeninputAnim::TimerCallBack |
946 // CPeninputAnim::TimerCallBack |
1001 // Wait until it's processed or timer out |
1008 // Wait until it's processed or timer out |
1002 // --------------------------------------------------------------------------- |
1009 // --------------------------------------------------------------------------- |
1003 // |
1010 // |
1004 TBool CPeninputAnim::OnRawKeyEvent(const TRawEvent& aRawEvent) |
1011 TBool CPeninputAnim::OnRawKeyEvent(const TRawEvent& aRawEvent) |
1005 { |
1012 { |
1006 TInt ret = KErrNone; |
1013 TInt ret = KErrNone; |
1007 |
1014 |
1008 //first sends all buffered event out |
1015 //first sends all buffered event out |
1009 FlushRawEventBuffer(); |
1016 FlushRawEventBuffer(); |
1010 |
1017 |
1011 //clear the signal and the response msg queue |
1018 //clear the signal and the response msg queue |
1012 TBool isHandled = EFalse; |
1019 TBool isHandled = EFalse; |
1013 ret = iKeyMsgResponseQueue.Receive(isHandled); |
1020 ret = iKeyMsgResponseQueue.Receive(isHandled); |
1014 while(ret == KErrNone) |
1021 while(ret == KErrNone) |
1015 { |
1022 { |
1016 iResponseQueueSemaphore.Wait(); |
1023 iResponseQueueSemaphore.Wait(); |
1017 ret = iKeyMsgResponseQueue.Receive(isHandled); |
1024 ret = iKeyMsgResponseQueue.Receive(isHandled); |
1018 } |
1025 } |
1019 |
1026 |
1020 //send the event directly |
1027 //send the event directly |
1021 iEventBuffer.iNum = 1; |
1028 iEventBuffer.iNum = 1; |
1022 iEventBuffer.iEvent[0] = aRawEvent; |
1029 iEventBuffer.iEvent[0] = aRawEvent; |
1023 ret = FlushRawEventBuffer(); |
1030 ret = FlushRawEventBuffer(); |
1024 |
1031 |
1025 isHandled = EFalse; |
1032 isHandled = EFalse; |
1026 if(ret == KErrNone) |
1033 if(ret == KErrNone) |
1027 { |
1034 { |
1028 //wait for the key event processed. |
1035 //wait for the key event processed. |
1029 ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime); |
1036 ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime); |
1030 if(ret == KErrNone) |
1037 if(ret == KErrNone) |
1031 { |
1038 { |
1032 //read the response from msg queue |
1039 //read the response from msg queue |
1033 iKeyMsgResponseQueue.Receive(isHandled); |
1040 iKeyMsgResponseQueue.Receive(isHandled); |
1034 } |
1041 } |
1035 } |
1042 } |
1036 |
1043 |
1037 return isHandled; |
1044 return isHandled; |
1038 } |
1045 } |
1039 |
1046 |
1042 // Initial and start timer |
1049 // Initial and start timer |
1043 // --------------------------------------------------------------------------- |
1050 // --------------------------------------------------------------------------- |
1044 // |
1051 // |
1045 void CPeninputAnim::StartTimer() |
1052 void CPeninputAnim::StartTimer() |
1046 { |
1053 { |
1047 iFlushTimer->Start( |
1054 if ( iIsActive ) |
1048 KFlushTimerPeriod, |
1055 { |
1049 KFlushTimerPeriod, |
1056 iFlushTimer->Start( |
1050 TCallBack(FlushTimerCallBack, this)); |
1057 KFlushTimerPeriod, |
1051 } |
1058 KFlushTimerPeriod, |
1052 |
1059 TCallBack(FlushTimerCallBack, this)); |
|
1060 } |
|
1061 } |
|
1062 |
1053 // --------------------------------------------------------------------------- |
1063 // --------------------------------------------------------------------------- |
1054 // CPeninputAnim::StopTimer |
1064 // CPeninputAnim::StopTimer |
1055 // Cancel timer |
1065 // Cancel timer |
1056 // --------------------------------------------------------------------------- |
1066 // --------------------------------------------------------------------------- |
1057 // |
1067 // |
1058 void CPeninputAnim::StopTimer() |
1068 void CPeninputAnim::StopTimer() |
1059 { |
1069 { |
1060 iFlushTimer->Cancel(); |
1070 iFlushTimer->Cancel(); |
|
1071 FlushRawEventBuffer(); |
1061 } |
1072 } |
1062 |
1073 |
1063 #ifdef RD_TACTILE_FEEDBACK |
1074 #ifdef RD_TACTILE_FEEDBACK |
1064 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray, |
1075 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray, |
1065 const RMessagePtr2* msg, |
1076 const RMessagePtr2* msg, |
1066 RArray<TRect>* aPrevRectArray) |
1077 RArray<TRect>* aPrevRectArray) |
1067 { |
1078 { |
1068 TInt num; |
1079 TInt num; |
1069 TPckg<TInt> numBuf(num); |
1080 TPckg<TInt> numBuf(num); |
1070 msg->ReadL(KMsgSlot1,numBuf); |
1081 msg->ReadL(KMsgSlot1,numBuf); |
1092 // CPeninputAnim::MatchItemByControlID |
1103 // CPeninputAnim::MatchItemByControlID |
1093 // Compare the Item by ID |
1104 // Compare the Item by ID |
1094 // --------------------------------------------------------------------------- |
1105 // --------------------------------------------------------------------------- |
1095 // |
1106 // |
1096 TBool CPeninputAnim::MatchItemByControlID (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond) |
1107 TBool CPeninputAnim::MatchItemByControlID (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond) |
1097 { |
1108 { |
1098 if (aFirst.iId == aSecond.iId) |
1109 if (aFirst.iId == aSecond.iId) |
1099 return ETrue; |
1110 return ETrue; |
1100 return EFalse; |
1111 return EFalse; |
1101 } |
1112 } |
1102 |
1113 |
1103 // --------------------------------------------------------------------------- |
1114 // --------------------------------------------------------------------------- |
1104 // CPeninputAnim::MatchItemByControlIDAndArea |
1115 // CPeninputAnim::MatchItemByControlIDAndArea |
1105 // Compare the Item by ID and Area |
1116 // Compare the Item by ID and Area |
1106 // --------------------------------------------------------------------------- |
1117 // --------------------------------------------------------------------------- |
1107 // |
1118 // |
1108 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond) |
1119 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond) |
1109 { |
1120 { |
1110 if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea)) |
1121 if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea)) |
1111 return ETrue; |
1122 return ETrue; |
1112 return EFalse; |
1123 return EFalse; |
1113 } |
1124 } |
1114 #endif // RD_TACTILE_FEEDBACK |
1125 #endif // RD_TACTILE_FEEDBACK |
1115 |
1126 |
1116 void CPeninputAnim::SetDiscreeptPop(TRect aArea) |
1127 void CPeninputAnim::SetDiscreeptPop(TRect aArea) |
1117 { |
1128 { |
1118 iDiscreetPopArea = aArea; |
1129 iDiscreetPopArea = aArea; |
1119 if(iDiscreetPopArea.Size().iWidth > 0) |
1130 if(iDiscreetPopArea.Size().iWidth > 0) |
1120 { |
1131 { |
1121 iDiscreetPoped = ETrue; |
1132 iDiscreetPoped = ETrue; |
1122 } |
1133 } |
1123 else |
1134 else |
1124 { |
1135 { |
1125 iDiscreetPoped = EFalse; |
1136 iDiscreetPoped = EFalse; |
1126 iDiscreetPopedCapture = EFalse; |
1137 iDiscreetPopedCapture = EFalse; |
1127 } |
1138 } |
1128 } |
1139 } |
1129 // End of File |
1140 // End of File |