videoplayback/videoplaybackviews/src/mpxvideoplaybackuserinputhandler.cpp
changeset 0 96612d01cf9f
child 8 ce5ada96ab30
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of playback view's input handler
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 14 %
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <w32std.h> // RWindowBase
       
    23 #include <e32base.h>
       
    24 #include <StringLoader.h>
       
    25 #include <AknUtils.h>
       
    26 #include <eikclbd.h>
       
    27 #include <aknconsts.h>
       
    28 #include <AknUtils.h>
       
    29 #include <AknIconUtils.h>  // SetSize for the icons
       
    30 #include <remconcoreapi.h>
       
    31 #include <remconcoreapitarget.h>
       
    32 #include <remconinterfaceselector.h> // Side volume key
       
    33 #include <mpxplaybackframeworkdefs.h>
       
    34 #include <centralrepository.h>  // for peripheral display timeout setting
       
    35 #include <settingsinternalcrkeys.h> // display timeout setting keys
       
    36 #include <hwrmlightdomaincrkeys.h>
       
    37 #include <e32std.h>
       
    38 
       
    39 #ifdef __USERINPUTHANDLERSTIF__
       
    40 #include "videoplaybackcontainer_stub.h"
       
    41 #include "videoplaybackcontrol_stub.h"
       
    42 #include "hal_stub.h"
       
    43 #else
       
    44 #include "mpxvideoplaybackcontainer.h"
       
    45 #include "mpxvideoplaybackcontrol.h"
       
    46 #include <hal.h>
       
    47 #include <hal_data.h>
       
    48 #endif
       
    49 
       
    50 #include "mpxvideoplaybackcontrol.hrh"
       
    51 #include "mpxvideoplaybackuserinputhandler.h"
       
    52 
       
    53 #include <mpxvideoplaybackdefs.h>
       
    54 #include "mpxcommonvideoplaybackview.hrh"
       
    55 #include "mpxvideo_debug.h"
       
    56 
       
    57 
       
    58 // CONSTANTS
       
    59 const TInt KMPXMicroSecondsInASecond = 1000000;
       
    60 
       
    61 
       
    62 // ======== MEMBER FUNCTIONS =======================================================================
       
    63 
       
    64 // -------------------------------------------------------------------------------------------------
       
    65 // MPXVideoPlaybackUserInputHandler::CMPXVideoPlaybackUserInputHandler()
       
    66 // -------------------------------------------------------------------------------------------------
       
    67 //
       
    68 CMPXVideoPlaybackUserInputHandler::CMPXVideoPlaybackUserInputHandler(
       
    69         CMPXVideoPlaybackContainer* aContainer)
       
    70    : iContainer(aContainer)
       
    71 {
       
    72 }
       
    73 
       
    74 // -------------------------------------------------------------------------------------------------
       
    75 // CMPXVideoPlaybackUserInputHandler::NewL()
       
    76 // -------------------------------------------------------------------------------------------------
       
    77 //
       
    78 CMPXVideoPlaybackUserInputHandler* CMPXVideoPlaybackUserInputHandler::NewL(
       
    79         CMPXVideoPlaybackContainer* aContainer, TBool aTvOutConnected)
       
    80 {
       
    81     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::NewL()"));
       
    82 
       
    83     CMPXVideoPlaybackUserInputHandler* self =
       
    84         new (ELeave) CMPXVideoPlaybackUserInputHandler( aContainer );
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL(aTvOutConnected);
       
    87     CleanupStack::Pop();
       
    88     return self;
       
    89 }
       
    90 
       
    91 // -------------------------------------------------------------------------------------------------
       
    92 // CMPXVideoPlaybackUserInputHandler::ConstructL
       
    93 // Symbian 2nd phase constructor can leave.
       
    94 // -------------------------------------------------------------------------------------------------
       
    95 //
       
    96 void CMPXVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected )
       
    97 {
       
    98     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ConstructL()"));
       
    99 
       
   100     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   101     iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
       
   102     iInterfaceSelector = CRemConInterfaceSelector::NewL();
       
   103     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
       
   104 
       
   105     iTVOutConnected = aTvOutConnected;
       
   106 
       
   107     // Start the timer if TV out is connected
       
   108     if ( iTVOutConnected )
       
   109     {
       
   110         // Get the display light time-out value from CenRep
       
   111         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );
       
   112 
       
   113         // What's the timeout value (in seconds ) for the display light?
       
   114         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   115         MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   116 
       
   117         CleanupStack::PopAndDestroy( repository );
       
   118 
       
   119         // Convert the timeout value to microseconds
       
   120         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   121 
       
   122         RestartDisplayTimer();
       
   123     }
       
   124 
       
   125     // not detrimental if Media Keys dont work - so ignore any errors here
       
   126     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
       
   127 
       
   128     iProcessingInputType = EMpxVideoNone;
       
   129     iForeground = ETrue;
       
   130 }
       
   131 
       
   132 // -------------------------------------------------------------------------------------------------
       
   133 // CMPXVideoPlaybackUserInputHandler::~CMPXVideoPlaybackUserInputHandler()
       
   134 // -------------------------------------------------------------------------------------------------
       
   135 //
       
   136 CMPXVideoPlaybackUserInputHandler::~CMPXVideoPlaybackUserInputHandler()
       
   137 {
       
   138     if ( iVolumeRepeatTimer )
       
   139     {
       
   140         iVolumeRepeatTimer->Cancel();
       
   141         delete iVolumeRepeatTimer;
       
   142     }
       
   143 
       
   144     if ( iDisplayTimer )
       
   145     {
       
   146         iDisplayTimer->Cancel();
       
   147         delete iDisplayTimer;
       
   148     }
       
   149 
       
   150     if ( iInterfaceSelector )
       
   151     {
       
   152         delete iInterfaceSelector;
       
   153         iCoreTarget = NULL;
       
   154         iInterfaceSelector = NULL;
       
   155     }
       
   156 
       
   157     // make sure that backlight enabled when
       
   158     // the view updates or deactivates
       
   159     EnableBacklight();
       
   160 
       
   161 }
       
   162 
       
   163 // -------------------------------------------------------------------------------------------------
       
   164 // CMPXVideoPlaybackUserInputHandler::MrccatoPlay()
       
   165 // -------------------------------------------------------------------------------------------------
       
   166 //
       
   167 void CMPXVideoPlaybackUserInputHandler::MrccatoPlay( TRemConCoreApiPlaybackSpeed /*aSpeed*/,
       
   168                                                      TRemConCoreApiButtonAction aButtonAct )
       
   169 {
       
   170     MPX_ENTER_EXIT(
       
   171         _L("CMPXVideoPlaybackUserInputHandler::MrccatoPlay"),
       
   172         _L("aButtonAct = %d"), aButtonAct );
       
   173 
       
   174     ProcessMediaKey(ERemConCoreApiPlay, aButtonAct);
       
   175 }
       
   176 
       
   177 // -------------------------------------------------------------------------------------------------
       
   178 // CMPXVideoPlaybackUserInputHandler::MrccatoCommand()
       
   179 // -------------------------------------------------------------------------------------------------
       
   180 //
       
   181 void CMPXVideoPlaybackUserInputHandler::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
       
   182                                                        TRemConCoreApiButtonAction aButtonAct )
       
   183 {
       
   184     MPX_ENTER_EXIT(
       
   185         _L("CMPXVideoPlaybackUserInputHandler::MrccatoCommand"),
       
   186         _L("aButtonAct = %d"), aButtonAct );
       
   187 
       
   188     ProcessMediaKey(aOperationId, aButtonAct);
       
   189 }
       
   190 
       
   191 // -------------------------------------------------------------------------------------------------
       
   192 // CMPXVideoPlaybackUserInputHandler::DoHandleMediaKey()
       
   193 // -------------------------------------------------------------------------------------------------
       
   194 //
       
   195 void CMPXVideoPlaybackUserInputHandler::DoHandleMediaKey( TRemConCoreApiOperationId aOperationId,
       
   196                                                           TRemConCoreApiButtonAction aButtonAct )
       
   197 {
       
   198     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::DoHandleMediaKey()"));
       
   199 
       
   200     switch ( aOperationId )
       
   201     {
       
   202         case ERemConCoreApiStop:
       
   203         {
       
   204             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   205             {
       
   206                 //
       
   207                 //  When the stop key is pressed from the remote control interface,
       
   208                 //  issue a softkey back so all views will exit the playback view.
       
   209                 //
       
   210                 TRAP_IGNORE( iContainer->HandleCommandL( EAknSoftkeyBack ) );
       
   211             }
       
   212             break;
       
   213         }
       
   214         case ERemConCoreApiRewind:
       
   215         {
       
   216             HandleRewind(aButtonAct);
       
   217             break;
       
   218         }
       
   219         case ERemConCoreApiFastForward:
       
   220         {
       
   221             HandleFastForward(aButtonAct);
       
   222             break;
       
   223         }
       
   224         case ERemConCoreApiVolumeUp:
       
   225         {
       
   226             HandleVolumeUp(aButtonAct);
       
   227             break;
       
   228         }
       
   229         case ERemConCoreApiVolumeDown:
       
   230         {
       
   231             HandleVolumeDown(aButtonAct);
       
   232             break;
       
   233         }
       
   234         case ERemConCoreApiPausePlayFunction:
       
   235         {
       
   236             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   237             {
       
   238                 TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdPlayPause));
       
   239             }
       
   240             break;
       
   241         }
       
   242         case ERemConCoreApiPause:
       
   243         {
       
   244             TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdPause));
       
   245             break;
       
   246         }
       
   247         case ERemConCoreApiPlay:
       
   248         {
       
   249             if ( aButtonAct == ERemConCoreApiButtonClick )
       
   250             {
       
   251                 TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdPlay));
       
   252             }
       
   253             break;
       
   254         }
       
   255         default:
       
   256             break;
       
   257     }
       
   258 }
       
   259 
       
   260 // -------------------------------------------------------------------------------------------------
       
   261 // CMPXVideoPlaybackUserInputHandler::HandleFastForward()
       
   262 // -------------------------------------------------------------------------------------------------
       
   263 //
       
   264 void CMPXVideoPlaybackUserInputHandler::HandleFastForward(TRemConCoreApiButtonAction aButtonAct)
       
   265 {
       
   266     if (aButtonAct == ERemConCoreApiButtonPress)
       
   267     {
       
   268         TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdSeekForward));
       
   269     }
       
   270     else if (aButtonAct == ERemConCoreApiButtonRelease)
       
   271     {
       
   272         TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdEndSeek));
       
   273     }
       
   274 }
       
   275 
       
   276 
       
   277 // -------------------------------------------------------------------------------------------------
       
   278 // CMPXVideoPlaybackUserInputHandler::HandleRewind()
       
   279 // -------------------------------------------------------------------------------------------------
       
   280 //
       
   281 void CMPXVideoPlaybackUserInputHandler::HandleRewind(TRemConCoreApiButtonAction aButtonAct)
       
   282 {
       
   283     if (aButtonAct == ERemConCoreApiButtonPress)
       
   284     {
       
   285         TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdSeekBackward));
       
   286     }
       
   287     else if (aButtonAct == ERemConCoreApiButtonRelease)
       
   288     {
       
   289         TRAP_IGNORE(iContainer->HandleCommandL(EMPXPbvCmdEndSeek));
       
   290     }
       
   291 }
       
   292 
       
   293 // -------------------------------------------------------------------------------------------------
       
   294 // CMPXVideoPlaybackUserInputHandler::HandleVolumeUp()
       
   295 // -------------------------------------------------------------------------------------------------
       
   296 //
       
   297 void CMPXVideoPlaybackUserInputHandler::HandleVolumeUp(TRemConCoreApiButtonAction aButtonAct)
       
   298 {
       
   299     switch ( aButtonAct )
       
   300     {
       
   301         case ERemConCoreApiButtonPress:
       
   302         {
       
   303             // Volume Up - Pressed
       
   304             if ( iVolumeRepeatTimer->IsActive() )
       
   305             {
       
   306                 iVolumeRepeatTimer->Cancel();
       
   307             }
       
   308 
       
   309             iVolumeRepeatUp = ETrue;
       
   310             iVolumeRepeatTimer->Start(
       
   311                 KAknStandardKeyboardRepeatRate,
       
   312                 KAknStandardKeyboardRepeatRate,
       
   313                 TCallBack(
       
   314                     CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
       
   315                     this ) );
       
   316 
       
   317             break;
       
   318         }
       
   319         case ERemConCoreApiButtonRelease:
       
   320         {
       
   321             // Volume Up - Released
       
   322             iVolumeRepeatTimer->Cancel();
       
   323             break;
       
   324         }
       
   325         case ERemConCoreApiButtonClick:
       
   326         {
       
   327             // Volume Up - Clicked
       
   328             TRAP_IGNORE( iContainer->HandleCommandL( EMPXPbvCmdIncreaseVolume ) );
       
   329             break;
       
   330         }
       
   331     }
       
   332 }
       
   333 
       
   334 
       
   335 // -------------------------------------------------------------------------------------------------
       
   336 // CMPXVideoPlaybackUserInputHandler::HandleVolumeDown()
       
   337 // -------------------------------------------------------------------------------------------------
       
   338 //
       
   339 void CMPXVideoPlaybackUserInputHandler::HandleVolumeDown(TRemConCoreApiButtonAction aButtonAct)
       
   340 {
       
   341     switch ( aButtonAct )
       
   342     {
       
   343         case ERemConCoreApiButtonPress:
       
   344         {
       
   345             // Volume Up - Pressed
       
   346             if ( iVolumeRepeatTimer->IsActive() )
       
   347             {
       
   348                 iVolumeRepeatTimer->Cancel();
       
   349             }
       
   350 
       
   351             iVolumeRepeatUp = EFalse;
       
   352             iVolumeRepeatTimer->Start(
       
   353                 KAknStandardKeyboardRepeatRate,
       
   354                 KAknStandardKeyboardRepeatRate,
       
   355                 TCallBack(
       
   356                     CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL,
       
   357                     this ) );
       
   358 
       
   359             break;
       
   360         }
       
   361         case ERemConCoreApiButtonRelease:
       
   362         {
       
   363             // Volume Up - Released
       
   364             iVolumeRepeatTimer->Cancel();
       
   365             break;
       
   366         }
       
   367         case ERemConCoreApiButtonClick:
       
   368         {
       
   369             // Volume Down - Clicked
       
   370             TRAP_IGNORE( iContainer->HandleCommandL( EMPXPbvCmdDecreaseVolume ) );
       
   371             break;
       
   372         }
       
   373     }
       
   374 }
       
   375 
       
   376 
       
   377 // -------------------------------------------------------------------------------------------------
       
   378 // CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent()
       
   379 // -------------------------------------------------------------------------------------------------
       
   380 //
       
   381 EXPORT_C void
       
   382 CMPXVideoPlaybackUserInputHandler::ProcessPointerEventL( CCoeControl* aControl,
       
   383                                                          const TPointerEvent& aPointerEvent,
       
   384                                                          TMPXVideoControlType aMPXControl )
       
   385 {
       
   386     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent"));
       
   387 
       
   388     switch (iProcessingInputType)
       
   389     {
       
   390         case EMpxVideoNone:
       
   391         {
       
   392             if (aPointerEvent.iType == TPointerEvent::EButton1Down && iForeground)
       
   393             {
       
   394                 iProcessingInputType = EMpxVideoTouch;
       
   395                 if ( iTVOutConnected )
       
   396                 {
       
   397                     RestartDisplayTimer();
       
   398                 }
       
   399                 ReRoutePointerEventL(aControl, aPointerEvent, aMPXControl);
       
   400             }
       
   401             break;
       
   402         }
       
   403         case EMpxVideoTouch:
       
   404         {
       
   405             if (aPointerEvent.iType != TPointerEvent::EButton1Down)
       
   406             {
       
   407                 ReRoutePointerEventL(aControl, aPointerEvent, aMPXControl);
       
   408 
       
   409                 // reset the value only on pointer up event - but not on drag
       
   410                 if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   411                 {
       
   412                     iProcessingInputType = EMpxVideoNone;
       
   413                 }
       
   414             }
       
   415             break;
       
   416         }
       
   417         default:
       
   418         {
       
   419             // user input is disallowed
       
   420             break;
       
   421         }
       
   422     } // switch
       
   423 }
       
   424 
       
   425 
       
   426 // -------------------------------------------------------------------------------------------------
       
   427 // CMPXVideoPlaybackUserInputHandler::ProcessKeyEvent()
       
   428 // -------------------------------------------------------------------------------------------------
       
   429 //
       
   430 void CMPXVideoPlaybackUserInputHandler::ProcessKeyEventL( const TKeyEvent& aKeyEvent,
       
   431                                                           TEventCode aType )
       
   432 {
       
   433     MPX_DEBUG(_L("MPXVideoPlaybackUserInputHandler::ProcessKeyEvent"));
       
   434 
       
   435     switch (iProcessingInputType)
       
   436     {
       
   437         case EMpxVideoNone:
       
   438         {
       
   439             if (aType == EEventKeyDown && iForeground)
       
   440             {
       
   441                 iProcessingInputType = EMpxVideoKeyboard;
       
   442                 iLastPressedKeyCode = aKeyEvent.iCode;
       
   443                 iLastPressedKeyScanCode = aKeyEvent.iScanCode;
       
   444                 if ( iTVOutConnected )
       
   445                 {
       
   446                     RestartDisplayTimer();
       
   447                 }
       
   448                 iContainer->DoHandleKeyEventL(aKeyEvent, aType);
       
   449             }
       
   450             break;
       
   451         }
       
   452         case EMpxVideoKeyboard:
       
   453         {
       
   454             if (aType == EEventKeyUp)
       
   455             {
       
   456                 // only handle up event for the key being handled
       
   457                 // ignore spurious key presses
       
   458                 if (aKeyEvent.iCode == iLastPressedKeyCode  &&
       
   459                     aKeyEvent.iScanCode == iLastPressedKeyScanCode)
       
   460                 {
       
   461                     iContainer->DoHandleKeyEventL(aKeyEvent, aType);
       
   462 
       
   463                     // reset the value only on key up event
       
   464                     iProcessingInputType = EMpxVideoNone;
       
   465                 }
       
   466             }
       
   467             break;
       
   468         }
       
   469         default:
       
   470         {
       
   471             // user input is disallowed
       
   472             break;
       
   473         }
       
   474     } // switch
       
   475 }
       
   476 
       
   477 // -------------------------------------------------------------------------------------------------
       
   478 // CMPXVideoPlaybackUserInputHandler::ProcessMediaKey()
       
   479 // -------------------------------------------------------------------------------------------------
       
   480 //
       
   481 void CMPXVideoPlaybackUserInputHandler::ProcessMediaKey( TRemConCoreApiOperationId aOperationId,
       
   482                                                          TRemConCoreApiButtonAction aButtonAct )
       
   483 {
       
   484     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ProcessMediaKey"));
       
   485 
       
   486     switch ( iProcessingInputType )
       
   487     {
       
   488         case EMpxVideoNone:
       
   489         {
       
   490             if ( aButtonAct == ERemConCoreApiButtonPress && iForeground )
       
   491             {
       
   492                 iProcessingInputType = EMpxVideoMediaKeys;
       
   493                 iLastMediaKeyPressed = aOperationId;
       
   494                 DoHandleMediaKey(aOperationId, aButtonAct);
       
   495                 if ( iTVOutConnected )
       
   496                 {
       
   497                     RestartDisplayTimer();
       
   498                 }
       
   499             }
       
   500             else if (aButtonAct == ERemConCoreApiButtonClick && iForeground)
       
   501             {
       
   502                 DoHandleMediaKey(aOperationId, aButtonAct);
       
   503                 if ( iTVOutConnected )
       
   504                 {
       
   505                     RestartDisplayTimer();
       
   506                 }
       
   507                 // reset on click AND/OR release
       
   508                 iProcessingInputType = EMpxVideoNone;
       
   509             }
       
   510             break;
       
   511         }
       
   512         case EMpxVideoMediaKeys:
       
   513         {
       
   514             if (aButtonAct == ERemConCoreApiButtonRelease)
       
   515             {
       
   516                 // handle only if this release is for media-key being currently handled
       
   517                 // ignore spurious media key presses
       
   518                 if (iLastMediaKeyPressed == aOperationId)
       
   519                 {
       
   520                     DoHandleMediaKey(aOperationId, aButtonAct);
       
   521                     // reset on click AND/OR release
       
   522                     iProcessingInputType = EMpxVideoNone;
       
   523                 }
       
   524             }
       
   525             break;
       
   526         }
       
   527         default:
       
   528         {
       
   529             // user input is disallowed
       
   530             break;
       
   531         }
       
   532     } // switch
       
   533 }
       
   534 
       
   535 
       
   536 // -------------------------------------------------------------------------------------------------
       
   537 //   CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()
       
   538 // -------------------------------------------------------------------------------------------------
       
   539 //
       
   540 TInt CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL( TAny* aPtr )
       
   541 {
       
   542     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL()"));
       
   543 
       
   544     static_cast<CMPXVideoPlaybackUserInputHandler*>(aPtr)->HandleVolumeRepeatL();
       
   545 
       
   546     return KErrNone;
       
   547 }
       
   548 
       
   549 // -------------------------------------------------------------------------------------------------
       
   550 //   CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatL()
       
   551 // -------------------------------------------------------------------------------------------------
       
   552 //
       
   553 void CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatL()
       
   554 {
       
   555     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::HandleVolumeRepeatL()"));
       
   556 
       
   557     TMPXVideoPlaybackViewCommandIds command = EMPXPbvCmdDecreaseVolume;
       
   558 
       
   559     if ( iVolumeRepeatUp )
       
   560     {
       
   561         command = EMPXPbvCmdIncreaseVolume;
       
   562     }
       
   563 
       
   564     iContainer->HandleCommandL( command );
       
   565 }
       
   566 
       
   567 
       
   568 // -------------------------------------------------------------------------------------------------
       
   569 //   CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL()
       
   570 // -------------------------------------------------------------------------------------------------
       
   571 //
       
   572 void CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL(CCoeControl* aControl,
       
   573                                                              const TPointerEvent& aPointerEvent,
       
   574                                                              TMPXVideoControlType aMPXControl)
       
   575 {
       
   576     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL()"));
       
   577 
       
   578     if ( aMPXControl == EMpxVideoPlaybackContainer )
       
   579     {
       
   580         iContainer->DoHandlePointerEventL(aPointerEvent);
       
   581     }
       
   582     else if ( aMPXControl == EMpxVideoPlaybackControl )
       
   583     {
       
   584         static_cast<CMPXVideoPlaybackControl*>(aControl)->DoHandlePointerEventL(aPointerEvent);
       
   585     }
       
   586 }
       
   587 
       
   588 // -------------------------------------------------------------------------------------------------
       
   589 //   CMPXVideoPlaybackUserInputHandler::SetForeground()
       
   590 // -------------------------------------------------------------------------------------------------
       
   591 //
       
   592 void CMPXVideoPlaybackUserInputHandler::SetForeground(TBool aForeground)
       
   593 {
       
   594     iForeground = aForeground;
       
   595 
       
   596     if ( !iForeground )
       
   597     {
       
   598         // we are in background so reset iProcessingInputType value
       
   599         iProcessingInputType = EMpxVideoNone;
       
   600     }
       
   601 }
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // CMPXVideoPlaybackUserInputHandler::DisableBacklight()
       
   605 // -----------------------------------------------------------------------------
       
   606 //
       
   607 void CMPXVideoPlaybackUserInputHandler::DisableBacklight()
       
   608 {
       
   609     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::DisableBacklight"));
       
   610 
       
   611     // cancel the timer
       
   612     iDisplayTimer->Cancel();
       
   613 
       
   614     // disable the backlight
       
   615     HAL::Set( HALData::EBacklightState, 0 );
       
   616 }
       
   617 
       
   618 // -----------------------------------------------------------------------------
       
   619 // CMPXVideoPlaybackUserInputHandler::EnableBacklight()
       
   620 // -----------------------------------------------------------------------------
       
   621 //
       
   622 void CMPXVideoPlaybackUserInputHandler::EnableBacklight()
       
   623 {
       
   624     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::EnableBacklight"));
       
   625 
       
   626     // enable the backlight
       
   627     HAL::Set( HALData::EBacklightState, 1 );
       
   628 }
       
   629 
       
   630 
       
   631 // -------------------------------------------------------------------------------------------------
       
   632 //   CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent()
       
   633 // -------------------------------------------------------------------------------------------------
       
   634 //
       
   635 void CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent(TBool aTVOutConnected)
       
   636 {
       
   637     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent"));
       
   638 
       
   639     iTVOutConnected = aTVOutConnected;
       
   640 
       
   641     if ( iTVOutConnected )
       
   642     {
       
   643         // Get the display light time-out value from CenRep
       
   644         CRepository* repository = CRepository::NewLC( KCRUidLightSettings );
       
   645 
       
   646         // What's the timeout value (in seconds ) for the display light?
       
   647         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   648         MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   649 
       
   650         CleanupStack::PopAndDestroy( repository );
       
   651 
       
   652         // Convert the timeout value to microseconds
       
   653         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   654 
       
   655         RestartDisplayTimer();
       
   656     }
       
   657     else
       
   658     {
       
   659         iDisplayTimer->Cancel();
       
   660         EnableBacklight();
       
   661     }
       
   662 }
       
   663 
       
   664 // -------------------------------------------------------------------------------------------------
       
   665 //   CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout
       
   666 // -------------------------------------------------------------------------------------------------
       
   667 //
       
   668 TInt CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout( TAny* aPtr )
       
   669 {
       
   670     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout"));
       
   671 
       
   672     static_cast<CMPXVideoPlaybackUserInputHandler*>(aPtr)->DisableBacklight();
       
   673 
       
   674     return KErrNone;
       
   675 }
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer
       
   679 // -----------------------------------------------------------------------------
       
   680 //
       
   681 void CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer()
       
   682 {
       
   683     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer"));
       
   684 
       
   685     // check if the display timer is running if so cancelit
       
   686     if ( iDisplayTimer->IsActive() )
       
   687     {
       
   688         iDisplayTimer->Cancel();
       
   689     }
       
   690     else
       
   691     {
       
   692         // timeout has happened and the backlight is disabled
       
   693         // enable the backlight
       
   694         HAL::Set( HALData::EBacklightState, 1 );
       
   695     }
       
   696 
       
   697     TBool backlightState;
       
   698     TInt ret = HAL::Get( HALData::EBacklightState, backlightState );
       
   699 
       
   700     // Re start the display backlight timer
       
   701     iDisplayTimer->Start( iDisplayTimeOut, iDisplayTimeOut,
       
   702                           TCallBack( CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout, this ) );
       
   703 }
       
   704 
       
   705 // EOF