javauis/lcdui_akn/lcdui/src/CMIDKeyDecoder.cpp
branchRCL_3
changeset 71 d5e927d5853b
parent 19 04becd199f91
child 83 26b2b12093af
equal deleted inserted replaced
66:2455ef1f5bbc 71:d5e927d5853b
   189     DEBUG("> CMIDKeyDecoder::~CMIDKeyDecoder");
   189     DEBUG("> CMIDKeyDecoder::~CMIDKeyDecoder");
   190 }
   190 }
   191 
   191 
   192 /** */
   192 /** */
   193 CMIDKeyDecoder::CMIDKeyDecoder(MMIDEnv& aEnv)
   193 CMIDKeyDecoder::CMIDKeyDecoder(MMIDEnv& aEnv)
   194         : iEnv(aEnv)
   194     : iEnv(aEnv)
   195         ,iMediaKeysEnabled(EFalse)
   195     ,iMediaKeysEnabled(EFalse)
   196 {
   196 {
   197     DEBUG("< CMIDKeyDecoder::CMIDKeyDecoder");
   197     DEBUG("< CMIDKeyDecoder::CMIDKeyDecoder");
   198     DEBUG("> CMIDKeyDecoder::CMIDKeyDecoder");
   198     DEBUG("> CMIDKeyDecoder::CMIDKeyDecoder");
   199 }
   199 }
   200 
   200 
   220     CRepository* repository = NULL;
   220     CRepository* repository = NULL;
   221     TInt err = KErrNone;
   221     TInt err = KErrNone;
   222     TRAP(err, repository = CRepository::NewL(KCRUidMidpLcdui));
   222     TRAP(err, repository = CRepository::NewL(KCRUidMidpLcdui));
   223     // 2 bytes in scan code
   223     // 2 bytes in scan code
   224     TBuf8<2> scanCodeBuffer;
   224     TBuf8<2> scanCodeBuffer;
   225     CleanupStack::PushL(repository);
   225 
   226     err = repository->Get(KAdditionalSelectKeyMapping,scanCodeBuffer);
   226     if (err == KErrNone)
   227     CleanupStack::PopAndDestroy(repository);
   227     {
       
   228         CleanupStack::PushL(repository);
       
   229         err = repository->Get(KAdditionalSelectKeyMapping,scanCodeBuffer);
       
   230         CleanupStack::PopAndDestroy(repository);
       
   231     }
   228     if (err == KErrNone)
   232     if (err == KErrNone)
   229     {
   233     {
   230         TUint8 scanCodeLeft = scanCodeBuffer[0];
   234         TUint8 scanCodeLeft = scanCodeBuffer[0];
   231         TUint8 scanCodeRight = scanCodeBuffer[1];
   235         TUint8 scanCodeRight = scanCodeBuffer[1];
   232         TUint scanCode = (scanCodeLeft << 8) + scanCodeRight;
   236         TUint scanCode = (scanCodeLeft << 8) + scanCodeRight;
   233         if (scanCode != 0)
   237         iAdditionalSelectkeyMapping = scanCode;
   234         {
   238     }
   235             iAdditionalSelectkeyMapping = scanCode;
   239     else
   236         }
   240     {
       
   241         // Default value is set in error situations.
       
   242         iAdditionalSelectkeyMapping = 0;
   237     }
   243     }
   238 
   244 
   239     CreateQwertyWatchL();
   245     CreateQwertyWatchL();
   240     CreateGameActionsL();
   246     CreateGameActionsL();
   241 
   247 
   295     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice11,EKeyRightUpArrow, R_MIDP_KEY_RIGHT)));
   301     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice11,EKeyRightUpArrow, R_MIDP_KEY_RIGHT)));
   296     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice12,EKeyRightDownArrow, R_MIDP_KEY_RIGHT)));
   302     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice12,EKeyRightDownArrow, R_MIDP_KEY_RIGHT)));
   297     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice13,EKeyLeftDownArrow, R_MIDP_KEY_LEFT)));
   303     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDevice13,EKeyLeftDownArrow, R_MIDP_KEY_LEFT)));
   298     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDelete,EKeyDelete, R_MIDP_KEY_DELETE)));
   304     User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyDelete,EKeyDelete, R_MIDP_KEY_DELETE)));
   299     if (!iQwertyModeActive)
   305     if (!iQwertyModeActive)
   300     { // ITU-T keys with different behaviour
   306     {
       
   307         // ITU-T keys with different behaviour
   301         User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyBackspace, KMIDKeyClear, R_MIDP_KEY_CLEAR)));
   308         User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyBackspace, KMIDKeyClear, R_MIDP_KEY_CLEAR)));
   302     }
   309     }
   303     else
   310     else
   304     { // QWERTY  keys with different behaviour
   311     {
       
   312         // QWERTY  keys with different behaviour
   305         User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyBackspace, EKeyBackspace, R_MIDP_KEY_BACKSPACE)));
   313         User::LeaveIfError(iSpecialKeys.Append(TMIDKey(EStdKeyBackspace, EKeyBackspace, R_MIDP_KEY_BACKSPACE)));
   306     }
   314     }
   307 
   315 
   308     /*
   316     /*
   309         // Keys defined in specs but not yet present in Series 60
   317         // Keys defined in specs but not yet present in Series 60
   555     }
   563     }
   556 
   564 
   557     iActionScanCodes = NULL;
   565     iActionScanCodes = NULL;
   558 
   566 
   559     if (!QwertyInputAvailable())
   567     if (!QwertyInputAvailable())
   560     { // if no qwerty always use default ITU-T codes
   568     {
       
   569         // if no qwerty always use default ITU-T codes
   561         DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - use default ITU-T scan codes");
   570         DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - use default ITU-T scan codes");
   562         iActionScanCodes = (TInt*)&KDefaultActionScanCodes[0];
   571         iActionScanCodes = (TInt*)&KDefaultActionScanCodes[0];
   563     }
   572     }
   564     else
   573     else
   565     { // if there is qwerty either use CR repository codes or default qwerty codes
   574     {
       
   575         // if there is qwerty either use CR repository codes or default qwerty codes
   566         CRepository* repository = NULL;
   576         CRepository* repository = NULL;
   567         TRAPD(crExists, repository = CRepository::NewL(KCRUidMidpLcdui));
   577         TRAPD(crExists, repository = CRepository::NewL(KCRUidMidpLcdui));
   568 
   578 
   569         if (crExists == KErrNone)
   579         if (crExists == KErrNone)
   570         {
   580         {
   571             CleanupStack::PushL(repository);
   581             CleanupStack::PushL(repository);
   572             repository->Get(KUseCustomGameActionScanCodes, iUseCRScanCodes);
   582             repository->Get(KUseCustomGameActionScanCodes, iUseCRScanCodes);
   573         }
   583         }
   574 
   584 
   575         if (iUseCRScanCodes)
   585         if (iUseCRScanCodes)
   576         { // use CR QWERTY codes
   586         {
       
   587             // use CR QWERTY codes
   577             DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - use central repository scan codes");
   588             DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - use central repository scan codes");
   578             LoadCentralRepositoryCodesL(repository);
   589             LoadCentralRepositoryCodesL(repository);
   579         }
   590         }
   580         else
   591         else
   581         { //  use default QWERTY codes
   592         {
       
   593             //  use default QWERTY codes
   582             DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - add default qwerty scan codes");
   594             DEBUG("  CMIDKeyDecoder::LoadGameActionCodesL - add default qwerty scan codes");
   583             iActionScanCodes = (TInt*)&KDefaultQwertyActionScanCodes[0];
   595             iActionScanCodes = (TInt*)&KDefaultQwertyActionScanCodes[0];
   584         }
   596         }
   585 
   597 
   586         if (crExists == KErrNone)
   598         if (crExists == KErrNone)