tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp
branchRCL_3
changeset 12 63c33341dc19
parent 0 d54f32e146dd
child 13 a4df7952b706
equal deleted inserted replaced
11:e0d1d1629961 12:63c33341dc19
    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     return ( aFeedback == ETouchFeedbackPopUp || 
       
   116              aFeedback == ETouchFeedbackIncreasingPopUp || 
       
   117              aFeedback == ETouchFeedbackDecreasingPopUp ) &&
       
   118            ( iLastFeedback == ETouchFeedbackBasicButton ||
       
   119              iLastFeedback == ETouchFeedbackList );
       
   120     }
       
   121 
   111 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   112 // We play feedback in case all three conditions are met:
   123 // We play feedback in case all three conditions are met:
   113 // 
   124 // 
   114 // #1 Either vibra or audio feedback is requested and globally enabled
   125 // #1 Either vibra or audio feedback is requested and globally enabled
   115 // #2 Given feedback type is different than "None"
   126 // #2 Given feedback type is different than "None"
   127     TTime now;
   138     TTime now;
   128     now.UniversalTime();
   139     now.UniversalTime();
   129     
   140     
   130     TTimeIntervalMicroSeconds interval = 
   141     TTimeIntervalMicroSeconds interval = 
   131         now.MicroSecondsFrom( iLastFeedbackTimeStamp );
   142         now.MicroSecondsFrom( iLastFeedbackTimeStamp );
   132     
   143 
   133      if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
   144     TBool willPlay = EFalse;
   134           now < iLastFeedbackTimeStamp ||                       
   145     
   135           iMinimumInterval <= interval )                        
   146     if ( iMinimumInterval == TTimeIntervalMicroSeconds( 0 ) || 
       
   147          now < iLastFeedbackTimeStamp ||                       
       
   148          iMinimumInterval <= interval )
       
   149         {
       
   150         willPlay = ETrue;
       
   151         }
       
   152     else if ( IsHigherThanPlaying( aFeedback ) )
       
   153         {
       
   154         willPlay = ETrue;
       
   155         
       
   156         iAudioPlayer->StopFeedback();
       
   157         iHapticsPlayer->StopFeedback();
       
   158         }
       
   159 
       
   160     if ( willPlay )
   136         {
   161         {
   137         // First store the timestamp of this feedback playing moment.
   162         // First store the timestamp of this feedback playing moment.
   138         // This really needs to be done when 
   163         // This really needs to be done when 
   139         // actually playing feedback (not when feedback was requested
   164         // actually playing feedback (not when feedback was requested
   140         // but filtered out).
   165         // but filtered out).
   141         iLastFeedbackTimeStamp = now;      
   166         iLastFeedbackTimeStamp = now;      
   142     
   167 
       
   168         iLastFeedback = aFeedback;
   143     
   169     
   144         // Force vibra- and audio feedback off if those are globally disabled
   170         // Force vibra- and audio feedback off if those are globally disabled
   145         if ( !iVibraEnabled )
   171         if ( !iVibraEnabled )
   146             {
   172             {
   147             aPlayVibra = EFalse;
   173             aPlayVibra = EFalse;