tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp
changeset 23 ef70b7e23576
parent 0 d54f32e146dd
child 24 90362ffca16a
equal deleted inserted replaced
17:8e4f1d643852 23:ef70b7e23576
    45 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    46 // Consructor.
    46 // Consructor.
    47 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    48 //
    48 //
    49 CTactileFeedbackResolver::CTactileFeedbackResolver() : 
    49 CTactileFeedbackResolver::CTactileFeedbackResolver() : 
    50     iFeedbackStarted( EFalse )
    50     iFeedbackStarted( EFalse ), 
       
    51     iLastFeedback( ETouchFeedbackNone ) 
    51     {
    52     {
    52     }
    53     }
    53 
    54 
    54 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    55 // 2nd phase costructor.
    56 // 2nd phase costructor.
   105     delete iPropertyWatcher;
   106     delete iPropertyWatcher;
   106     delete iHapticsPlayer;
   107     delete iHapticsPlayer;
   107     delete iAudioPlayer;
   108     delete iAudioPlayer;
   108     REComSession::FinalClose();
   109     REComSession::FinalClose();
   109     }
   110     }
   110     
   111 
       
   112 TBool CTactileFeedbackResolver::IsHigherThanPlaying(
       
   113     TTouchLogicalFeedback aFeedback ) const
       
   114     {
       
   115     if( aFeedback == ETouchFeedbackBasicItem &&
       
   116         iLastFeedback == ETouchFeedbackSensitiveItem )
       
   117         {
       
   118         return ETrue;
       
   119         }
       
   120     
       
   121     return ( ( aFeedback == ETouchFeedbackPopUp || 
       
   122             aFeedback == ETouchFeedbackPopupOpen || 
       
   123             aFeedback == ETouchFeedbackPopupClose ||
       
   124             aFeedback == ETouchFeedbackBounceEffect ||
       
   125             aFeedback == ETouchFeedbackOptionsMenuOpen ||
       
   126             aFeedback == ETouchFeedbackOptionsMenuClosed ||
       
   127             aFeedback == ETouchFeedbackSubMenuOpen ||
       
   128             aFeedback == ETouchFeedbackSubMenuClosed ) &&
       
   129             ( iLastFeedback == ETouchFeedbackBasicButton ||
       
   130             iLastFeedback == ETouchFeedbackSensitiveButton ||
       
   131             iLastFeedback == ETouchFeedbackSensitiveItem ||
       
   132             iLastFeedback == ETouchFeedbackBasicItem ||
       
   133             iLastFeedback == ETouchFeedbackCheckbox ) ) 
       
   134             || (
       
   135              aFeedback == ETouchFeedbackPopUp && 
       
   136              ( iLastFeedback == ETouchFeedbackPopupOpen ||
       
   137               iLastFeedback == ETouchFeedbackOptionsMenuOpen ||
       
   138               iLastFeedback == ETouchFeedbackSubMenuOpen )
       
   139              );
       
   140     }
       
   141 
   111 // ---------------------------------------------------------------------------
   142 // ---------------------------------------------------------------------------
   112 // We play feedback in case all three conditions are met:
   143 // We play feedback in case all three conditions are met:
   113 // 
   144 // 
   114 // #1 Either vibra or audio feedback is requested and globally enabled
   145 // #1 Either vibra or audio feedback is requested and globally enabled
   115 // #2 Given feedback type is different than "None"
   146 // #2 Given feedback type is different than "None"
   127     TTime now;
   158     TTime now;
   128     now.UniversalTime();
   159     now.UniversalTime();
   129     
   160     
   130     TTimeIntervalMicroSeconds interval = 
   161     TTimeIntervalMicroSeconds interval = 
   131         now.MicroSecondsFrom( iLastFeedbackTimeStamp );
   162         now.MicroSecondsFrom( iLastFeedbackTimeStamp );
   132     
   163 
   133      if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
   164     TBool willPlay = EFalse;
   134           now < iLastFeedbackTimeStamp ||                       
   165     
   135           iMinimumInterval <= interval )                        
   166     if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
       
   167          now < iLastFeedbackTimeStamp ||                       
       
   168          iMinimumInterval <= interval )
       
   169         {
       
   170         willPlay = ETrue;
       
   171         }
       
   172     else if ( IsHigherThanPlaying( aFeedback ) )
       
   173         {
       
   174         willPlay = ETrue;
       
   175         }
       
   176 
       
   177     if ( willPlay )
   136         {
   178         {
   137         // First store the timestamp of this feedback playing moment.
   179         // First store the timestamp of this feedback playing moment.
   138         // This really needs to be done when 
   180         // This really needs to be done when 
   139         // actually playing feedback (not when feedback was requested
   181         // actually playing feedback (not when feedback was requested
   140         // but filtered out).
   182         // but filtered out).
   141         iLastFeedbackTimeStamp = now;      
   183         iLastFeedbackTimeStamp = now;      
   142     
   184 
       
   185         iLastFeedback = aFeedback;
   143     
   186     
   144         // Force vibra- and audio feedback off if those are globally disabled
   187         // Force vibra- and audio feedback off if those are globally disabled
   145         if ( !iVibraEnabled )
   188         if ( !iVibraEnabled )
   146             {
   189             {
   147             aPlayVibra = EFalse;
   190             aPlayVibra = EFalse;