videoplayback/videoplaybackview/viewsrc/videoplaybackuserinputhandler.cpp
changeset 62 0e1e938beb1a
parent 59 a76e86df7ccd
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    13 *
    13 *
    14 * Description:  Implementation of playback view's input handler
    14 * Description:  Implementation of playback view's input handler
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 9 %
    18 // Version : %version: 11 %
    19 
    19 
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include <e32std.h>
    22 #include <e32std.h>
    23 #include <w32std.h> // RWindowBase
    23 #include <w32std.h> // RWindowBase
    30 #include <mpxplaybackframeworkdefs.h>
    30 #include <mpxplaybackframeworkdefs.h>
    31 #include <centralrepository.h>  // for peripheral display timeout setting
    31 #include <centralrepository.h>  // for peripheral display timeout setting
    32 #include <settingsinternalcrkeys.h> // display timeout setting keys
    32 #include <settingsinternalcrkeys.h> // display timeout setting keys
    33 #include <hwrmlightdomaincrkeys.h>
    33 #include <hwrmlightdomaincrkeys.h>
    34 #include <mpxvideoplaybackdefs.h>
    34 #include <mpxvideoplaybackdefs.h>
    35 
    35 #include <avkondomainpskeys.h>
    36 #include <hal.h>
       
    37 #include <hal_data.h>
       
    38 
    36 
    39 #include "mpxvideo_debug.h"
    37 #include "mpxvideo_debug.h"
    40 #include "mpxvideoviewwrapper.h"
    38 #include "mpxvideoviewwrapper.h"
    41 #include "mpxcommonvideoplaybackview.hrh"
    39 #include "mpxcommonvideoplaybackview.hrh"
    42 #include "videoplaybackuserinputhandler.h"
    40 #include "videoplaybackuserinputhandler.h"
    43 
    41 
    44 
    42 
    45 // CONSTANTS
       
    46 const TInt KMPXMicroSecondsInASecond = 1000000;
       
    47 
       
    48 
    43 
    49 // ======== MEMBER FUNCTIONS =======================================================================
    44 // ======== MEMBER FUNCTIONS =======================================================================
    50 
    45 
    51 // -------------------------------------------------------------------------------------------------
    46 // -------------------------------------------------------------------------------------------------
    52 // CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler()
    47 // CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler()
    53 // -------------------------------------------------------------------------------------------------
    48 // -------------------------------------------------------------------------------------------------
    54 //
    49 //
    55 CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler( CMPXVideoViewWrapper* aWrapper )
    50 CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler( CMPXVideoViewWrapper* aWrapper )
    56    : iViewWrapper( aWrapper )
    51     : iProcessingInputType( EVideoNone )
       
    52     , iForeground( ETrue )
       
    53     , iViewWrapper( aWrapper )
    57 {
    54 {
    58 }
    55 }
    59 
    56 
    60 // -------------------------------------------------------------------------------------------------
    57 // -------------------------------------------------------------------------------------------------
    61 // CVideoPlaybackUserInputHandler::NewL()
    58 // CVideoPlaybackUserInputHandler::NewL()
    62 // -------------------------------------------------------------------------------------------------
    59 // -------------------------------------------------------------------------------------------------
    63 //
    60 //
    64 CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL(
    61 CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL( CMPXVideoViewWrapper* aWrapper )
    65         CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected )
    62 {
    66 {
    63     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::NewL()"));
    67     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::NewL()"));
       
    68 
    64 
    69     CVideoPlaybackUserInputHandler* self =
    65     CVideoPlaybackUserInputHandler* self =
    70         new (ELeave) CVideoPlaybackUserInputHandler( aWrapper );
    66         new (ELeave) CVideoPlaybackUserInputHandler( aWrapper );
    71     CleanupStack::PushL( self );
    67     CleanupStack::PushL( self );
    72     self->ConstructL( aTvOutConnected );
    68     self->ConstructL();
    73     CleanupStack::Pop();
    69     CleanupStack::Pop();
    74     return self;
    70     return self;
    75 }
    71 }
    76 
    72 
    77 // -------------------------------------------------------------------------------------------------
    73 // -------------------------------------------------------------------------------------------------
    78 // CVideoPlaybackUserInputHandler::ConstructL
    74 // CVideoPlaybackUserInputHandler::ConstructL
    79 // Symbian 2nd phase constructor can leave.
    75 // Symbian 2nd phase constructor can leave.
    80 // -------------------------------------------------------------------------------------------------
    76 // -------------------------------------------------------------------------------------------------
    81 //
    77 //
    82 void CVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected )
    78 void CVideoPlaybackUserInputHandler::ConstructL()
    83 {
    79 {
    84     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ConstructL()"));
    80     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ConstructL()"));
    85 
    81 
    86     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
    82     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
    87     iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
    83 
    88     iInterfaceSelector = CRemConInterfaceSelector::NewL();
    84     iInterfaceSelector = CRemConInterfaceSelector::NewL();
    89     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
    85     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
    90 
    86 
    91     iTVOutConnected = aTvOutConnected;
       
    92  
       
    93     // Start the timer if TV out is connected
       
    94     if ( iTVOutConnected )
       
    95     {                
       
    96         // Get the display light time-out value from CenRep 
       
    97         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );
       
    98     
       
    99         // What's the timeout value (in seconds ) for the display light?
       
   100         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   101         MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   102     
       
   103         CleanupStack::PopAndDestroy( repository );
       
   104     
       
   105         // Convert the timeout value to microseconds
       
   106         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   107     
       
   108         RestartDisplayTimer();
       
   109     }
       
   110 
       
   111     // not detrimental if Media Keys dont work - so ignore any errors here
    87     // not detrimental if Media Keys dont work - so ignore any errors here
   112     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
    88     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
   113 
       
   114     iProcessingInputType = EVideoNone;
       
   115     iForeground = ETrue;
       
   116 }
    89 }
   117 
    90 
   118 // -------------------------------------------------------------------------------------------------
    91 // -------------------------------------------------------------------------------------------------
   119 // CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
    92 // CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
   120 // -------------------------------------------------------------------------------------------------
    93 // -------------------------------------------------------------------------------------------------
   121 //
    94 //
   122 CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
    95 CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()
   123 {
    96 {
       
    97     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()"));
       
    98 
   124     if ( iVolumeRepeatTimer )
    99     if ( iVolumeRepeatTimer )
   125     {
   100     {
   126         iVolumeRepeatTimer->Cancel();
   101         iVolumeRepeatTimer->Cancel();
   127         delete iVolumeRepeatTimer;
   102         delete iVolumeRepeatTimer;
   128     }
       
   129 
       
   130     if ( iDisplayTimer )
       
   131     {
       
   132         iDisplayTimer->Cancel();
       
   133         delete iDisplayTimer;
       
   134     }
   103     }
   135 
   104 
   136     if ( iInterfaceSelector )
   105     if ( iInterfaceSelector )
   137     {
   106     {
   138         delete iInterfaceSelector;
   107         delete iInterfaceSelector;
   139         iCoreTarget = NULL;
   108         iCoreTarget = NULL;
   140         iInterfaceSelector = NULL;
   109         iInterfaceSelector = NULL;
   141     }
   110     }
   142 
       
   143     // make sure that backlight enabled when 
       
   144     // the view updates or deactivates
       
   145     EnableBacklight();
       
   146 }
   111 }
   147 
   112 
   148 // -------------------------------------------------------------------------------------------------
   113 // -------------------------------------------------------------------------------------------------
   149 // CVideoPlaybackUserInputHandler::MrccatoPlay()
   114 // CVideoPlaybackUserInputHandler::MrccatoPlay()
   150 // -------------------------------------------------------------------------------------------------
   115 // -------------------------------------------------------------------------------------------------
   179 // -------------------------------------------------------------------------------------------------
   144 // -------------------------------------------------------------------------------------------------
   180 //
   145 //
   181 void CVideoPlaybackUserInputHandler::DoHandleMediaKey( TRemConCoreApiOperationId aOperationId,
   146 void CVideoPlaybackUserInputHandler::DoHandleMediaKey( TRemConCoreApiOperationId aOperationId,
   182                                                        TRemConCoreApiButtonAction aButtonAct )
   147                                                        TRemConCoreApiButtonAction aButtonAct )
   183 {
   148 {
   184     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DoHandleMediaKey()"));
   149     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DoHandleMediaKey()"),
       
   150                    _L("aOperationId = %d"), aOperationId );
   185 
   151 
   186     switch ( aOperationId )
   152     switch ( aOperationId )
   187     {
   153     {
   188         case ERemConCoreApiStop:
   154         case ERemConCoreApiStop:
   189         {
   155         {
   190             if ( aButtonAct == ERemConCoreApiButtonClick )
   156             if ( aButtonAct == ERemConCoreApiButtonClick )
   191             {
   157             {
   192                 TRAP_IGNORE(iViewWrapper->HandleCommandL( EMPXPbvCmdStop ));
   158                 TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdStop ) );
   193             }
   159             }
   194             break;
   160             break;
   195         }
   161         }
   196         case ERemConCoreApiRewind:
   162         case ERemConCoreApiRewind:
   197         {
   163         {
   198             HandleRewind(aButtonAct);
   164             HandleRewind( aButtonAct );
   199             break;
   165             break;
   200         }
   166         }
   201         case ERemConCoreApiFastForward:
   167         case ERemConCoreApiFastForward:
   202         {
   168         {
   203             HandleFastForward(aButtonAct);
   169             HandleFastForward( aButtonAct );
   204             break;
   170             break;
   205         }
   171         }
   206         case ERemConCoreApiVolumeUp:
   172         case ERemConCoreApiVolumeUp:
   207         {
   173         {
   208             HandleVolumeUp(aButtonAct);
   174             HandleVolumeUp( aButtonAct );
   209             break;
   175             break;
   210         }
   176         }
   211         case ERemConCoreApiVolumeDown:
   177         case ERemConCoreApiVolumeDown:
   212         {
   178         {
   213             HandleVolumeDown(aButtonAct);
   179             HandleVolumeDown( aButtonAct );
   214             break;
   180             break;
   215         }
   181         }
   216         case ERemConCoreApiPausePlayFunction:
   182         case ERemConCoreApiPausePlayFunction:
   217         {
   183         {
   218             if ( aButtonAct == ERemConCoreApiButtonClick )
   184             if ( aButtonAct == ERemConCoreApiButtonClick )
   219             {
   185             {
   220                 TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlayPause));
   186                 TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdPlayPause ) );
   221             }
   187             }
   222             break;
   188             break;
   223         }
   189         }
   224         case ERemConCoreApiPause:
   190         case ERemConCoreApiPause:
   225         {
   191         {
   226             TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPause));
   192             TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdPause ) );
   227             break;
   193             break;
   228         }
   194         }
   229         case ERemConCoreApiPlay:
   195         case ERemConCoreApiPlay:
   230         {
   196         {
   231             if ( aButtonAct == ERemConCoreApiButtonClick )
   197             if ( aButtonAct == ERemConCoreApiButtonClick )
   233                 TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlay));
   199                 TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlay));
   234             }
   200             }
   235             break;
   201             break;
   236         }
   202         }
   237         default:
   203         default:
   238             break;
   204         {
       
   205             break;
       
   206         }
   239     }
   207     }
   240 }
   208 }
   241 
   209 
   242 // -------------------------------------------------------------------------------------------------
   210 // -------------------------------------------------------------------------------------------------
   243 // CVideoPlaybackUserInputHandler::HandleFastForward()
   211 // CVideoPlaybackUserInputHandler::HandleFastForward()
   244 // -------------------------------------------------------------------------------------------------
   212 // -------------------------------------------------------------------------------------------------
   245 //
   213 //
   246 void CVideoPlaybackUserInputHandler::HandleFastForward( TRemConCoreApiButtonAction aButtonAct )
   214 void CVideoPlaybackUserInputHandler::HandleFastForward( TRemConCoreApiButtonAction aButtonAct )
   247 {
   215 {
   248     if (aButtonAct == ERemConCoreApiButtonPress)
   216     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleFastForward()"));
   249     {
   217 
   250         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekForward));
   218     if ( aButtonAct == ERemConCoreApiButtonPress )
   251     }
   219     {
   252     else if (aButtonAct == ERemConCoreApiButtonRelease)
   220         TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdSeekForward ) );
   253     {
   221     }
   254         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek));
   222     else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   223     {
       
   224         TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdEndSeek ) );
   255     }
   225     }
   256 }
   226 }
   257 
   227 
   258 
   228 
   259 // -------------------------------------------------------------------------------------------------
   229 // -------------------------------------------------------------------------------------------------
   260 // CVideoPlaybackUserInputHandler::HandleRewind()
   230 // CVideoPlaybackUserInputHandler::HandleRewind()
   261 // -------------------------------------------------------------------------------------------------
   231 // -------------------------------------------------------------------------------------------------
   262 //
   232 //
   263 void CVideoPlaybackUserInputHandler::HandleRewind( TRemConCoreApiButtonAction aButtonAct )
   233 void CVideoPlaybackUserInputHandler::HandleRewind( TRemConCoreApiButtonAction aButtonAct )
   264 {
   234 {
   265     if (aButtonAct == ERemConCoreApiButtonPress)
   235     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleFastForward()"));
   266     {
   236 
   267         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekBackward));
   237     if ( aButtonAct == ERemConCoreApiButtonPress )
   268     }
   238     {
   269     else if (aButtonAct == ERemConCoreApiButtonRelease)
   239         TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdSeekBackward ) );
   270     {
   240     }
   271         TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek));
   241     else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   242     {
       
   243         TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdEndSeek ) );
   272     }
   244     }
   273 }
   245 }
   274 
   246 
   275 // -------------------------------------------------------------------------------------------------
   247 // -------------------------------------------------------------------------------------------------
   276 // CVideoPlaybackUserInputHandler::HandleVolumeUp()
   248 // CVideoPlaybackUserInputHandler::HandleVolumeUp()
   277 // -------------------------------------------------------------------------------------------------
   249 // -------------------------------------------------------------------------------------------------
   278 //
   250 //
   279 void CVideoPlaybackUserInputHandler::HandleVolumeUp( TRemConCoreApiButtonAction aButtonAct )
   251 void CVideoPlaybackUserInputHandler::HandleVolumeUp( TRemConCoreApiButtonAction aButtonAct )
   280 {
   252 {
       
   253     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleVolumeUp()"),
       
   254                    _L("aButtonAct = %d"), aButtonAct );
       
   255 
   281     switch ( aButtonAct )
   256     switch ( aButtonAct )
   282     {
   257     {
   283         case ERemConCoreApiButtonPress:
   258         case ERemConCoreApiButtonPress:
   284         {
   259         {
   285             // Volume Up - Pressed
   260             // Volume Up - Pressed
   287             {
   262             {
   288                 iVolumeRepeatTimer->Cancel();
   263                 iVolumeRepeatTimer->Cancel();
   289             }
   264             }
   290 
   265 
   291             iVolumeRepeatUp = ETrue;
   266             iVolumeRepeatUp = ETrue;
       
   267 
   292             iVolumeRepeatTimer->Start(
   268             iVolumeRepeatTimer->Start(
   293                 KAknStandardKeyboardRepeatRate,
   269                 KAknStandardKeyboardRepeatRate,
   294                 KAknStandardKeyboardRepeatRate,
   270                 KAknStandardKeyboardRepeatRate,
   295                 TCallBack(
   271                 TCallBack(
   296                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
   272                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
   311             break;
   287             break;
   312         }
   288         }
   313     }
   289     }
   314 }
   290 }
   315 
   291 
   316 
       
   317 // -------------------------------------------------------------------------------------------------
   292 // -------------------------------------------------------------------------------------------------
   318 // CVideoPlaybackUserInputHandler::HandleVolumeDown()
   293 // CVideoPlaybackUserInputHandler::HandleVolumeDown()
   319 // -------------------------------------------------------------------------------------------------
   294 // -------------------------------------------------------------------------------------------------
   320 //
   295 //
   321 void CVideoPlaybackUserInputHandler::HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct )
   296 void CVideoPlaybackUserInputHandler::HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct )
   322 {
   297 {
       
   298     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleVolumeDown()"));
       
   299 
   323     switch ( aButtonAct )
   300     switch ( aButtonAct )
   324     {
   301     {
   325         case ERemConCoreApiButtonPress:
   302         case ERemConCoreApiButtonPress:
   326         {
   303         {
   327             // Volume Up - Pressed
   304             // Volume Up - Pressed
   329             {
   306             {
   330                 iVolumeRepeatTimer->Cancel();
   307                 iVolumeRepeatTimer->Cancel();
   331             }
   308             }
   332 
   309 
   333             iVolumeRepeatUp = EFalse;
   310             iVolumeRepeatUp = EFalse;
       
   311 
   334             iVolumeRepeatTimer->Start(
   312             iVolumeRepeatTimer->Start(
   335                 KAknStandardKeyboardRepeatRate,
   313                 KAknStandardKeyboardRepeatRate,
   336                 KAknStandardKeyboardRepeatRate,
   314                 KAknStandardKeyboardRepeatRate,
   337                 TCallBack(
   315                 TCallBack(
   338                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
   316                     CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
   353             break;
   331             break;
   354         }
   332         }
   355     }
   333     }
   356 }
   334 }
   357 
   335 
   358 // -------------------------------------------------------------------------------------------------
   336 /*
   359 // CVideoPlaybackUserInputHandler::ProcessKeyEvent()
   337 // -------------------------------------------------------------------------------------------------
   360 // -------------------------------------------------------------------------------------------------
   338 // CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent()
   361 //
   339 // -------------------------------------------------------------------------------------------------
   362 void CVideoPlaybackUserInputHandler::ProcessKeyEventL( const TKeyEvent& /*aKeyEvent*/,
   340 //
   363                                                        TEventCode /*aType*/ )
   341 void
   364 {
   342 CMPXVideoPlaybackUserInputHandler::ProcessPointerEventL( CCoeControl* aControl,
   365     MPX_DEBUG(_L("VideoPlaybackUserInputHandler::ProcessKeyEvent"));
   343                                                          const TPointerEvent& aPointerEvent,
   366 
   344                                                          TMPXVideoControlType aControl )
   367     /*
   345 {
   368     switch (iProcessingInputType)
   346     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent()"),
   369     {
   347                    _L("iProcessingInputType = %d, aPointerEvent.iType = %d"),
   370         case EVideoNone:
   348                    iProcessingInputType, aPointerEvent.iType );
   371         {
   349 
   372             if (aType == EEventKeyDown && iForeground)
   350     switch ( iProcessingInputType )
   373             {
   351     {
   374                 iProcessingInputType = EVideoKeyboard;
   352         case EMpxVideoNone:
   375                 iLastPressedKeyCode = aKeyEvent.iCode;
   353         {
   376                 iLastPressedKeyScanCode = aKeyEvent.iScanCode;
   354             if ( aPointerEvent.iType == TPointerEvent::EButton1Down && IsUserInputAllowed() )
   377                 if ( iTVOutConnected )
   355             {
   378                 {    
   356                 iProcessingInputType = EMpxVideoTouch;
   379                     RestartDisplayTimer();
   357 
       
   358                 //
       
   359                 //  Save the active controls pointer to reroute invalid pointer events
       
   360                 //
       
   361                 iActiveControlPtr = aControl;
       
   362                 iActiveControlType = aMPXControl;
       
   363 
       
   364                 ReRoutePointerEventL( aControl, aPointerEvent, aMPXControl );
       
   365             }
       
   366 
       
   367             break;
       
   368         }
       
   369         case EMpxVideoTouch:
       
   370         {
       
   371             if ( aControl == iActiveControlPtr )
       
   372             {
       
   373                 //
       
   374                 //  Event is from the active control, process pointer event normally
       
   375                 //
       
   376                 if ( aPointerEvent.iType != TPointerEvent::EButton1Down )
       
   377                 {
       
   378                     ReRoutePointerEventL( aControl, aPointerEvent, aMPXControl );
       
   379 
       
   380                     //
       
   381                     //  reset the value only on pointer up event - but not on drag
       
   382                     //
       
   383                     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   384                     {
       
   385                         iProcessingInputType = EMpxVideoNone;
       
   386                         iActiveControlPtr = NULL;
       
   387                     }
   380                 }
   388                 }
   381                 iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType );
   389             }
   382             }
   390             else
   383             break;
   391             {
   384         }
   392                 //
   385         case EVideoKeyboard:
   393                 //  Event is from non active control
   386         {
   394                 //  This should not happen, but if event is a button up event,
   387             if (aType == EEventKeyUp)
   395                 //  end the current active control pointer processing
   388             {
   396                 //
   389                 // only handle up event for the key being handled
   397                 if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   390                 // ignore spurious key presses
       
   391                 if (aKeyEvent.iCode == iLastPressedKeyCode  &&
       
   392                     aKeyEvent.iScanCode == iLastPressedKeyScanCode)
       
   393                 {
   398                 {
   394                     iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType );
   399                     //
   395 
   400                     //  Reroute button up event to active control and end current
   396                     // reset the value only on key up event
   401                     //  control processing
   397                     iProcessingInputType = EVideoNone;
   402                     //
       
   403                     ReRoutePointerEventL( iActiveControlPtr, aPointerEvent, iActiveControlType );
       
   404                     iProcessingInputType = EMpxVideoNone;
       
   405                     iActiveControlPtr = NULL;
   398                 }
   406                 }
   399             }
   407             }
   400             break;
   408 
   401         }
   409             break;
   402         default:
   410         }
   403         {
   411     } // switch
   404             // user input is disallowed
   412 }
   405             break;
   413 
   406         }
   414 // -------------------------------------------------------------------------------------------------
   407     } // switch*/
   415 //   CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL()
   408 }
   416 // -------------------------------------------------------------------------------------------------
       
   417 //
       
   418 void CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL( CCoeControl* aControl,
       
   419                                                               const TPointerEvent& aPointerEvent,
       
   420                                                               TVideoControlType aMPXControl )
       
   421 {
       
   422     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL()"),
       
   423                    _L("aMPXControl = %d"), aMPXControl );
       
   424 
       
   425     if ( aMPXControl == EMpxVideoPlaybackContainer )
       
   426     {
       
   427         iContainer->DoHandlePointerEventL( aPointerEvent );
       
   428     }
       
   429     else if ( aMPXControl == EMpxVideoPlaybackControl )
       
   430     {
       
   431         static_cast<CMPXVideoPlaybackControl*>(aControl)->DoHandlePointerEventL( aPointerEvent );
       
   432     }
       
   433 }*/
   409 
   434 
   410 // -------------------------------------------------------------------------------------------------
   435 // -------------------------------------------------------------------------------------------------
   411 // CVideoPlaybackUserInputHandler::ProcessMediaKey()
   436 // CVideoPlaybackUserInputHandler::ProcessMediaKey()
   412 // -------------------------------------------------------------------------------------------------
   437 // -------------------------------------------------------------------------------------------------
   413 //
   438 //
   414 void CVideoPlaybackUserInputHandler::ProcessMediaKey( TRemConCoreApiOperationId aOperationId,
   439 void CVideoPlaybackUserInputHandler::ProcessMediaKey( TRemConCoreApiOperationId aOperationId,
   415                                                       TRemConCoreApiButtonAction aButtonAct )
   440                                                       TRemConCoreApiButtonAction aButtonAct )
   416 {
   441 {
   417     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ProcessMediaKey"));
   442     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ProcessMediaKey()"),
   418 
   443                    _L("iProcessingInputType = %d, aButtonAct = %d"),
   419     switch (iProcessingInputType)
   444                        iProcessingInputType, aButtonAct );
       
   445 
       
   446     switch ( iProcessingInputType )
   420     {
   447     {
   421         case EVideoNone:
   448         case EVideoNone:
   422         {
   449         {
   423             if (aButtonAct == ERemConCoreApiButtonPress && iForeground)
   450             if ( iForeground && !IsKeyLocked() )
   424             {
   451             {
   425                 iProcessingInputType = EVideoMediaKeys;
   452                 if ( aButtonAct == ERemConCoreApiButtonPress )
   426                 iLastMediaKeyPressed = aOperationId;
   453                 {
   427                 DoHandleMediaKey(aOperationId, aButtonAct);
   454                     iProcessingInputType = EVideoMediaKeys;
   428                 if ( iTVOutConnected )
   455                     iLastMediaKeyPressed = aOperationId;
   429                 {    
   456                     DoHandleMediaKey( aOperationId, aButtonAct );
   430                     RestartDisplayTimer();
       
   431                 }
   457                 }
   432             }
   458                 else if ( aButtonAct == ERemConCoreApiButtonClick )
   433             else if (aButtonAct == ERemConCoreApiButtonClick && iForeground)
       
   434             {
       
   435                 DoHandleMediaKey(aOperationId, aButtonAct);
       
   436                 if ( iTVOutConnected )
       
   437                 {    
       
   438                     RestartDisplayTimer();
       
   439                 }
       
   440                 // reset on click AND/OR release
       
   441                 iProcessingInputType = EVideoNone;
       
   442             }
       
   443             break;
       
   444         }
       
   445         case EVideoMediaKeys:
       
   446         {
       
   447             if (aButtonAct == ERemConCoreApiButtonRelease)
       
   448             {
       
   449                 // handle only if this release is for media-key being currently handled
       
   450                 // ignore spurious media key presses
       
   451                 if (iLastMediaKeyPressed == aOperationId)
       
   452                 {
   459                 {
   453                     DoHandleMediaKey(aOperationId, aButtonAct);
   460                     DoHandleMediaKey( aOperationId, aButtonAct );
       
   461 
   454                     // reset on click AND/OR release
   462                     // reset on click AND/OR release
   455                     iProcessingInputType = EVideoNone;
   463                     iProcessingInputType = EVideoNone;
   456                 }
   464                 }
   457             }
   465             }
       
   466 
       
   467             break;
       
   468         }
       
   469         case EVideoMediaKeys:
       
   470         {
       
   471             if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   472             {
       
   473                 // handle only if this release is for media-key being currently handled
       
   474                 // ignore spurious media key presses
       
   475                 if ( iLastMediaKeyPressed == aOperationId )
       
   476                 {
       
   477                     DoHandleMediaKey( aOperationId, aButtonAct );
       
   478                     // reset on click AND/OR release
       
   479                     iProcessingInputType = EVideoNone;
       
   480                 }
       
   481             }
   458             break;
   482             break;
   459         }
   483         }
   460         default:
   484         default:
   461         {
   485         {
   462             // user input is disallowed
   486             // user input is disallowed
   463             break;
   487             break;
   464         }
   488         }
   465     } // switch
   489     } // switch
   466 }
   490 }
   467 
   491 
   468 
       
   469 // -------------------------------------------------------------------------------------------------
   492 // -------------------------------------------------------------------------------------------------
   470 //   CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()
   493 //   CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()
   471 // -------------------------------------------------------------------------------------------------
   494 // -------------------------------------------------------------------------------------------------
   472 //
   495 //
   473 TInt CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL( TAny* aPtr )
   496 TInt CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL( TAny* aPtr )
   495     }
   518     }
   496 
   519 
   497     iViewWrapper->HandleCommandL( command );
   520     iViewWrapper->HandleCommandL( command );
   498 }
   521 }
   499 
   522 
   500 
       
   501 // -------------------------------------------------------------------------------------------------
   523 // -------------------------------------------------------------------------------------------------
   502 //   CVideoPlaybackUserInputHandler::SetForeground()
   524 //   CVideoPlaybackUserInputHandler::SetForeground()
   503 // -------------------------------------------------------------------------------------------------
   525 // -------------------------------------------------------------------------------------------------
   504 //
   526 //
   505 void CVideoPlaybackUserInputHandler::SetForeground( TBool aForeground )
   527 void CVideoPlaybackUserInputHandler::SetForeground( TBool aForeground )
   506 {
   528 {
       
   529     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::SetForeground()"),
       
   530                    _L("aForeground = %d"), aForeground );
       
   531 
   507     iForeground = aForeground;
   532     iForeground = aForeground;
   508 
   533 
   509     if ( !iForeground )
   534     if ( ! iForeground )
   510     {
   535     {
   511         // we are in background so reset iProcessingInputType value
   536         //
       
   537         //  Keyboard focus has been lost
       
   538         //  Reset input type and clear volume timer if necessary
       
   539         //
   512         iProcessingInputType = EVideoNone;
   540         iProcessingInputType = EVideoNone;
   513     }
   541 
   514 }
   542         if ( iVolumeRepeatTimer->IsActive() )
   515 
   543         {
   516 // -------------------------------------------------------------------------------------------------
   544             iVolumeRepeatTimer->Cancel();
   517 // CVideoPlaybackUserInputHandler::DisableBacklight()
   545         }
   518 // -------------------------------------------------------------------------------------------------
   546     }
   519 //
   547 }
   520 void CVideoPlaybackUserInputHandler::DisableBacklight()
   548 
   521 {
   549 // -------------------------------------------------------------------------------------------------
   522     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DisableBacklight"));
   550 //   CVideoPlaybackUserInputHandler::IsKeyLocked
   523     
   551 // -------------------------------------------------------------------------------------------------
   524     // cancel the timer
   552 //
   525     iDisplayTimer->Cancel(); 
   553 TBool CVideoPlaybackUserInputHandler::IsKeyLocked()
   526 
   554 {
   527     // disable the backlight
   555     TBool keylock( EFalse );
   528     HAL::Set( HALData::EBacklightState, 0 );
   556     RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock );
   529 }
   557 
   530 
   558     MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::IsKeyLocked(%d)"), keylock);
   531 // -------------------------------------------------------------------------------------------------
   559 
   532 // CVideoPlaybackUserInputHandler::EnableBacklight()
   560     return keylock;
   533 // -------------------------------------------------------------------------------------------------
       
   534 //
       
   535 void CVideoPlaybackUserInputHandler::EnableBacklight()
       
   536 {
       
   537     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::EnableBacklight"));
       
   538  
       
   539     // enable the backlight
       
   540     HAL::Set( HALData::EBacklightState, 1 );    
       
   541 }
       
   542 
       
   543 
       
   544 // -------------------------------------------------------------------------------------------------
       
   545 //   CVideoPlaybackUserInputHandler::HandleTVOutEvent()
       
   546 // -------------------------------------------------------------------------------------------------
       
   547 //
       
   548 void CVideoPlaybackUserInputHandler::HandleTVOutEventL(TBool aTVOutConnected)
       
   549 {
       
   550     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleTVOutEvent"));
       
   551 
       
   552     iTVOutConnected = aTVOutConnected;
       
   553 
       
   554     if ( iTVOutConnected )
       
   555     {
       
   556         // Get the display light time-out value from CenRep 
       
   557         CRepository* repository = CRepository::NewLC( KCRUidLightSettings );
       
   558     
       
   559         // What's the timeout value (in seconds ) for the display light?
       
   560         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   561         MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   562     
       
   563         CleanupStack::PopAndDestroy( repository );
       
   564     
       
   565         // Convert the timeout value to microseconds
       
   566         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   567     
       
   568         RestartDisplayTimer();
       
   569     }
       
   570     else
       
   571     {
       
   572         iDisplayTimer->Cancel(); 
       
   573         EnableBacklight();
       
   574     }
       
   575 }
       
   576 
       
   577 // -------------------------------------------------------------------------------------------------
       
   578 //   CVideoPlaybackUserInputHandler::HandleDisplayTimeout
       
   579 // -------------------------------------------------------------------------------------------------
       
   580 //
       
   581 TInt CVideoPlaybackUserInputHandler::HandleDisplayTimeout( TAny* aPtr )
       
   582 {
       
   583     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleDisplayTimeout"));
       
   584 
       
   585     static_cast<CVideoPlaybackUserInputHandler*>(aPtr)->DisableBacklight();
       
   586 
       
   587     return KErrNone;
       
   588 }
       
   589 
       
   590 // -----------------------------------------------------------------------------
       
   591 // CVideoPlaybackUserInputHandler::RestartDisplayTimer
       
   592 // -----------------------------------------------------------------------------
       
   593 //
       
   594 void CVideoPlaybackUserInputHandler::RestartDisplayTimer()
       
   595 {
       
   596     MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::RestartDisplayTimer"));
       
   597 
       
   598     // check if the display timer is running if so cancelit
       
   599     if ( iDisplayTimer->IsActive() )
       
   600     {
       
   601         iDisplayTimer->Cancel(); 
       
   602     }
       
   603     else
       
   604     {
       
   605         // timeout has happened and the backlight is disabled
       
   606         // enable the backlight
       
   607         HAL::Set( HALData::EBacklightState, 1 );    
       
   608     }
       
   609     
       
   610     TBool backlightState;    
       
   611     TInt ret = HAL::Get( HALData::EBacklightState, backlightState );    
       
   612 
       
   613     // Re start the display backlight timer
       
   614     iDisplayTimer->Start( iDisplayTimeOut, iDisplayTimeOut,
       
   615                           TCallBack( CVideoPlaybackUserInputHandler::HandleDisplayTimeout, this ) );                     
       
   616 }
   561 }
   617 
   562 
   618 // EOF
   563 // EOF