phoneapp/phoneuicontrol/src/cphonekeyeventforwarder.cpp
branchRCL_3
changeset 7 544e34b3255a
parent 6 38529f706030
child 9 91c2fb4b78df
equal deleted inserted replaced
6:38529f706030 7:544e34b3255a
    40 // CONSTANTS
    40 // CONSTANTS
    41 
    41 
    42 //Avkon P&S keys
    42 //Avkon P&S keys
    43 const TUid KCRUidAvkon = { 0x101F876E };
    43 const TUid KCRUidAvkon = { 0x101F876E };
    44 const TUint32 KAknKeyBoardLayout = 0x0000000B;
    44 const TUint32 KAknKeyBoardLayout = 0x0000000B;
       
    45 
       
    46 // Characters resulting from multitapping *-key.
       
    47 _LIT( KAsteriskMultitapCharacters, "*+pw" );
       
    48 
       
    49 // Multitap delay parameter in micro seconds.
       
    50 const TInt KMultitapDelay = 1000000;
       
    51 
    45 
    52 
    46 // ============================ MEMBER FUNCTIONS ===============================
    53 // ============================ MEMBER FUNCTIONS ===============================
    47 
    54 
    48 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    49 // CPhoneKeyEventForwarder::NewL
    56 // CPhoneKeyEventForwarder::NewL
   276 
   283 
   277     return ret;
   284     return ret;
   278     }
   285     }
   279 
   286 
   280 // -----------------------------------------------------------------------------
   287 // -----------------------------------------------------------------------------
       
   288 // CPhoneKeyEventForwarder::HandleTouchDialerKeyEventL
       
   289 // 
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 void CPhoneKeyEventForwarder::HandleTouchDialerKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   293     {
       
   294     TBool multitap = aKeyEvent.iScanCode == EStdKeyNkpAsterisk && 
       
   295             iPreviousScanCode == EStdKeyNkpAsterisk &&
       
   296             iKeyPressTime.MicroSecondsFrom( iPreviousKeyPressTime ) < KMultitapDelay;
       
   297     
       
   298     if ( multitap )
       
   299         {
       
   300         if ( aType == EEventKeyDown )
       
   301             {
       
   302             // Update multitap index
       
   303             iMultitapIndex = ( iMultitapIndex + 1 ) % KAsteriskMultitapCharacters().Length();
       
   304             
       
   305             // Delete the previously entered character by simulating a backspace character.
       
   306             TKeyEvent backSpaceEvent;
       
   307             backSpaceEvent.iModifiers = 0;
       
   308             backSpaceEvent.iRepeats = 0;
       
   309             backSpaceEvent.iCode = EKeyBackspace;
       
   310             backSpaceEvent.iScanCode = EStdKeyBackspace;
       
   311             iStateMachine->State()->HandleKeyEventL( backSpaceEvent, EEventKey );
       
   312             }
       
   313         
       
   314         TKeyEvent keyEvent( aKeyEvent );
       
   315         
       
   316         // Modify the key event to contain the next character on multitap list.
       
   317         keyEvent.iCode = ( TInt ) KAsteriskMultitapCharacters()[ iMultitapIndex ];
       
   318         
       
   319         // Send character to number entry.
       
   320         iStateMachine->State()->HandleKeyEventL( keyEvent, aType );
       
   321         }
       
   322     
       
   323     else 
       
   324         {
       
   325         iMultitapIndex = 0;
       
   326         iStateMachine->State()->HandleKeyEventL( aKeyEvent, aType );
       
   327         }
       
   328     
       
   329     if ( aType == EEventKeyUp )
       
   330         {
       
   331         iPreviousScanCode = aKeyEvent.iScanCode;
       
   332         }
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
   281 // CPhoneKeyEventForwarder::OfferKeyEventBeforeControlStackL
   336 // CPhoneKeyEventForwarder::OfferKeyEventBeforeControlStackL
   282 // Let phone handle before other components in control stack
   337 // Let phone handle before other components in control stack
   283 // -----------------------------------------------------------------------------
   338 // -----------------------------------------------------------------------------
   284 //
   339 //
   285 TKeyResponse CPhoneKeyEventForwarder::OfferKeyEventBeforeControlStackL(
   340 TKeyResponse CPhoneKeyEventForwarder::OfferKeyEventBeforeControlStackL(
   311             break;
   366             break;
   312         default:
   367         default:
   313             break;
   368             break;
   314         }
   369         }
   315     
   370     
   316     // Check if keyEvent is simulated in Dialer.
   371     // Check if keyEvent is simulated by Dialer.
   317     const TBool simulatedByDialer = 
   372     const TBool simulatedByDialer = 
   318         ( ( aKeyEvent.iModifiers & ( EModifierNumLock | EModifierKeypad ) ) 
   373         ( ( aKeyEvent.iModifiers & ( EModifierNumLock | EModifierKeypad ) ) 
   319                 == ( EModifierNumLock | EModifierKeypad ) );
   374                 == ( EModifierNumLock | EModifierKeypad ) );
   320     
   375     
   321     if(  simulatedByDialer && iQwertyHandler->IsQwertyInput() )
   376     if( simulatedByDialer )
   322         {
   377         {
   323         // When dialler key was pressed and
   378         HandleTouchDialerKeyEventL( aKeyEvent, aType );
   324         // qwerty is open and editor is alphanumeric
       
   325         //  -Dont let FEP to handle key events 
       
   326         //    -> Multitapping doesnt work
       
   327         //    -> Numbers are inserted to dialler without modifications
       
   328         // Also effects # / * - key handling 
       
   329         iStateMachine->State()->HandleKeyEventL( aKeyEvent, aType );
       
   330         response = EKeyWasConsumed;
   379         response = EKeyWasConsumed;
   331         }
   380         }
   332     
   381     
       
   382     else 
       
   383         {
       
   384         // If not simulated by dialer, multitap related fields are reset.
       
   385         // Any key event not originating from dialer interrupts multitap
       
   386         // behaviour.
       
   387         iMultitapIndex = 0;
       
   388         iPreviousScanCode = 0;
       
   389         }
       
   390 
   333     return response;
   391     return response;
   334     }
   392     }
   335 
   393 
   336 
   394 
   337 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   377 
   435 
   378     // Convert key code
   436     // Convert key code
   379     ConvertKeyCode( iKeyPressedDown, aKeyEvent );
   437     ConvertKeyCode( iKeyPressedDown, aKeyEvent );
   380     // Save key scan code
   438     // Save key scan code
   381     iScanCode = aKeyEvent.iScanCode;
   439     iScanCode = aKeyEvent.iScanCode;
       
   440     
       
   441     // Store the previous keypress time.
       
   442     iPreviousKeyPressTime = iKeyPressTime;
   382 
   443 
   383     // Start the key press timer
   444     // Start the key press timer
   384     iKeyPressTime.UniversalTime();
   445     iKeyPressTime.UniversalTime();
   385 
   446 
   386     // Cancel the long press key event timer, if it is active
   447     // Cancel the long press key event timer, if it is active