tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp
changeset 23 ef70b7e23576
parent 0 d54f32e146dd
child 24 90362ffca16a
--- a/tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp	Mon May 03 12:47:28 2010 +0300
+++ b/tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp	Wed May 26 00:48:57 2010 +0300
@@ -47,7 +47,8 @@
 // ---------------------------------------------------------------------------
 //
 CTactileFeedbackResolver::CTactileFeedbackResolver() : 
-    iFeedbackStarted( EFalse )
+    iFeedbackStarted( EFalse ), 
+    iLastFeedback( ETouchFeedbackNone ) 
     {
     }
 
@@ -107,7 +108,37 @@
     delete iAudioPlayer;
     REComSession::FinalClose();
     }
+
+TBool CTactileFeedbackResolver::IsHigherThanPlaying(
+    TTouchLogicalFeedback aFeedback ) const
+    {
+    if( aFeedback == ETouchFeedbackBasicItem &&
+        iLastFeedback == ETouchFeedbackSensitiveItem )
+        {
+        return ETrue;
+        }
     
+    return ( ( aFeedback == ETouchFeedbackPopUp || 
+            aFeedback == ETouchFeedbackPopupOpen || 
+            aFeedback == ETouchFeedbackPopupClose ||
+            aFeedback == ETouchFeedbackBounceEffect ||
+            aFeedback == ETouchFeedbackOptionsMenuOpen ||
+            aFeedback == ETouchFeedbackOptionsMenuClosed ||
+            aFeedback == ETouchFeedbackSubMenuOpen ||
+            aFeedback == ETouchFeedbackSubMenuClosed ) &&
+            ( iLastFeedback == ETouchFeedbackBasicButton ||
+            iLastFeedback == ETouchFeedbackSensitiveButton ||
+            iLastFeedback == ETouchFeedbackSensitiveItem ||
+            iLastFeedback == ETouchFeedbackBasicItem ||
+            iLastFeedback == ETouchFeedbackCheckbox ) ) 
+            || (
+             aFeedback == ETouchFeedbackPopUp && 
+             ( iLastFeedback == ETouchFeedbackPopupOpen ||
+              iLastFeedback == ETouchFeedbackOptionsMenuOpen ||
+              iLastFeedback == ETouchFeedbackSubMenuOpen )
+             );
+    }
+
 // ---------------------------------------------------------------------------
 // We play feedback in case all three conditions are met:
 // 
@@ -129,17 +160,29 @@
     
     TTimeIntervalMicroSeconds interval = 
         now.MicroSecondsFrom( iLastFeedbackTimeStamp );
+
+    TBool willPlay = EFalse;
     
-     if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
-          now < iLastFeedbackTimeStamp ||                       
-          iMinimumInterval <= interval )                        
+    if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
+         now < iLastFeedbackTimeStamp ||                       
+         iMinimumInterval <= interval )
+        {
+        willPlay = ETrue;
+        }
+    else if ( IsHigherThanPlaying( aFeedback ) )
+        {
+        willPlay = ETrue;
+        }
+
+    if ( willPlay )
         {
         // First store the timestamp of this feedback playing moment.
         // This really needs to be done when 
         // actually playing feedback (not when feedback was requested
         // but filtered out).
         iLastFeedbackTimeStamp = now;      
-    
+
+        iLastFeedback = aFeedback;
     
         // Force vibra- and audio feedback off if those are globally disabled
         if ( !iVibraEnabled )