uifw/AknGlobalUI/AknCapServer/src/aknKeyFilter.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    53 
    53 
    54 
    54 
    55 /** Video call application's AppUID */
    55 /** Video call application's AppUID */
    56 const TUid KVideoCallAppUid     = { 0x101F8681 }; 
    56 const TUid KVideoCallAppUid     = { 0x101F8681 }; 
    57 
    57 
       
    58 /** Layout */
       
    59 const TInt KLayoutPortrait = 0;
       
    60 const TInt KLayoutLandscape = 1;
    58 /**
    61 /**
    59 * Command used in activating the phone view.
    62 * Command used in activating the phone view.
    60 * Null command allows the the phone app to decide whether
    63 * Null command allows the the phone app to decide whether
    61 * to open dialer or call handling.
    64 * to open dialer or call handling.
    62 */
    65 */
    90     {
    93     {
    91     FreeHardwareStateKeys();
    94     FreeHardwareStateKeys();
    92 
    95 
    93     RWindowGroup& groupWin = iCoeEnv->RootWin();
    96     RWindowGroup& groupWin = iCoeEnv->RootWin();
    94     groupWin.CancelCaptureKeyUpAndDowns( iHomeKeyHandle );
    97     groupWin.CancelCaptureKeyUpAndDowns( iHomeKeyHandle );
    95     groupWin.CancelCaptureKeyUpAndDowns( iQwertyOnKeyHandle );
       
    96     groupWin.CancelCaptureKeyUpAndDowns( iQwertyOffKeyHandle );
       
    97     groupWin.CancelCaptureKey( iFlipOpenKeyHandle );
       
    98     groupWin.CancelCaptureKey( iFlipCloseKeyHandle );
       
    99 #ifdef RD_INTELLIGENT_TEXT_INPUT
    98 #ifdef RD_INTELLIGENT_TEXT_INPUT
   100     delete iAvkonRepository;
    99     delete iAvkonRepository;
   101 #endif
   100 #endif
   102     delete iHomeTimer;
   101     delete iHomeTimer;
       
   102     delete iSlideStatusObserver;
   103     }
   103     }
   104 
   104 
   105 
   105 
   106 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
   107 // CAknServKeyFilter::ConstructL
   107 // CAknServKeyFilter::ConstructL
   110 //
   110 //
   111 void CAknServKeyFilter::ConstructL( CAknCapAppServerAppUi& aAppUi )
   111 void CAknServKeyFilter::ConstructL( CAknCapAppServerAppUi& aAppUi )
   112     {
   112     {
   113     RWindowGroup& groupWin = iCoeEnv->RootWin();
   113     RWindowGroup& groupWin = iCoeEnv->RootWin();
   114     iHomeKeyHandle      = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0);
   114     iHomeKeyHandle      = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0);
   115     iQwertyOnKeyHandle  = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication7, 0, 0); // EKeyQwertyOn
       
   116     iQwertyOffKeyHandle = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication8, 0, 0); // EKeyQwertyOff
       
   117     iFlipOpenKeyHandle  = groupWin.CaptureKey(EKeyDeviceA, 0, 0); // EKeyFlipOpen
       
   118     iFlipCloseKeyHandle = groupWin.CaptureKey(EKeyDeviceB, 0, 0); // EKeyFlipClose
       
   119 
   115 
   120     // Get the default view id
   116     // Get the default view id
   121     TResourceReader reader;
   117     TResourceReader reader;
   122     // AppUi loads this resource
   118     // AppUi loads this resource
   123     iEikonEnv->CreateResourceReaderLC( reader, R_EIK_SYSTEM_DEFAULT_VIEW_ID );
   119     iEikonEnv->CreateResourceReaderLC( reader, R_EIK_SYSTEM_DEFAULT_VIEW_ID );
   203         {
   199         {
   204         RProperty::Set(KCRUidAvkon, KAknQwertyInputModeActive, 0);
   200         RProperty::Set(KCRUidAvkon, KAknQwertyInputModeActive, 0);
   205         iAppUi->iQwertyStatus = EFalse;
   201         iAppUi->iQwertyStatus = EFalse;
   206         }
   202         }
   207 #endif // RD_INTELLIGENT_TEXT_INPUT
   203 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   204     iSlideOpen = EFalse;
       
   205     TRAP_IGNORE( iSlideStatusObserver = CAknSlideStatusNotifier::NewL( this ) );
       
   206     iSensorOrientation = KLayoutPortrait;
   208     }
   207     }
   209 
   208 
   210 // ---------------------------------------------------------------------------
   209 // ---------------------------------------------------------------------------
   211 // CAknServKeyFilter::ToggleShellL
   210 // CAknServKeyFilter::ToggleShellL
   212 // This method handles the short press of the applications key.
   211 // This method handles the short press of the applications key.
   343         }
   342         }
   344 
   343 
   345     if ( aKeyEvent.iScanCode == EStdKeyApplication0 )
   344     if ( aKeyEvent.iScanCode == EStdKeyApplication0 )
   346         {
   345         {
   347         return HandleHomeKeyEventL( aType );
   346         return HandleHomeKeyEventL( aType );
   348         }
       
   349     else if ( aKeyEvent.iScanCode == EStdKeyApplication7 || // EKeyQwertyOn
       
   350               aKeyEvent.iScanCode == EStdKeyApplication8 )  // EKeyQwertyOff
       
   351         {
       
   352         return HandleQwertyKeyEvent( aKeyEvent, aType );
       
   353         }
   347         }
   354     else if ( aType==EEventKey && HandleHardwareStateKeyL( aKeyEvent.iCode ) )
   348     else if ( aType==EEventKey && HandleHardwareStateKeyL( aKeyEvent.iCode ) )
   355         {
   349         {
   356         return EKeyWasConsumed;
   350         return EKeyWasConsumed;
   357         }
   351         }
   410         }
   404         }
   411 
   405 
   412     return EKeyWasNotConsumed;
   406     return EKeyWasNotConsumed;
   413     }
   407     }
   414 
   408 
   415 
       
   416 // ---------------------------------------------------------------------------
       
   417 // CAknServKeyFilter::HandleQwertyKeyEvent
       
   418 // Handles the pressing of QWERTY key.
       
   419 // ---------------------------------------------------------------------------
       
   420 //
       
   421 TKeyResponse CAknServKeyFilter::HandleQwertyKeyEvent( const TKeyEvent& /*aKeyEvent*/,
       
   422                                                       TEventCode aType )
       
   423     {
       
   424     if ( aType == EEventKeyDown )
       
   425         {
       
   426         TInt qwertyOn = 0;
       
   427 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
   428         TInt keyboardLayout = EPtiKeyboard12Key;
       
   429         iAvkonRepository->Get(KAknKeyBoardLayout, keyboardLayout);            
       
   430         switch(keyboardLayout)
       
   431             {
       
   432             case EPtiKeyboardQwerty4x12:
       
   433             case EPtiKeyboardQwerty4x10:
       
   434             case EPtiKeyboardQwerty3x11:
       
   435             case EPtiKeyboardHalfQwerty:
       
   436             case EPtiKeyboardCustomQwerty:
       
   437                 {
       
   438                 qwertyOn = 1;
       
   439                 break;
       
   440                 }
       
   441             default:
       
   442                 break;
       
   443             }
       
   444 #endif            
       
   445 
       
   446         TInt err = RProperty::Set( KCRUidAvkon,
       
   447                                    KAknQwertyInputModeActive,
       
   448                                    qwertyOn );
       
   449         iAppUi->iQwertyStatus = qwertyOn;
       
   450 
       
   451 #ifdef _DEBUG
       
   452         _LIT( KDMsg, "xxxx KAknQwertyInputModeActive err=%d" );
       
   453         RDebug::Print( KDMsg, err );
       
   454 #endif
       
   455 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
   456         err = RProperty::Set(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   457 #endif
       
   458 
       
   459         }
       
   460 
       
   461     return EKeyWasConsumed;
       
   462     }
       
   463 
       
   464 
       
   465 // ---------------------------------------------------------------------------
   409 // ---------------------------------------------------------------------------
   466 // CAknServKeyFilter::HandleFlipKeyEvent
   410 // CAknServKeyFilter::HandleFlipKeyEvent
   467 // Handles the flip events.
   411 // Handles the flip events.
   468 // ---------------------------------------------------------------------------
   412 // ---------------------------------------------------------------------------
   469 //
   413 //
   577     if ( aCode == EKeyFlipOpen || aCode == EKeyFlipClose )
   521     if ( aCode == EKeyFlipOpen || aCode == EKeyFlipClose )
   578         {
   522         {
   579         HandleFlipKeyEvent(aCode);
   523         HandleFlipKeyEvent(aCode);
   580         }
   524         }
   581 
   525 
   582     CWsScreenDevice* screen = iEikonEnv->ScreenDevice();
       
   583     TInt screenMode = screen->CurrentScreenMode();
       
   584 
       
   585     CAknLayoutConfig::THardwareStateArray hwStates =
   526     CAknLayoutConfig::THardwareStateArray hwStates =
   586         CAknSgcClient::LayoutConfig().HardwareStates();
   527         CAknSgcClient::LayoutConfig().HardwareStates();
   587     TInt count = hwStates.Count();
   528     TInt count = hwStates.Count();
   588     for ( TInt ii = 0; ii < count; ii++ )
   529     for ( TInt ii = 0; ii < count; ii++ )
   589         {
   530         {
   590         const CAknLayoutConfig::THardwareState& hwState = hwStates.At( ii );
   531         const CAknLayoutConfig::THardwareState& hwState = hwStates.At( ii );
   591         if ( hwState.KeyCode() == aCode )
   532         if ( hwState.KeyCode() == aCode )
   592             {
   533         	{
   593             SetHardwareStateL( hwState.StateNumber() );
   534         	iSensorOrientation = hwState.StateNumber();
   594 
   535             if( !iSlideOpen )
   595             // Update the setting cache and get SGCS to process the screen
   536 				{
   596             // mode change. This may broadcast a screen device change to
   537 				RotateScreenL( hwState.StateNumber() );
   597             // the apps, to inform them of the update.
       
   598             iAvkonEnv->SettingCache().Update( KAknHardwareLayoutSwitch );
       
   599             iAppUi->SgcServer()->HandleWindowGroupParamChangeL(
       
   600                 iEikonEnv->RootWin().Identifier(),
       
   601                 0,
       
   602                 0,
       
   603                 0,
       
   604                 KAknScreenModeUnset );
       
   605 
       
   606             if ( screenMode == screen->CurrentScreenMode() )
       
   607                 {
       
   608                 // Apps will not have received a screen device changed event
       
   609                 // so send a KAknHardwareLayoutSwitch to the apps to ensure
       
   610                 // they get to know about the key.
       
   611                 TWsEvent event;
       
   612                 event.SetType( KAknHardwareLayoutSwitch );
       
   613                 event.SetHandle( 0 );
       
   614                 iEikonEnv->WsSession().SendEventToAllWindowGroups( 0, event );
       
   615                 }
       
   616 #ifdef RD_INTELLIGENT_TEXT_INPUT
   538 #ifdef RD_INTELLIGENT_TEXT_INPUT
   617 #if defined(__WINS__)
   539 #if defined(__WINS__)
   618             
   540             
   619             TInt keyboardLayout = HwKeyToKeyBoardType(aCode);
   541             TInt keyboardLayout = HwKeyToKeyBoardType(aCode);
   620             TInt curkeyLayout = 0;
   542             TInt curkeyLayout = 0;
   677 #endif
   599 #endif
   678 
   600 
   679 #endif // __WINS__
   601 #endif // __WINS__
   680 #endif //RD_INTELLIGENT_TEXT_INPUT
   602 #endif //RD_INTELLIGENT_TEXT_INPUT
   681             return ETrue;
   603             return ETrue;
       
   604 				}
   682             }
   605             }
   683         }
   606         }
   684 
   607 
   685     return EFalse;
   608     return EFalse;
   686     }
   609     }
   781             }
   704             }
   782         }
   705         }
   783     return ret;
   706     return ret;
   784     }
   707     }
   785 #endif //RD_INTELLIGENT_TEXT_INPUT
   708 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   709 
       
   710 // ---------------------------------------------------------------------------
       
   711 // CAknServKeyFilter::SlideStatusChangedL
       
   712 // ---------------------------------------------------------------------------
       
   713 //
       
   714 void CAknServKeyFilter::SlideStatusChangedL( const TInt& aValue )
       
   715     {
       
   716 	CAknLayoutConfig::THardwareStateArray hwStates =
       
   717 		CAknSgcClient::LayoutConfig().HardwareStates();
       
   718     TInt keyboardLayout(0);
       
   719     TInt state(0);
       
   720     
       
   721     RWsSession wsSession = iEikonEnv->WsSession();
       
   722     
       
   723     TKeyEvent eventQwertyOn = { EKeyQwertyOn, 0 };
       
   724     
       
   725     TKeyEvent eventQwertyOff = { EKeyQwertyOff, 0 };
       
   726 
       
   727 	switch( aValue )
       
   728 		{
       
   729 		case EPSHWRMGripOpen:
       
   730 			iSlideOpen = ETrue;
       
   731 			wsSession.SimulateKeyEvent( eventQwertyOn );
       
   732 			//to be read from cenrep
       
   733 			iAvkonRepository->Get( KAknKeyboardSlideOpen, keyboardLayout );
       
   734 			if( keyboardLayout > EPtiKeyboard12Key )
       
   735 				{
       
   736 				//if the keyboard is a qwerty the layout is landscape
       
   737 				state = KLayoutLandscape;
       
   738 				}
       
   739 			else
       
   740 				{
       
   741 				//if the keyboard is not a qwerty the layout is portrait
       
   742 				state = KLayoutPortrait;
       
   743 				}
       
   744 			break;
       
   745 		case EPSHWRMGripClosed:
       
   746 			iSlideOpen = EFalse;
       
   747 			wsSession.SimulateKeyEvent( eventQwertyOff );
       
   748 			state = iSensorOrientation;
       
   749 			iAvkonRepository->Get( KAknKeyboardSlideClose, keyboardLayout );
       
   750 			break;
       
   751 		}
       
   752 	
       
   753 	UpdateKeyboardLayout( keyboardLayout );
       
   754 	RotateScreenL( state );
       
   755     }
       
   756 
       
   757 // ---------------------------------------------------------------------------
       
   758 // CAknServKeyFilter::UpdateKeyboardLayout
       
   759 // ---------------------------------------------------------------------------
       
   760 //
       
   761 void CAknServKeyFilter::UpdateKeyboardLayout( TInt aKeyboardLayout )
       
   762     {
       
   763     RProperty::Set(KCRUidAvkon, KAknKeyBoardLayout, aKeyboardLayout);
       
   764 	if( aKeyboardLayout > EPtiKeyboard12Key )
       
   765 		{
       
   766 		iAppUi->iQwertyStatus = ETrue;
       
   767 		TInt err = RProperty::Set(KCRUidAvkon, KAknQwertyInputModeActive, 1); 
       
   768 		iAvkonRepository->Set(KAknQwertyInputModeActive,1);
       
   769 		}
       
   770 	else
       
   771 		{
       
   772 		iAppUi->iQwertyStatus = EFalse;
       
   773 		TInt err = RProperty::Set(KCRUidAvkon, KAknQwertyInputModeActive, 0); 
       
   774 		iAvkonRepository->Set(KAknQwertyInputModeActive, 0);
       
   775 		}
       
   776     }
       
   777 
       
   778 // ---------------------------------------------------------------------------
       
   779 // CAknServKeyFilter::RotateScreenL
       
   780 // ---------------------------------------------------------------------------
       
   781 //
       
   782 void CAknServKeyFilter::RotateScreenL( TInt aState )
       
   783 	{
       
   784 	CWsScreenDevice* screen = iEikonEnv->ScreenDevice();
       
   785 	TInt screenMode = screen->CurrentScreenMode();
       
   786 	SetHardwareStateL( aState );
       
   787 				
       
   788 	// Update the setting cache and get SGCS to process the screen
       
   789 	// mode change. This may broadcast a screen device change to
       
   790 	// the apps, to inform them of the update.
       
   791 	iAvkonEnv->SettingCache().Update( KAknHardwareLayoutSwitch );
       
   792 	iAppUi->SgcServer()->HandleWindowGroupParamChangeL(
       
   793 		iEikonEnv->RootWin().Identifier(),
       
   794 		0,
       
   795 		0,
       
   796 		0,
       
   797 		KAknScreenModeUnset );
       
   798 
       
   799 	if ( screenMode == screen->CurrentScreenMode() )
       
   800 		{
       
   801 		// Apps will not have received a screen device changed event
       
   802 		// so send a KAknHardwareLayoutSwitch to the apps to ensure
       
   803 		// they get to know about the key.
       
   804 		TWsEvent event;
       
   805 		event.SetType( KAknHardwareLayoutSwitch );
       
   806 		event.SetHandle( 0 );
       
   807 		iEikonEnv->WsSession().SendEventToAllWindowGroups( 0, event );
       
   808 		}
       
   809     }
       
   810 
   786 // End of file
   811 // End of file