videoplayback/videoplaybackviews/src/mpxvideoplaybackuserinputhandler.cpp
branchRCL_3
changeset 9 5294c000a26d
parent 8 ce5ada96ab30
child 11 8970fbd719ec
equal deleted inserted replaced
8:ce5ada96ab30 9:5294c000a26d
    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: 15 %
    18 // Version : %version: ou1cpsw#16 %
    19 
    19 
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include <w32std.h> // RWindowBase
    22 #include <w32std.h> // RWindowBase
    23 #include <e32base.h>
    23 #include <e32base.h>
    29 #include <AknIconUtils.h>  // SetSize for the icons
    29 #include <AknIconUtils.h>  // SetSize for the icons
    30 #include <remconcoreapi.h>
    30 #include <remconcoreapi.h>
    31 #include <remconcoreapitarget.h>
    31 #include <remconcoreapitarget.h>
    32 #include <remconinterfaceselector.h> // Side volume key
    32 #include <remconinterfaceselector.h> // Side volume key
    33 #include <mpxplaybackframeworkdefs.h>
    33 #include <mpxplaybackframeworkdefs.h>
    34 #include <centralrepository.h>  // for peripheral display timeout setting
    34 
    35 #include <settingsinternalcrkeys.h> // display timeout setting keys
       
    36 #include <hwrmlightdomaincrkeys.h>
       
    37 #include <e32std.h>
    35 #include <e32std.h>
    38 
    36 
    39 #ifdef __USERINPUTHANDLERSTIF__
    37 #ifdef __USERINPUTHANDLERSTIF__
    40 #include "videoplaybackcontainer_stub.h"
    38 #include "videoplaybackcontainer_stub.h"
    41 #include "videoplaybackcontrol_stub.h"
    39 #include "videoplaybackcontrol_stub.h"
    42 #include "hal_stub.h"
    40 #include "hal_stub.h"
    43 #else
    41 #else
    44 #include "mpxvideoplaybackcontainer.h"
    42 #include "mpxvideoplaybackcontainer.h"
    45 #include "mpxvideoplaybackcontrol.h"
    43 #include "mpxvideoplaybackcontrol.h"
    46 #include <hwrmlight.h> //light status
       
    47 #endif
    44 #endif
    48 
    45 
    49 #include "mpxvideoplaybackcontrol.hrh"
    46 #include "mpxvideoplaybackcontrol.hrh"
    50 #include "mpxvideoplaybackuserinputhandler.h"
    47 #include "mpxvideoplaybackuserinputhandler.h"
    51 
    48 
    52 #include <mpxvideoplaybackdefs.h>
    49 #include <mpxvideoplaybackdefs.h>
    53 #include "mpxcommonvideoplaybackview.hrh"
    50 #include "mpxcommonvideoplaybackview.hrh"
    54 #include "mpxvideo_debug.h"
    51 #include "mpxvideo_debug.h"
    55 
    52 
    56 
    53 
    57 // CONSTANTS
       
    58 const TInt KMPXMicroSecondsInASecond = 1000000;
       
    59 
    54 
    60 
    55 
    61 // ======== MEMBER FUNCTIONS =======================================================================
    56 // ======== MEMBER FUNCTIONS =======================================================================
    62 
    57 
    63 // -------------------------------------------------------------------------------------------------
    58 // -------------------------------------------------------------------------------------------------
    73 // -------------------------------------------------------------------------------------------------
    68 // -------------------------------------------------------------------------------------------------
    74 // CMPXVideoPlaybackUserInputHandler::NewL()
    69 // CMPXVideoPlaybackUserInputHandler::NewL()
    75 // -------------------------------------------------------------------------------------------------
    70 // -------------------------------------------------------------------------------------------------
    76 //
    71 //
    77 CMPXVideoPlaybackUserInputHandler* CMPXVideoPlaybackUserInputHandler::NewL(
    72 CMPXVideoPlaybackUserInputHandler* CMPXVideoPlaybackUserInputHandler::NewL(
    78         CMPXVideoPlaybackContainer* aContainer, TBool aTvOutConnected)
    73         CMPXVideoPlaybackContainer* aContainer )
    79 {
    74 {
    80     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::NewL()"));
    75     MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::NewL()"));
    81 
    76 
    82     CMPXVideoPlaybackUserInputHandler* self =
    77     CMPXVideoPlaybackUserInputHandler* self =
    83         new (ELeave) CMPXVideoPlaybackUserInputHandler( aContainer );
    78         new (ELeave) CMPXVideoPlaybackUserInputHandler( aContainer );
    84     CleanupStack::PushL( self );
    79     CleanupStack::PushL( self );
    85     self->ConstructL(aTvOutConnected);
    80     self->ConstructL();
    86     CleanupStack::Pop();
    81     CleanupStack::Pop();
    87     return self;
    82     return self;
    88 }
    83 }
    89 
    84 
    90 // -------------------------------------------------------------------------------------------------
    85 // -------------------------------------------------------------------------------------------------
    91 // CMPXVideoPlaybackUserInputHandler::ConstructL
    86 // CMPXVideoPlaybackUserInputHandler::ConstructL
    92 // Symbian 2nd phase constructor can leave.
    87 // Symbian 2nd phase constructor can leave.
    93 // -------------------------------------------------------------------------------------------------
    88 // -------------------------------------------------------------------------------------------------
    94 //
    89 //
    95 void CMPXVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected )
    90 void CMPXVideoPlaybackUserInputHandler::ConstructL()
    96 {
    91 {
    97     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ConstructL()"));
    92     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ConstructL()"));
    98 
    93 
    99     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
    94     iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   100     iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard );
    95 
   101     iInterfaceSelector = CRemConInterfaceSelector::NewL();
    96     iInterfaceSelector = CRemConInterfaceSelector::NewL();
   102     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
    97     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
   103 
    98 
   104     iTVOutConnected = aTvOutConnected;
       
   105 
       
   106     iLight = CHWRMLight::NewL();
       
   107 
       
   108     // Start the timer if TV out is connected
       
   109     if ( iTVOutConnected )
       
   110     {
       
   111         // Get the display light time-out value from CenRep
       
   112         CRepository* repository = CRepository::NewLC( KCRUidLightSettings  );
       
   113 
       
   114         // What's the timeout value (in seconds ) for the display light?
       
   115         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   116         MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   117 
       
   118         CleanupStack::PopAndDestroy( repository );
       
   119 
       
   120         // Convert the timeout value to microseconds
       
   121         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   122 
       
   123         RestartDisplayTimer();
       
   124     }
       
   125 
       
   126     // not detrimental if Media Keys dont work - so ignore any errors here
    99     // not detrimental if Media Keys dont work - so ignore any errors here
   127     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
   100     TRAP_IGNORE( iInterfaceSelector->OpenTargetL() );
   128 
   101 
   129     iProcessingInputType = EMpxVideoNone;
   102     iProcessingInputType = EMpxVideoNone;
   130     iForeground = ETrue;
   103     iForeground = ETrue;
   140     {
   113     {
   141         iVolumeRepeatTimer->Cancel();
   114         iVolumeRepeatTimer->Cancel();
   142         delete iVolumeRepeatTimer;
   115         delete iVolumeRepeatTimer;
   143     }
   116     }
   144 
   117 
   145     if ( iDisplayTimer )
       
   146     {
       
   147         iDisplayTimer->Cancel();
       
   148         delete iDisplayTimer;
       
   149     }
       
   150 
   118 
   151     if ( iInterfaceSelector )
   119     if ( iInterfaceSelector )
   152     {
   120     {
   153         delete iInterfaceSelector;
   121         delete iInterfaceSelector;
   154         iCoreTarget = NULL;
   122         iCoreTarget = NULL;
   155         iInterfaceSelector = NULL;
   123         iInterfaceSelector = NULL;
   156     }
   124     }
   157 
   125 
   158     // make sure that backlight enabled when
       
   159     // the view updates or deactivates
       
   160     EnableBacklight();
       
   161 
       
   162     if ( iLight )
       
   163     {
       
   164         delete iLight;
       
   165         iLight = NULL;
       
   166     }
       
   167 }
   126 }
   168 
   127 
   169 // -------------------------------------------------------------------------------------------------
   128 // -------------------------------------------------------------------------------------------------
   170 // CMPXVideoPlaybackUserInputHandler::MrccatoPlay()
   129 // CMPXVideoPlaybackUserInputHandler::MrccatoPlay()
   171 // -------------------------------------------------------------------------------------------------
   130 // -------------------------------------------------------------------------------------------------
   396         case EMpxVideoNone:
   355         case EMpxVideoNone:
   397         {
   356         {
   398             if (aPointerEvent.iType == TPointerEvent::EButton1Down && iForeground)
   357             if (aPointerEvent.iType == TPointerEvent::EButton1Down && iForeground)
   399             {
   358             {
   400                 iProcessingInputType = EMpxVideoTouch;
   359                 iProcessingInputType = EMpxVideoTouch;
   401                 if ( iTVOutConnected )
   360 
   402                 {
       
   403                     RestartDisplayTimer();
       
   404                 }
       
   405                 ReRoutePointerEventL(aControl, aPointerEvent, aMPXControl);
   361                 ReRoutePointerEventL(aControl, aPointerEvent, aMPXControl);
   406             }
   362             }
   407             break;
   363             break;
   408         }
   364         }
   409         case EMpxVideoTouch:
   365         case EMpxVideoTouch:
   445             if (aType == EEventKeyDown && iForeground)
   401             if (aType == EEventKeyDown && iForeground)
   446             {
   402             {
   447                 iProcessingInputType = EMpxVideoKeyboard;
   403                 iProcessingInputType = EMpxVideoKeyboard;
   448                 iLastPressedKeyCode = aKeyEvent.iCode;
   404                 iLastPressedKeyCode = aKeyEvent.iCode;
   449                 iLastPressedKeyScanCode = aKeyEvent.iScanCode;
   405                 iLastPressedKeyScanCode = aKeyEvent.iScanCode;
   450                 if ( iTVOutConnected )
   406 
   451                 {
       
   452                     RestartDisplayTimer();
       
   453                 }
       
   454                 iContainer->DoHandleKeyEventL(aKeyEvent, aType);
   407                 iContainer->DoHandleKeyEventL(aKeyEvent, aType);
   455             }
   408             }
   456             break;
   409             break;
   457         }
   410         }
   458         case EMpxVideoKeyboard:
   411         case EMpxVideoKeyboard:
   496             if ( aButtonAct == ERemConCoreApiButtonPress && iForeground )
   449             if ( aButtonAct == ERemConCoreApiButtonPress && iForeground )
   497             {
   450             {
   498                 iProcessingInputType = EMpxVideoMediaKeys;
   451                 iProcessingInputType = EMpxVideoMediaKeys;
   499                 iLastMediaKeyPressed = aOperationId;
   452                 iLastMediaKeyPressed = aOperationId;
   500                 DoHandleMediaKey(aOperationId, aButtonAct);
   453                 DoHandleMediaKey(aOperationId, aButtonAct);
   501                 if ( iTVOutConnected )
       
   502                 {
       
   503                     RestartDisplayTimer();
       
   504                 }
       
   505             }
   454             }
   506             else if (aButtonAct == ERemConCoreApiButtonClick && iForeground)
   455             else if (aButtonAct == ERemConCoreApiButtonClick && iForeground)
   507             {
   456             {
   508                 DoHandleMediaKey(aOperationId, aButtonAct);
   457                 DoHandleMediaKey(aOperationId, aButtonAct);
   509                 if ( iTVOutConnected )
       
   510                 {
       
   511                     RestartDisplayTimer();
       
   512                 }
       
   513                 // reset on click AND/OR release
   458                 // reset on click AND/OR release
   514                 iProcessingInputType = EMpxVideoNone;
   459                 iProcessingInputType = EMpxVideoNone;
   515             }
   460             }
   516             break;
   461             break;
   517         }
   462         }
   604         // we are in background so reset iProcessingInputType value
   549         // we are in background so reset iProcessingInputType value
   605         iProcessingInputType = EMpxVideoNone;
   550         iProcessingInputType = EMpxVideoNone;
   606     }
   551     }
   607 }
   552 }
   608 
   553 
   609 // -----------------------------------------------------------------------------
       
   610 // CMPXVideoPlaybackUserInputHandler::DisableBacklight()
       
   611 // -----------------------------------------------------------------------------
       
   612 //
       
   613 void CMPXVideoPlaybackUserInputHandler::DisableBacklight()
       
   614 {
       
   615     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::DisableBacklight"));
       
   616 
       
   617     // cancel the timer
       
   618     iDisplayTimer->Cancel();
       
   619 
       
   620     // disable the backlight
       
   621     MPX_TRAPD( err, 
       
   622     {
       
   623         iLight->ReserveLightL( CHWRMLight::EPrimaryDisplay );
       
   624         iLight->LightOffL( CHWRMLight::EPrimaryDisplay );
       
   625     } );
       
   626 }
       
   627 
       
   628 // -----------------------------------------------------------------------------
       
   629 // CMPXVideoPlaybackUserInputHandler::EnableBacklight()
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 void CMPXVideoPlaybackUserInputHandler::EnableBacklight()
       
   633 {
       
   634     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::EnableBacklight"));
       
   635 
       
   636     // enable the backlight
       
   637     MPX_TRAPD( err,
       
   638     {
       
   639         iLight->LightOnL( CHWRMLight::EPrimaryDisplay );
       
   640         iLight->ReleaseLight(CHWRMLight::EPrimaryDisplay );
       
   641     } );
       
   642 }
       
   643 
       
   644 
       
   645 // -------------------------------------------------------------------------------------------------
       
   646 //   CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent()
       
   647 // -------------------------------------------------------------------------------------------------
       
   648 //
       
   649 void CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent(TBool aTVOutConnected)
       
   650 {
       
   651     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::HandleTVOutEvent"));
       
   652 
       
   653     iTVOutConnected = aTVOutConnected;
       
   654 
       
   655     if ( iTVOutConnected )
       
   656     {
       
   657         // Get the display light time-out value from CenRep
       
   658         CRepository* repository = CRepository::NewLC( KCRUidLightSettings );
       
   659 
       
   660         // What's the timeout value (in seconds ) for the display light?
       
   661         repository->Get( KDisplayLightsTimeout, iDisplayTimeOut );
       
   662         MPX_DEBUG(_L("CMPXVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut);
       
   663 
       
   664         CleanupStack::PopAndDestroy( repository );
       
   665 
       
   666         // Convert the timeout value to microseconds
       
   667         iDisplayTimeOut *= KMPXMicroSecondsInASecond;
       
   668 
       
   669         RestartDisplayTimer();
       
   670     }
       
   671     else
       
   672     {
       
   673         iDisplayTimer->Cancel();
       
   674         EnableBacklight();
       
   675     }
       
   676 }
       
   677 
       
   678 // -------------------------------------------------------------------------------------------------
       
   679 //   CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout
       
   680 // -------------------------------------------------------------------------------------------------
       
   681 //
       
   682 TInt CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout( TAny* aPtr )
       
   683 {
       
   684     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout"));
       
   685 
       
   686     static_cast<CMPXVideoPlaybackUserInputHandler*>(aPtr)->DisableBacklight();
       
   687 
       
   688     return KErrNone;
       
   689 }
       
   690 
       
   691 // -----------------------------------------------------------------------------
       
   692 // CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer
       
   693 // -----------------------------------------------------------------------------
       
   694 //
       
   695 void CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer()
       
   696 {
       
   697     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::RestartDisplayTimer"));
       
   698 
       
   699     // check if the display timer is running if so cancelit
       
   700     if ( iDisplayTimer->IsActive() )
       
   701     {
       
   702         iDisplayTimer->Cancel();
       
   703     }
       
   704     else
       
   705     {
       
   706         // timeout has happened and the backlight is disabled
       
   707         // enable the backlight
       
   708         EnableBacklight();
       
   709     }
       
   710 
       
   711     // Re start the display backlight timer
       
   712     iDisplayTimer->Start( iDisplayTimeOut, iDisplayTimeOut,
       
   713                           TCallBack( CMPXVideoPlaybackUserInputHandler::HandleDisplayTimeout, this ) );
       
   714 }
       
   715 
   554 
   716 // EOF
   555 // EOF