qstmgesturelib/recognisers/qstmflickgesturerecogniser.cpp
changeset 16 3c88a81ff781
parent 3 0954f5dd2cd0
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
    56         }
    56         }
    57         
    57         
    58         if (m_powner == puie->target() && eventCode == qstmUiEventEngine::ERelease)
    58         if (m_powner == puie->target() && eventCode == qstmUiEventEngine::ERelease)
    59         {
    59         {
    60             if (m_loggingenabled) {
    60             if (m_loggingenabled) {
    61                 LOGARG("QStm_FlickGestureRecogniser: 0x%x ERelease: num %d code %d, %d", 
    61                 LOGARG("QStm_FlickGestureRecogniser: 0x%x ERelease: num %d pos: [%d, %d]", 
    62                 		this, countOfEvents, puie->currentXY().x(), puie->currentXY().y());
    62                 		this, countOfEvents, puie->currentXY().x(), puie->currentXY().y());
    63             }
    63             }
    64             // Check if the speed before release was fast enough for flick
    64             // Check if the speed before release was fast enough for flick
    65             const qstmUiEventEngine::QStm_UiEventIf* puieprev = puie->previousEvent() ;
    65             const qstmUiEventEngine::QStm_UiEventIf* puieprev = puie->previousEvent() ;
    66             if (puieprev && puieprev->code() == qstmUiEventEngine::EMove) {
    66             if (puieprev && puieprev->code() == qstmUiEventEngine::EMove) {
    67                 using qstmUiEventEngine::QStm_UiEventSpeed;
    67                 using qstmUiEventEngine::QStm_UiEventSpeed;
    68 
    68 
       
    69                 QPoint pos = puieprev->currentXY();
       
    70                 QPoint prevPos = puieprev->previousXY();
    69                 float thespeed = puieprev->speed() ;
    71                 float thespeed = puieprev->speed() ;
       
    72                 if (thespeed == 0.0f && countOfEvents > 2) {
       
    73                 if (m_loggingenabled) {
       
    74                         LOGTXT("QStm_FlickGestureRecogniser: speed is 0.0. Trying to get prev speed!");
       
    75                     }
       
    76                     // trye to get speed from puie->previousEvent()->previousEvent()
       
    77                     puieprev = puieprev->previousEvent();
       
    78                     if (puieprev && puieprev->code() == qstmUiEventEngine::EMove) {
       
    79                         thespeed = puieprev->speed() ;
       
    80                     }
       
    81                 }
    70                 if (m_loggingenabled) {
    82                 if (m_loggingenabled) {
    71                     LOGARG("QStm_FlickGestureRecogniser: prev speed: %f (limit: %f)", double(thespeed), double(m_speed)) ;
    83                     LOGARG("QStm_FlickGestureRecogniser: prev speed: %f (limit: %f)", double(thespeed), double(m_speed)) ;
    72                 }
    84                 }
    73                 if (thespeed > m_speed) {
    85                 if (thespeed > m_speed) {
    74                     state = EGestureActive ;
    86                     state = EGestureActive ;
    76                     QStm_UiEventSpeed speedIf(thespeed, puieprev->speedVec());
    88                     QStm_UiEventSpeed speedIf(thespeed, puieprev->speedVec());
    77 
    89 
    78                     // issue the flick gesture using the TDirectionalGesture (it has the speed and direction)
    90                     // issue the flick gesture using the TDirectionalGesture (it has the speed and direction)
    79                     qstmGesture::QStm_DirectionalGesture pgest(
    91                     qstmGesture::QStm_DirectionalGesture pgest(
    80                             KUid,
    92                             KUid,
    81                             puieprev->currentXY(),
    93                             pos,
    82                             puieprev->previousXY(),
    94                             prevPos,
       
    95                             puie->timestamp(),
    83                             &speedIf,
    96                             &speedIf,
    84                             m_loggingenabled);
    97                             m_loggingenabled);
    85                     pgest.setTarget(puie->target());
    98                     pgest.setTarget(puie->target());
    86 
    99 
    87                     // Call the listener to inform that a flick has occurred...
   100                     // Call the listener to inform that a flick has occurred...