160 PRINT ( _L("Enter CPcsKeyMap::~CPcsKeyMap") ); |
122 PRINT ( _L("Enter CPcsKeyMap::~CPcsKeyMap") ); |
161 |
123 |
162 // Cleanup local arrays |
124 // Cleanup local arrays |
163 iLanguageNotSupported.Reset(); |
125 iLanguageNotSupported.Reset(); |
164 |
126 |
165 for (TInt i = 0; i < PoolCount(); i++) |
127 for (TInt i = 0; i < iItutKeyMaps.Count(); i++) |
166 { |
128 { |
167 for (TInt j = 0; j < TKeyMappingData::EKeyMapNumberArr; j++) |
129 for (TInt j = 0; j < TKeyMappingData::EKeyMapNumberArr; j++) |
168 { |
130 { |
169 iKeyMapPtrArr[i]->iKeyMapCharArr[j].Close(); |
131 iItutKeyMaps[i]->iKeyMapCharArr[j].Close(); |
170 } |
132 } |
171 } |
133 } |
172 iKeyMapPtrArr.ResetAndDestroy(); |
134 iItutKeyMaps.ResetAndDestroy(); |
173 iKeysArr.Close(); |
135 |
|
136 for (TInt i = 0; i < iQwertyKeyMaps.Count(); i++) |
|
137 { |
|
138 for (TInt j = 0; j < TKeyMappingData::EKeyMapNumberArr; j++) |
|
139 { |
|
140 iQwertyKeyMaps[i]->iKeyMapCharArr[j].Close(); |
|
141 } |
|
142 } |
|
143 iQwertyKeyMaps.ResetAndDestroy(); |
|
144 |
|
145 iItutKeys.Close(); |
|
146 iQwertyKeys.Close(); |
174 |
147 |
175 PRINT ( _L("End CPcsKeyMap::~CPcsKeyMap") ); |
148 PRINT ( _L("End CPcsKeyMap::~CPcsKeyMap") ); |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // CPcsKeyMap::IsModePredictive |
|
153 // |
|
154 // ---------------------------------------------------------------------------- |
|
155 TBool CPcsKeyMap::IsModePredictive( TKeyboardModes aKbMode ) |
|
156 { |
|
157 return ( (EPredictiveDefaultKeyboard == aKbMode) || |
|
158 (EPredictiveItuT == aKbMode) || |
|
159 (EPredictiveQwerty == aKbMode) ); |
|
160 } |
|
161 |
|
162 // ---------------------------------------------------------------------------- |
|
163 // CPcsKeyMap::ResolveKeyboardMode |
|
164 // Resolve EPredictiveDefaultKeyboard or ENonPredictive mode to EPredictiveItuT |
|
165 // or EPredictiveQwerty mode |
|
166 // ---------------------------------------------------------------------------- |
|
167 TKeyboardModes CPcsKeyMap::ResolveKeyboardMode( TKeyboardModes aKbMode, |
|
168 TKeyboardModes aKbModeToResolve ) const |
|
169 { |
|
170 // Substitute "default predictive" mode with actual mode |
|
171 if ( (aKbMode == aKbModeToResolve) && |
|
172 ((aKbMode == ENonPredictive) || (aKbMode == EPredictiveDefaultKeyboard)) ) |
|
173 { |
|
174 return iPredictiveDefaultKeyboardMode; |
|
175 } |
|
176 else |
|
177 { |
|
178 return aKbMode; |
|
179 } |
176 } |
180 } |
177 |
181 |
178 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
179 // CPcsKeyMap::GetMixedKeyStringForQueryL |
183 // CPcsKeyMap::GetMixedKeyStringForQueryL |
180 // aDestStr will have the length as the number of items in aSrcQuery. |
184 // aDestStr will have the length as the number of items in aSrcQuery. |
181 // ---------------------------------------------------------------------------- |
185 // ---------------------------------------------------------------------------- |
182 void CPcsKeyMap::GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) |
186 void CPcsKeyMap::GetMixedKeyStringForQueryL( |
183 { |
187 CPsQuery& aSrcQuery, TDes& aDestStr) const |
|
188 { |
184 PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForQueryL") ); |
189 PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForQueryL") ); |
185 |
190 |
186 GetMixedKeyStringForDataL( aSrcQuery, aSrcQuery.QueryAsStringLC(), aDestStr ); |
191 GetMixedKeyStringForDataL( aSrcQuery, aSrcQuery.QueryAsStringLC(), aDestStr ); |
187 CleanupStack::PopAndDestroy(); //result of QueryAsStringLC |
192 CleanupStack::PopAndDestroy(); //result of QueryAsStringLC |
188 |
193 |
189 PRINT ( _L("End CPcsKeyMap::GetMixedKeyStringForQueryL") ); |
194 PRINT ( _L("End CPcsKeyMap::GetMixedKeyStringForQueryL") ); |
190 } |
195 } |
191 |
196 |
192 // ---------------------------------------------------------------------------- |
197 // ---------------------------------------------------------------------------- |
193 // CPcsKeyMap::GetMixedKeyStringForDataL |
198 // CPcsKeyMap::GetMixedKeyStringForDataL |
194 // aDestStr will have the same length as aSrcData. aSrcQuery can be shorter. |
199 // aDestStr will have the same length as aSrcData. aSrcQuery can be shorter. |
195 // ---------------------------------------------------------------------------- |
200 // ---------------------------------------------------------------------------- |
196 void CPcsKeyMap::GetMixedKeyStringForDataL( |
201 void CPcsKeyMap::GetMixedKeyStringForDataL( |
197 CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) |
202 CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const |
198 { |
203 { |
199 PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForDataL") ); |
204 PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForDataL") ); |
200 |
205 |
201 for ( TInt i = 0; i < aSrcData.Length(); ++i ) |
206 for ( TInt i = 0; i < aSrcData.Length(); ++i ) |
202 { |
207 { |
203 TChar character( aSrcData[i] ); |
208 TChar character( aSrcData[i] ); |
204 character.LowerCase(); |
209 character.LowerCase(); |
205 if ( i < aSrcQuery.Count() ) |
210 if ( i < aSrcQuery.Count() ) |
206 { |
211 { |
207 CPsQueryItem& currentItem = aSrcQuery.GetItemAtL(i); |
212 CPsQueryItem& currentItem = aSrcQuery.GetItemAtL(i); |
208 switch ( currentItem.Mode() ) |
213 TPtiKey key = KeyForCharacterMultiMatch( aSrcData[i], currentItem.Mode() ); |
209 { |
214 // If a character is not mapped to any key or it's entered in non-predictive mode, |
210 case EItut: |
215 // then append the character. |
211 { |
216 if ( EPtiKeyNone == key ) |
212 TPtiKey key = KeyForCharacterMultiMatch(aSrcData[i]); |
217 { |
213 // If a character is not mapped to numeric key append the character |
218 PRINT3 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char at index %d not mapped to a key, appending char '%c' (#%d)"), |
214 if ( EPtiKeyNone == key ) |
219 i, (TUint) character, (TUint) character ); |
215 { |
220 |
216 PRINT3 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char at index %d not mapped to a key, appending char '%c' (#%d)"), |
221 aDestStr.Append( character ); |
217 i, (TUint) character, (TUint) character ); |
222 } |
218 |
223 else |
219 aDestStr.Append( character ); |
224 { |
220 } |
225 aDestStr.Append( key ); |
221 else |
|
222 { |
|
223 aDestStr.Append( key ); |
|
224 } |
|
225 } |
|
226 break; |
|
227 case EQwerty: |
|
228 //fall through |
|
229 default: |
|
230 PRINT2 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char '%c' (#%d) is taken exact (non predictive in query)"), |
|
231 (TUint) character, (TUint) character ); |
|
232 aDestStr.Append( character ); |
|
233 break; |
|
234 } |
226 } |
235 } |
227 } |
236 else |
228 else |
237 { |
229 { |
238 PRINT2 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char '%c' (#%d) is taken exact (over query length)"), |
230 PRINT2 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char '%c' (#%d) is taken exact (over query length)"), |
461 |
477 |
462 // Set the key value from the pool index |
478 // Set the key value from the pool index |
463 TPtiKey key = EPtiKeyNone; |
479 TPtiKey key = EPtiKeyNone; |
464 if ( KErrNotFound != poolIndex ) |
480 if ( KErrNotFound != poolIndex ) |
465 { |
481 { |
466 key = iKeysArr[poolIndex]; |
482 key = (*ptiKeyArray)[poolIndex]; |
467 } |
483 } |
468 |
484 |
469 poolIndexArr.Close(); |
485 poolIndexArr.Close(); |
470 return key; |
486 return key; |
471 } |
487 } |
472 |
488 |
473 // ---------------------------------------------------------------------------- |
489 // ---------------------------------------------------------------------------- |
474 // CPcsKeyMap::PoolIdForKey |
490 // CPcsKeyMap::PoolIdForKey |
475 // |
491 // |
476 // ---------------------------------------------------------------------------- |
492 // ---------------------------------------------------------------------------- |
477 TInt CPcsKeyMap::PoolIdForKey(const TPtiKey aKey) |
493 TInt CPcsKeyMap::PoolIdForKey(const TPtiKey aKey, TKeyboardModes aKbMode) |
478 { |
494 { |
479 TInt poolId = iKeysArr.Find(aKey); |
495 aKbMode = ResolveKeyboardMode( aKbMode, EPredictiveDefaultKeyboard ); |
480 |
496 |
481 // IF the key is not found, then it should go to the special pool, |
497 // From logical point of view, the Pool ID is an index of the key in |
482 // which is the last pool of iKeyMapPtrArr |
498 // an array which is formed by concatenating QWERTY keys array in the end |
483 if (KErrNotFound == poolId) |
499 // of the ITU-T keys array. |
484 { |
500 TInt poolId = KErrNotFound; |
485 poolId = PoolCount() - 1; |
501 if ( aKbMode == EPredictiveItuT && iItutKeys.Count() ) |
486 } |
502 { |
|
503 poolId = iItutKeys.Find(aKey); |
|
504 // IF the key is not found, then it should go to the special pool, |
|
505 // which is the pool of the dummy key in the ITU-T keys array |
|
506 if (KErrNotFound == poolId) |
|
507 { |
|
508 poolId = iItutKeys.Count() - 1; |
|
509 } |
|
510 } |
|
511 else if ( aKbMode == EPredictiveQwerty && iQwertyKeys.Count() ) |
|
512 { |
|
513 poolId = iQwertyKeys.Find(aKey); |
|
514 // IF the key is not found, then it should go to the special pool, |
|
515 // which is the pool of the dummy key in the QWERTY keys array |
|
516 if (KErrNotFound == poolId) |
|
517 { |
|
518 poolId = iQwertyKeys.Count() - 1; |
|
519 } |
|
520 // Pools of QWERTY keys come after pools of ITU-T keys |
|
521 poolId += iItutKeys.Count(); |
|
522 } |
|
523 |
|
524 // Pool ID must never exceed value 63, because CPcsCache class |
|
525 // stores these values as bitmask into 64 bit variable. |
|
526 __ASSERT_DEBUG( poolId < 64, Panic(EPanic_OverflowInPoolIndex) ); |
487 |
527 |
488 return poolId; |
528 return poolId; |
489 } |
529 } |
490 |
530 |
491 // ---------------------------------------------------------------------------- |
531 // ---------------------------------------------------------------------------- |
492 // CPcsKeyMap::PoolIdForCharacter |
532 // CPcsKeyMap::PoolIdForCharacter |
493 // |
533 // |
494 // ---------------------------------------------------------------------------- |
534 // ---------------------------------------------------------------------------- |
495 TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar) |
535 TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar, TKeyboardModes aKbMode) |
496 { |
536 { |
497 TPtiKey key = KeyForCharacterMultiMatch(aChar); |
537 // Pools are formed according the predictive keyboard mapping(s). |
498 |
538 // When selecting pool for non-predictive mode, we use the pool of the |
499 TInt poolId = PoolIdForKey(key); |
539 // default keyboard. The non-predictive matches should be a sub set of the |
|
540 // predictive matches of the default keyboard, although strictly speaking, |
|
541 // there' no guarantee for this. |
|
542 aKbMode = ResolveKeyboardMode( aKbMode, ENonPredictive ); |
|
543 |
|
544 TPtiKey key = KeyForCharacterMultiMatch( aChar, aKbMode ); |
|
545 |
|
546 TInt poolId = (key == EPtiKeyNone) ? KErrNotFound : PoolIdForKey(key, aKbMode); |
500 |
547 |
501 return poolId; |
548 return poolId; |
502 } |
549 } |
503 |
550 |
504 // ---------------------------------------------------------------------------- |
551 // ---------------------------------------------------------------------------- |
505 // CPcsKeyMap::PoolCount |
552 // CPcsKeyMap::PoolCount |
506 // |
553 // |
507 // ---------------------------------------------------------------------------- |
554 // ---------------------------------------------------------------------------- |
508 TInt CPcsKeyMap::PoolCount() |
555 TInt CPcsKeyMap::PoolCount() |
509 { |
556 { |
510 return iKeyMapPtrArr.Count(); |
557 return iItutKeyMaps.Count() + iQwertyKeyMaps.Count(); |
511 } |
558 } |
512 |
559 |
513 // ---------------------------------------------------------------------------- |
560 // ---------------------------------------------------------------------------- |
514 // CPcsKeyMap::SetSpaceAndZeroOnSameKey |
561 // CPcsKeyMap::SetSpaceAndZeroOnSameKey |
515 // |
562 // |
516 // ---------------------------------------------------------------------------- |
563 // ---------------------------------------------------------------------------- |
517 void CPcsKeyMap::SetSpaceAndZeroOnSameKey() |
564 void CPcsKeyMap::SetSpaceAndZeroOnSameKey() |
518 { |
565 { |
519 const TInt KSpace = 32; // ASCII for " " |
566 PRINT ( _L("Enter CPcsKeyMap::SetSpaceAndZeroOnSameKey") ); |
520 const TInt KZero = 48; // ASCII for "0" |
567 |
|
568 static const TInt KSpace = 0x20; // ASCII for " " |
|
569 static const TInt KZero = 0x30; // ASCII for "0" |
521 |
570 |
522 TChar charSpace(KSpace); |
571 TChar charSpace(KSpace); |
523 TChar charZero(KZero); |
572 TChar charZero(KZero); |
524 |
573 |
525 TPtiKey keySpace = KeyForCharacterMultiMatch(charSpace); |
574 TPtiKey keySpace; |
526 TPtiKey keyZero = KeyForCharacterMultiMatch(charZero); |
575 TPtiKey keyZero; |
527 |
576 |
528 iSpaceAndZeroOnSameKey = (keySpace == keyZero); |
577 // ITU-T mode |
|
578 keySpace = KeyForCharacterMultiMatch(charSpace, EPredictiveItuT); |
|
579 keyZero = KeyForCharacterMultiMatch(charZero, EPredictiveItuT); |
|
580 iSpaceAndZeroOnSameKeyOnItut = (keySpace == keyZero && keyZero != EPtiKeyNone); |
|
581 PRINT1 ( _L("CPcsKeyMap::iSpaceAndZeroOnSameKeyOnItut = %d"), iSpaceAndZeroOnSameKeyOnItut ); |
|
582 |
|
583 // QWERTY mode |
|
584 keySpace = KeyForCharacterMultiMatch(charSpace, EPredictiveQwerty); |
|
585 keyZero = KeyForCharacterMultiMatch(charZero, EPredictiveQwerty); |
|
586 iSpaceAndZeroOnSameKeyOnQwerty = (keySpace == keyZero && keyZero != EPtiKeyNone); |
|
587 PRINT1 ( _L("CPcsKeyMap::iSpaceAndZeroOnSameKeyOnQwerty = %d"), iSpaceAndZeroOnSameKeyOnQwerty ); |
|
588 |
|
589 PRINT ( _L("CPcsKeyMap::SetSpaceAndZeroOnSameKey") ); |
529 } |
590 } |
530 |
591 |
531 // ---------------------------------------------------------------------------- |
592 // ---------------------------------------------------------------------------- |
532 // CPcsKeyMap::GetSpaceAndZeroOnSameKey |
593 // CPcsKeyMap::GetSpaceAndZeroOnSameKey |
533 // |
594 // |
534 // ---------------------------------------------------------------------------- |
595 // ---------------------------------------------------------------------------- |
535 TBool CPcsKeyMap::GetSpaceAndZeroOnSameKey() |
596 TBool CPcsKeyMap::GetSpaceAndZeroOnSameKey( TKeyboardModes aKbMode ) |
536 { |
597 { |
537 return iSpaceAndZeroOnSameKey; |
598 TBool result = EFalse; |
538 } |
599 |
539 |
600 aKbMode = ResolveKeyboardMode( aKbMode, EPredictiveDefaultKeyboard ); |
540 // ---------------------------------------------------------------------------- |
601 |
541 // CPcsKeyMap::GetKeyboardKeyMapping |
602 if ( aKbMode == EPredictiveItuT ) |
542 // Helper function to get Key Mappings depending on keyboard type |
603 { |
543 // ---------------------------------------------------------------------------- |
604 result = iSpaceAndZeroOnSameKeyOnItut; |
544 MPtiKeyMappings* CPcsKeyMap::GetKeyboardKeyMapping(CPtiCoreLanguage& aCurrLanguage) |
605 } |
545 { |
606 else if ( aKbMode == EPredictiveQwerty ) |
546 MPtiKeyMappings* ptiKeyMappings; |
607 { |
547 |
608 result = iSpaceAndZeroOnSameKeyOnQwerty; |
548 switch ( iKeyboardType ) |
609 } |
549 { |
610 |
550 case EPtiKeyboardQwerty4x12: |
611 return result; |
551 case EPtiKeyboardQwerty4x10: |
612 } |
552 case EPtiKeyboardQwerty3x11: |
613 |
553 case EPtiKeyboardCustomQwerty: |
614 // ---------------------------------------------------------------------------- |
554 ptiKeyMappings = aCurrLanguage.GetQwertyKeymappings(); |
615 // CPcsKeyMap::SetupKeyboardTypesL |
555 break; |
616 // Initialise the keyboard type variables |
556 |
617 // ---------------------------------------------------------------------------- |
557 case EPtiKeyboard12Key: |
618 void CPcsKeyMap::SetupKeyboardTypesL() |
558 ptiKeyMappings = aCurrLanguage.GetKeymappings(); |
619 { |
559 break; |
620 TInt physicalKeyboard = 0; |
560 |
621 CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep ); |
561 case EPtiKeyboardHalfQwerty: |
622 aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard ); |
562 ptiKeyMappings = aCurrLanguage.GetHalfQwertyKeymappings(); |
623 delete aknFepRepository; |
563 break; |
624 |
564 |
625 PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: Physical keyboard support flag = 0x%02X"), physicalKeyboard ); |
565 default: |
626 |
566 ptiKeyMappings = aCurrLanguage.GetKeymappings(); |
627 // Constants follow the definition of KAknFepPhysicalKeyboards |
567 break; |
628 const TInt KPtiKeyboard12Key = 0x01; |
568 } |
629 const TInt KPtiKeyboardQwerty4x12 = 0x02; |
569 |
630 const TInt KPtiKeyboardQwerty4x10 = 0x04; |
570 return ptiKeyMappings; |
631 const TInt KPtiKeyboardQwerty3x11 = 0x08; |
571 } |
632 const TInt KPtiKeyboardHalfQwerty = 0x10; |
572 |
633 const TInt KPtiKeyboardCustomQwerty = 0x20; |
573 // ---------------------------------------------------------------------------- |
634 |
574 // CPcsKeyMap::GetKeyMapData |
635 // Setup ITU-T mode first. |
575 // |
636 // Use always 12-key mode since all the supported devices should have at least |
576 // ---------------------------------------------------------------------------- |
637 // virtual ITU-T available. |
577 CPtiKeyMapData* CPcsKeyMap::GetKeyMapData(CPtiCoreLanguage& aCurrLanguage) |
638 iItutKeyboardType = EPtiKeyboard12Key; |
578 { |
639 // TODO: ITU-T type could be set to "none" if device does not have either |
579 MPtiKeyMappings* ptiKeyMappings = GetKeyboardKeyMapping( aCurrLanguage ); |
640 // virtual keypad or hardware ITU-T available. This could be decided according |
580 |
641 // some cenrep value, feature flag, device model, or platform version. |
581 CPtiKeyMapData* keyMapData; |
642 |
582 |
643 // Then setup QWERTY mode. On real-life devices there should never |
583 switch ( iKeyboardType ) |
644 // be more than one QWERTY keyboard available but on emulator there can be several. |
584 { |
645 // Use the first one found in the following precedence |
585 case EPtiKeyboardQwerty4x12: |
646 if ( physicalKeyboard & KPtiKeyboardQwerty3x11 ) |
586 case EPtiKeyboardQwerty4x10: |
647 { |
587 case EPtiKeyboardQwerty3x11: |
648 iQwertyKeyboardType = EPtiKeyboardQwerty3x11; |
588 case EPtiKeyboardCustomQwerty: |
649 } |
589 keyMapData = static_cast<CPtiQwertyKeyMappings*>(ptiKeyMappings)->KeyMapData(); |
650 else if ( physicalKeyboard & KPtiKeyboardQwerty4x10 ) |
590 break; |
651 { |
591 |
652 iQwertyKeyboardType = EPtiKeyboardQwerty4x10; |
592 case EPtiKeyboard12Key: |
653 } |
593 keyMapData = static_cast<CPtiKeyMappings*>(ptiKeyMappings)->KeyMapData(); |
654 else if ( physicalKeyboard & KPtiKeyboardQwerty4x12 ) |
594 break; |
655 { |
595 |
656 iQwertyKeyboardType = EPtiKeyboardQwerty4x12; |
596 case EPtiKeyboardHalfQwerty: |
657 } |
597 keyMapData = static_cast<CPtiHalfQwertyKeyMappings*>(ptiKeyMappings)->KeyMapData(); |
658 else if ( physicalKeyboard & KPtiKeyboardCustomQwerty ) |
598 break; |
659 { |
599 |
660 iQwertyKeyboardType = EPtiKeyboardCustomQwerty; |
600 default: |
661 } |
601 keyMapData = static_cast<CPtiKeyMappings*>(ptiKeyMappings)->KeyMapData(); |
662 else if ( physicalKeyboard & KPtiKeyboardHalfQwerty ) |
602 break; |
663 { |
603 } |
664 iQwertyKeyboardType = EPtiKeyboardHalfQwerty; |
604 |
665 } |
605 return keyMapData; |
666 else |
|
667 { |
|
668 iQwertyKeyboardType = EPtiKeyboardNone; |
|
669 } |
|
670 |
|
671 // Set the Default Predictive keyboard mode |
|
672 iPredictiveDefaultKeyboardMode = ( |
|
673 (physicalKeyboard & KPtiKeyboard12Key) || (iQwertyKeyboardType == EPtiKeyboardNone) ? |
|
674 EPredictiveItuT : EPredictiveQwerty ); |
|
675 |
|
676 PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: ITU-T Keyboard chosen for Predictive Search = %d"), iItutKeyboardType ); |
|
677 PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: QWERTY Keyboard chosen for Predictive Search = %d"), iQwertyKeyboardType ); |
606 } |
678 } |
607 |
679 |
608 // ---------------------------------------------------------------------------- |
680 // ---------------------------------------------------------------------------- |
609 // CPcsKeyMap::AppendEntryWithFakeKeyToKeyList |
681 // CPcsKeyMap::AppendEntryWithFakeKeyToKeyList |
610 // Add pool with unused id for for key |
682 // Add pool with unused id for for key |
611 // ---------------------------------------------------------------------------- |
683 // ---------------------------------------------------------------------------- |
612 void CPcsKeyMap::AppendEntryWithFakeKeyToKeyList() |
684 void CPcsKeyMap::AppendEntryWithFakeKeyToKeyList( RArray<TPtiKey>& aKeyArray ) |
613 { |
685 { |
614 TUint keyUInt = (TUint) EPtiKeyNone + 1; |
686 TUint keyUInt = (TUint) EPtiKeyNone + 1; |
615 |
687 |
616 while ( KErrNotFound != iKeysArr.Find( (TPtiKey) keyUInt) ) |
688 while ( KErrNotFound != aKeyArray.Find( (TPtiKey) keyUInt) ) |
617 { |
689 { |
618 keyUInt++; |
690 keyUInt++; |
619 } |
691 } |
620 |
692 |
621 TPtiKey key = (TPtiKey) keyUInt; |
693 TPtiKey key = (TPtiKey) keyUInt; |
622 iKeysArr.Append( key ); |
694 aKeyArray.Append( key ); |
623 |
695 |
624 // This should always be the last one in the array |
696 // This should always be the last one in the array |
625 PRINT2 ( _L("CPcsKeyMap::AppendEntryWithFakeKeyToKeyList: Added additional last pool %d with key id #%d"), |
697 PRINT2 ( _L("CPcsKeyMap::AppendEntryWithFakeKeyToKeyList: Added additional last pool %d with key id #%d"), |
626 iKeysArr.Count()-1, key ); |
698 aKeyArray.Count()-1, key ); |
627 } |
|
628 |
|
629 // ---------------------------------------------------------------------------- |
|
630 // CPcsKeyMap::CreateKeyMapFromITUTHardcodedKeys |
|
631 // |
|
632 // ---------------------------------------------------------------------------- |
|
633 void CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys() |
|
634 { |
|
635 PRINT ( _L("Enter CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys") ); |
|
636 |
|
637 iKeysArr.Append( EPtiKey0 ); |
|
638 iKeysArr.Append( EPtiKey1 ); |
|
639 iKeysArr.Append( EPtiKey2 ); |
|
640 iKeysArr.Append( EPtiKey3 ); |
|
641 iKeysArr.Append( EPtiKey4 ); |
|
642 iKeysArr.Append( EPtiKey5 ); |
|
643 iKeysArr.Append( EPtiKey6 ); |
|
644 iKeysArr.Append( EPtiKey7 ); |
|
645 iKeysArr.Append( EPtiKey8 ); |
|
646 iKeysArr.Append( EPtiKey9 ); |
|
647 |
|
648 AppendEntryWithFakeKeyToKeyList(); |
|
649 |
|
650 PRINT ( _L("End CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys") ); |
|
651 } |
699 } |
652 |
700 |
653 // ---------------------------------------------------------------------------- |
701 // ---------------------------------------------------------------------------- |
654 // CPcsKeyMap::CreateKeyMapFromKeyBindingTable |
702 // CPcsKeyMap::CreateKeyMapFromKeyBindingTable |
655 // |
703 // |
656 // ---------------------------------------------------------------------------- |
704 // ---------------------------------------------------------------------------- |
657 void CPcsKeyMap::CreateKeyListFromKeyBindingTable( CPtiEngine* aPtiEngine ) |
705 void CPcsKeyMap::CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, |
|
706 TPtiKeyboardType aKbType, CPtiEngine* aPtiEngine ) |
658 { |
707 { |
659 PRINT ( _L("Enter CPcsKeyMap::CreateKeyListFromKeyBindingTable") ); |
708 PRINT ( _L("Enter CPcsKeyMap::CreateKeyListFromKeyBindingTable") ); |
|
709 |
|
710 PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Creating KeyList for TPtiKeyboardType=%d"), |
|
711 aKbType ); |
660 |
712 |
661 // Get the user language |
713 // Get the user language |
662 TLanguage keyMapLanguage = iUILanguage; |
714 TLanguage keyMapLanguage = iUILanguage; |
663 PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Current User Language is %d"), |
715 PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Current User Language is %d"), |
664 keyMapLanguage ); |
716 keyMapLanguage ); |
698 TPtiKey key = (TPtiKey) table[i].iScanCode; |
761 TPtiKey key = (TPtiKey) table[i].iScanCode; |
699 // Get all keys with same EPtiCaseLower or EPtiCaseUpper case |
762 // Get all keys with same EPtiCaseLower or EPtiCaseUpper case |
700 // Only for one of the casing to avoid repetitions |
763 // Only for one of the casing to avoid repetitions |
701 if ( (EPtiKeyNone != key) && (EPtiCaseLower == table[i].iCase) ) |
764 if ( (EPtiKeyNone != key) && (EPtiCaseLower == table[i].iCase) ) |
702 { |
765 { |
703 PRINT3 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Adding pool %d with key '%c' (%d)"), |
766 PRINT3 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Adding pool %d with key '%c' (0x%02X)"), |
704 iKeysArr.Count(), key, key ); |
767 aKeyArray.Count(), key, key ); |
705 iKeysArr.Append( key ); |
768 aKeyArray.Append( key ); |
706 } |
769 } |
707 } |
770 } |
|
771 // Add a fake key at the end if the KeyList is not empty |
|
772 if (aKeyArray.Count() > 0) |
|
773 { |
|
774 AppendEntryWithFakeKeyToKeyList(aKeyArray); |
|
775 } |
708 } |
776 } |
709 else |
777 else |
710 { |
778 { |
711 PRINT ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: ##### Failed to create Key List (KeyBindingTable) #####") ); |
779 PRINT ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: ##### Failed to create Key List (KeyBindingTable) #####") ); |
712 } |
780 } |
713 } |
781 } |
714 else |
782 else |
715 { |
783 { |
716 PRINT ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: ##### Failed to create Key List (Language) #####") ); |
784 PRINT ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: ##### Failed to create Key List (Language) #####") ); |
717 } |
785 } |
718 |
|
719 AppendEntryWithFakeKeyToKeyList(); |
|
720 |
786 |
721 PRINT ( _L("End CPcsKeyMap::CreateKeyListFromKeyBindingTable") ); |
787 PRINT ( _L("End CPcsKeyMap::CreateKeyListFromKeyBindingTable") ); |
722 } |
788 } |
723 |
789 |
724 // ---------------------------------------------------------------------------- |
790 // ---------------------------------------------------------------------------- |
725 // CPcsKeyMap::CreateKeyListL |
|
726 // |
|
727 // ---------------------------------------------------------------------------- |
|
728 void CPcsKeyMap::CreateKeyListL( CPtiEngine* aPtiEngine ) |
|
729 { |
|
730 PRINT ( _L("Enter CPcsKeyMap::CreateKeyListL") ); |
|
731 |
|
732 switch ( iKeyboardType ) |
|
733 { |
|
734 case EPtiKeyboardQwerty4x12: |
|
735 case EPtiKeyboardQwerty4x10: |
|
736 case EPtiKeyboardQwerty3x11: |
|
737 case EPtiKeyboardCustomQwerty: |
|
738 CreateKeyListFromKeyBindingTable( aPtiEngine ); |
|
739 break; |
|
740 |
|
741 case EPtiKeyboard12Key: |
|
742 CreateKeyListFromITUTHardcodedKeys( ); |
|
743 break; |
|
744 |
|
745 case EPtiKeyboardHalfQwerty: |
|
746 CreateKeyListFromKeyBindingTable( aPtiEngine ); |
|
747 break; |
|
748 |
|
749 default: |
|
750 CreateKeyListFromKeyBindingTable( aPtiEngine ); |
|
751 break; |
|
752 } |
|
753 |
|
754 PRINT ( _L("End CPcsKeyMap::CreateKeyListL") ); |
|
755 } |
|
756 |
|
757 // ---------------------------------------------------------------------------- |
|
758 // CPcsKeyMap::IsLanguageSupported |
791 // CPcsKeyMap::IsLanguageSupported |
759 // Returns ETrue if this language is supported |
792 // Returns ETrue if this language is supported |
760 // ---------------------------------------------------------------------------- |
793 // ---------------------------------------------------------------------------- |
761 TBool CPcsKeyMap::IsLanguageSupported(TInt aLang) |
794 TBool CPcsKeyMap::IsLanguageSupported(TInt aLang) |
762 { |
795 { |
763 return (KErrNotFound == iLanguageNotSupported.Find((TLanguage) aLang)); |
796 TBool supported = |
|
797 #ifdef __WINS__ |
|
798 // Only few languages for emulator |
|
799 ( ELangEnglish == aLang || |
|
800 ELangRussian == aLang || |
|
801 ELangHebrew == aLang || |
|
802 ELangFinnish == aLang ) && |
|
803 #endif // __WINS__ |
|
804 ( KErrNotFound == iLanguageNotSupported.Find((TLanguage)aLang) ); |
|
805 |
|
806 return supported; |
764 } |
807 } |
765 |
808 |
766 // ---------------------------------------------------------------------------- |
809 // ---------------------------------------------------------------------------- |
767 // CPcsKeyMap::CreateKeyMappingL |
810 // CPcsKeyMap::CreateKeyMappingL |
768 // |
811 // |
769 // ---------------------------------------------------------------------------- |
812 // ---------------------------------------------------------------------------- |
770 void CPcsKeyMap::CreateKeyMappingL() |
813 void CPcsKeyMap::CreateKeyMappingL( TKeyboardModes aKbMode ) |
771 { |
814 { |
772 PRINT ( _L("Enter CPcsKeyMap::CreateKeyMappingL") ); |
815 PRINT ( _L("Enter CPcsKeyMap::CreateKeyMappingL") ); |
773 |
816 |
|
817 __ASSERT_DEBUG( (aKbMode==EPredictiveItuT || aKbMode==EPredictiveQwerty), |
|
818 Panic(EPanic_InvalidKeyboardType) ); |
|
819 |
|
820 // Select the arrays we are operating on |
|
821 RArray<TPtiKey>* ptiKeysArray; |
|
822 RPointerArray<TKeyMappingData>* keyMappingArray; |
|
823 TPtiKeyboardType kbType; |
|
824 GetPredictiveKeyboardData( aKbMode, ptiKeysArray, keyMappingArray, kbType ); |
|
825 if ( kbType == EPtiKeyboardNone ) |
|
826 { |
|
827 PRINT1( _L("CPcsKeyMap::CreateKeyMappingL: ##### No Keyboard available for mode %d => skipping #####"), aKbMode ); |
|
828 return; |
|
829 } |
|
830 |
774 // Instantiate the engine |
831 // Instantiate the engine |
775 CPtiEngine* ptiEngine = CPtiEngine::NewL(ETrue); |
832 CPtiEngine* ptiEngine = CPtiEngine::NewL(ETrue); |
776 CleanupStack::PushL( ptiEngine ); |
833 CleanupStack::PushL( ptiEngine ); |
777 |
834 |
778 ptiEngine->SetKeyboardType( iKeyboardType ); |
835 ptiEngine->SetKeyboardType( kbType ); |
779 |
836 |
780 CreateKeyListL( ptiEngine ); |
837 CreateKeyListFromKeyBindingTable( *ptiKeysArray, kbType, ptiEngine ); |
781 |
838 |
782 // Now add the keymap arrays to hold the keymap data |
839 if ( ptiKeysArray->Count() > 0 ) |
783 for (TInt i = 0; i < iKeysArr.Count(); i++) |
840 { |
784 { |
841 // Now add the keymap arrays to hold the keymap data |
785 TKeyMappingData *keyData = new(ELeave) TKeyMappingData; |
842 for (TInt i = 0; i < ptiKeysArray->Count(); i++) |
786 iKeyMapPtrArr.Append(keyData); |
843 { |
787 } |
844 TKeyMappingData *keyData = new(ELeave) TKeyMappingData; |
788 |
845 keyMappingArray->Append(keyData); |
789 // Get the available Languages on the phone |
846 } |
790 RArray<TInt> LanguagesOnThisPhone; |
847 |
791 ptiEngine->GetAvailableLanguagesL(LanguagesOnThisPhone); |
848 // Get the available Languages on the phone |
792 PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Languages on this phone %d, maximum is set to %d"), |
849 RArray<TInt> languagesOnThisPhone; |
793 LanguagesOnThisPhone.Count(), KMaxNbrOfLangKeymapping ); |
850 CleanupClosePushL( languagesOnThisPhone ); |
794 |
851 ptiEngine->GetAvailableLanguagesL(languagesOnThisPhone); |
795 // Remove the non-supported languages |
852 PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Languages on this phone %d, maximum is set to %d"), |
796 for (TInt i = 0; i < LanguagesOnThisPhone.Count(); /* do not increment i */) |
853 languagesOnThisPhone.Count(), KMaxNbrOfLangKeymapping ); |
797 { |
854 |
798 if ( (IsLanguageSupported(LanguagesOnThisPhone[i])) |
855 // Remove the non-supported languages |
799 #ifdef __WINS__ |
856 for (TInt i = 0; i < languagesOnThisPhone.Count(); /* do not increment i */) |
800 && (ELangEnglish == LanguagesOnThisPhone[i]) // Only English for emulator |
857 { |
801 #endif // __WINS__ |
858 if ( IsLanguageSupported(languagesOnThisPhone[i]) ) |
802 ) |
859 { |
803 { |
860 i++; |
804 i++; |
861 } |
805 } |
862 else |
806 else |
863 { |
807 { |
864 PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Removing not supported Language %d"), |
808 PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Removing not supported Language %d"), |
865 languagesOnThisPhone[i] ); |
809 LanguagesOnThisPhone[i] ); |
866 languagesOnThisPhone.Remove(i); |
810 LanguagesOnThisPhone.Remove(i); |
867 } |
811 } |
868 } |
812 } |
869 |
813 |
870 // Set current UI language as 1st language and English as 2nd language, |
814 // Set current UI language as 1st language and English as 2nd language, |
871 // if present in AvailableLanguages |
815 // if present in AvailableLanguages |
872 TInt langIndex; |
816 TInt langIndex; |
873 if ( KErrNotFound != (langIndex = languagesOnThisPhone.Find(ELangEnglish)) ) |
817 if ( KErrNotFound != (langIndex = LanguagesOnThisPhone.Find(ELangEnglish)) ) |
874 { |
818 { |
875 languagesOnThisPhone.Remove(langIndex); |
819 LanguagesOnThisPhone.Remove(langIndex); |
876 languagesOnThisPhone.Insert(ELangEnglish, 0); |
820 LanguagesOnThisPhone.Insert(ELangEnglish, 0); |
877 } |
821 } |
878 if ( KErrNotFound != (langIndex = languagesOnThisPhone.Find(iUILanguage)) ) |
822 if ( KErrNotFound != (langIndex = LanguagesOnThisPhone.Find(iUILanguage)) ) |
879 { |
823 { |
880 languagesOnThisPhone.Remove(langIndex); |
824 LanguagesOnThisPhone.Remove(langIndex); |
881 languagesOnThisPhone.Insert(iUILanguage, 0); |
825 LanguagesOnThisPhone.Insert(iUILanguage, 0); |
882 } |
826 } |
883 |
827 |
884 // Set max number of languages for Key Map |
828 // Set max number of languages for Key Map |
885 TInt count = languagesOnThisPhone.Count(); |
829 TInt count = LanguagesOnThisPhone.Count(); |
886 if (count > KMaxNbrOfLangKeymapping) |
830 if (count > KMaxNbrOfLangKeymapping) |
887 { |
831 { |
888 PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Supported Languages on this phone %d, limiting to %d"), |
832 PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Supported Languages on this phone %d, limiting to %d"), |
889 count, KMaxNbrOfLangKeymapping ); |
833 count, KMaxNbrOfLangKeymapping ); |
890 count = KMaxNbrOfLangKeymapping; |
834 count = KMaxNbrOfLangKeymapping; |
891 } |
835 } |
892 |
836 |
893 // Add Key Map for the languages |
837 // Add Key Map for the languages |
894 for (TInt i = 0; i < count; i++) |
838 for (TInt i = 0; i < count; i++) |
895 { |
839 { |
896 TLanguage languageToUse = (TLanguage) languagesOnThisPhone[i]; |
840 TLanguage languageToUse = (TLanguage) LanguagesOnThisPhone[i]; |
897 |
841 |
898 PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Constructing Key Map for Language %d"), languageToUse ); |
842 PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Constructing Key Map for Language %d"), languageToUse ); |
899 TRAPD( leaveCode, AddKeyMappingForLanguageL(ptiEngine, languageToUse, kbType, *ptiKeysArray, *keyMappingArray) ); |
843 TInt errStatus = ptiEngine->ActivateLanguageL(languageToUse); |
900 if ( leaveCode ) |
844 if (KErrNone == errStatus) |
901 { |
845 { |
902 PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: ##### Adding mappings for language %d failed, leave code = %d #####"), |
846 TRAP_IGNORE(AddKeyMappingForActiveLanguageL(ptiEngine, languageToUse)); |
903 languageToUse, leaveCode ); |
847 } |
904 } |
848 else |
905 |
849 { |
906 PRINT ( _L("CPcsKeyMap::CreateKeyMappingL: ===================================================") ); |
850 PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: ##### Unable to activate Language %d #####"), |
907 } |
851 languageToUse ); |
908 |
852 } |
909 CleanupStack::PopAndDestroy( &languagesOnThisPhone ); |
853 |
910 } |
854 // Close the currently activated language |
|
855 ptiEngine->CloseCurrentLanguageL(); |
|
856 |
|
857 PRINT ( _L("CPcsKeyMap::CreateKeyMappingL: ===================================================") ); |
|
858 } |
|
859 |
|
860 LanguagesOnThisPhone.Close(); |
|
861 |
911 |
862 CleanupStack::PopAndDestroy( ptiEngine ); |
912 CleanupStack::PopAndDestroy( ptiEngine ); |
863 |
913 |
864 PRINT ( _L("End CPcsKeyMap::CreateKeyMappingL") ); |
914 PRINT ( _L("End CPcsKeyMap::CreateKeyMappingL") ); |
865 } |
915 } |
866 |
916 |
867 // ---------------------------------------------------------------------------- |
917 // ---------------------------------------------------------------------------- |
868 // CPcsKeyMap::AddKeyMappingForActiveLanguageL |
918 // CPcsKeyMap::AddKeyMappingForActiveLanguageL |
869 // |
919 // |
870 // ---------------------------------------------------------------------------- |
920 // ---------------------------------------------------------------------------- |
871 void CPcsKeyMap::AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage) |
921 void CPcsKeyMap::AddKeyMappingForLanguageL( |
|
922 CPtiEngine* aPtiEngine, |
|
923 TLanguage aLanguage, |
|
924 TPtiKeyboardType aKbType, |
|
925 const RArray<TPtiKey>& aPtiKeys, |
|
926 RPointerArray<TKeyMappingData>& aResultMapping ) |
872 { |
927 { |
873 PRINT ( _L("Enter CPcsKeyMap::AddKeyMappingForActiveLanguageL") ); |
928 PRINT ( _L("Enter CPcsKeyMap::AddKeyMappingForLanguageL") ); |
|
929 |
|
930 TInt err = aPtiEngine->ActivateLanguageL( aLanguage ); |
|
931 if ( err ) |
|
932 { |
|
933 PRINT2 ( _L("##### CPcsKeyMap::AddKeyMappingForLanguageL failed to activate language %d, error=%d) #####"), |
|
934 aLanguage, err ); |
|
935 User::Leave( err ); |
|
936 } |
874 |
937 |
875 // Make a language object based on the language |
938 // Make a language object based on the language |
876 CPtiCoreLanguage* activeLanguage = static_cast<CPtiCoreLanguage*>(aPtiEngine->GetLanguage( aLanguage )); |
939 CPtiCoreLanguage* language = static_cast<CPtiCoreLanguage*>(aPtiEngine->GetLanguage( aLanguage )); |
877 |
940 |
878 if (activeLanguage) |
941 if (language) |
879 { |
942 { |
880 // Get the keyboard Mappings for the Active Language |
943 for (TInt i = 0; i < aResultMapping.Count() - 1; i++) |
881 MPtiKeyMappings* ptiKeyMappings = GetKeyboardKeyMapping( *activeLanguage ); |
944 { |
882 |
945 TPtiKey key = aPtiKeys[i]; |
883 for (TInt i = 0; i < PoolCount() - 1; i++) |
946 |
884 { |
947 PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ===================================================") ); |
885 TPtiKey key = iKeysArr[i]; |
948 PRINT4 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Adding chars for Key '%c' (0x%02X) for Keyboard Type %d and Language %d"), |
886 |
949 key, key, aKbType, aLanguage ); |
887 PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ===================================================") ); |
|
888 PRINT4 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Adding characters for Key '%c' (%d) at Pool %d and Language %d"), |
|
889 (TInt) key, (TInt) key, PoolIdForKey(key), aLanguage ); |
|
890 |
950 |
891 // Get the pointer to the language class (UI, English, Others) |
951 // Get the pointer to the language class (UI, English, Others) |
892 RArray<TUint>* keyMapLang; |
952 RArray<TUint>* keyMapLang; |
893 if (aLanguage == iUILanguage) |
953 if (aLanguage == iUILanguage) |
894 { |
954 { |
895 keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapUILangArr]); |
955 keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapUILangArr]); |
896 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is the UI language"), aLanguage ); |
956 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is the UI language"), aLanguage ); |
897 } |
957 } |
898 else if (aLanguage == ELangEnglish) |
958 else if (aLanguage == ELangEnglish) |
899 { |
959 { |
900 // If (iUILanguage == ELangEnglish) ok to be in previous if case |
960 // If (iUILanguage == ELangEnglish) ok to be in previous if case |
901 keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapEnglishLangArr]); |
961 keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapEnglishLangArr]); |
902 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is English language"), aLanguage ); |
962 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is English language"), aLanguage ); |
903 } |
963 } |
904 else |
964 else |
905 { |
965 { |
906 keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapOthersLangArr]); |
966 keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapOthersLangArr]); |
907 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is in the Other languages"), aLanguage ); |
967 PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is in the Other languages"), aLanguage ); |
908 } |
968 } |
909 |
969 |
910 PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ---------------------------------------------------") ); |
970 PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ---------------------------------------------------") ); |
911 |
971 |
912 TBool isSingleCharForKey = ETrue; |
972 TBool isSingleCharForKey = ETrue; |
913 TUint singleChar = 0; |
973 TUint singleChar = 0; |
914 |
974 |
915 // EPtiCaseUpper must be the 1st TPtiTextCase for iUILanguage |
975 // EPtiCaseUpper must be the 1st TPtiTextCase for iUILanguage |
916 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseUpper, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
976 AddCharactersToKey( *language, aKbType, key, EPtiCaseUpper, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
917 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseLower, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
977 AddCharactersToKey( *language, aKbType, key, EPtiCaseLower, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
918 |
978 |
919 // 1. No other TPtiTextCase values for ITUT keyboard |
979 // 1. No other TPtiTextCase values for ITUT keyboard |
920 // 2. No language variants handling for ITUT keyboard |
980 // 2. No language variants handling for ITUT keyboard |
921 if ( EPtiKeyboard12Key != iKeyboardType ) |
981 if ( EPtiKeyboard12Key != aKbType ) |
922 { |
982 { |
923 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseFnLower, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
983 AddCharactersToKey( *language, aKbType, key, EPtiCaseFnLower, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
924 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseFnUpper, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
984 AddCharactersToKey( *language, aKbType, key, EPtiCaseFnUpper, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
925 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseChrLower, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
985 AddCharactersToKey( *language, aKbType, key, EPtiCaseChrLower, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
926 AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseChrUpper, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar ); |
986 AddCharactersToKey( *language, aKbType, key, EPtiCaseChrUpper, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar ); |
927 |
987 |
928 // Support for key guessing given the char in some phone language variants |
988 // Support for key guessing given the char in some phone language variants |
929 if ( (isSingleCharForKey) && (0 != singleChar) ) |
989 if ( (isSingleCharForKey) && (0 != singleChar) ) |
930 { |
990 { |
931 iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(singleChar); // singleChar is in LowerCase |
991 aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(singleChar); // singleChar is in LowerCase |
932 iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(User::UpperCase(singleChar)); |
992 aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(User::UpperCase(singleChar)); |
933 |
993 |
934 PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ---------------------------------------------------") ); |
994 PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ---------------------------------------------------") ); |
935 PRINT5 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: For Language %d and key '%c' of pool %d single char is '%c' (#%d)"), |
995 PRINT5 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: For Language %d and key '%c' of pool %d single char is '%c' (0x%04X)"), |
936 aLanguage, (TInt) key, i, singleChar, singleChar ); |
996 aLanguage, key, i, singleChar, singleChar ); |
937 } |
997 } |
938 } |
998 } |
939 } |
999 } |
940 PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ===================================================") ); |
1000 PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ===================================================") ); |
941 } |
1001 } |
942 |
1002 |
943 PRINT ( _L("End CPcsKeyMap::AddKeyMappingForActiveLanguageL") ); |
1003 PRINT ( _L("End CPcsKeyMap::AddKeyMappingForLanguageL") ); |
944 } |
1004 } |
945 |
1005 |
946 // ---------------------------------------------------------------------------- |
1006 // ---------------------------------------------------------------------------- |
947 // CPcsKeyMap::GetCharactersForKey |
1007 // CPcsKeyMap::GetCharactersForKey |
948 // |
1008 // |
949 // ---------------------------------------------------------------------------- |
1009 // ---------------------------------------------------------------------------- |
950 void CPcsKeyMap::GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings, |
1010 void CPcsKeyMap::GetCharactersForKey(CPtiCoreLanguage& aPtiLanguage, |
|
1011 TPtiKeyboardType aKbType, |
951 TPtiKey aKey, |
1012 TPtiKey aKey, |
952 TPtiTextCase aTextCase, |
1013 TPtiTextCase aTextCase, |
953 TDes& aResult) |
1014 TDes& aResult) |
954 { |
1015 { |
955 switch ( iKeyboardType ) |
1016 const CPtiKeyMapData* keyMapData = aPtiLanguage.RawKeyMapData(); |
956 { |
1017 if ( keyMapData ) |
957 case EPtiKeyboardQwerty4x12: |
1018 { |
958 case EPtiKeyboardQwerty4x10: |
1019 TPtrC dataPtr = keyMapData->DataForKey( aKbType, aKey, aTextCase ); |
959 case EPtiKeyboardQwerty3x11: |
1020 // truncate results if supplied buffer is not large enough |
960 case EPtiKeyboardCustomQwerty: |
1021 aResult = dataPtr.Left( aResult.MaxLength() ); |
961 (static_cast<CPtiQwertyKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase); |
|
962 break; |
|
963 |
|
964 case EPtiKeyboard12Key: |
|
965 (static_cast<CPtiKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase); |
|
966 break; |
|
967 |
|
968 case EPtiKeyboardHalfQwerty: |
|
969 (static_cast<CPtiHalfQwertyKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase); |
|
970 break; |
|
971 |
|
972 default: |
|
973 (static_cast<CPtiKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase); |
|
974 break; |
|
975 } |
1022 } |
976 } |
1023 } |
977 |
1024 |
978 // ---------------------------------------------------------------------------- |
1025 // ---------------------------------------------------------------------------- |
979 // CPcsKeyMap::AddDataForKeyL |
1026 // CPcsKeyMap::AddDataForKeyL |
980 // |
1027 // |
981 // ---------------------------------------------------------------------------- |
1028 // ---------------------------------------------------------------------------- |
982 void CPcsKeyMap::AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings, |
1029 void CPcsKeyMap::AddCharactersToKey(CPtiCoreLanguage& aPtiLanguage, |
|
1030 TPtiKeyboardType aKbType, |
983 TPtiKey aKey, |
1031 TPtiKey aKey, |
984 TPtiTextCase aTextCase, |
1032 TPtiTextCase aTextCase, |
985 TKeyMappingData& aKeyDataList, |
1033 TKeyMappingData& aKeyDataList, |
986 RArray<TUint>& aKeyMapLang, |
1034 RArray<TUint>& aKeyMapLang, |
987 TBool& aIsSingleCharForKey, |
1035 TBool& aIsSingleCharForKey, |
988 TUint& aSingleChar) |
1036 TUint& aSingleChar) |
989 { |
1037 { |
990 PRINT ( _L("Enter CPcsKeyMap::AddCharactersToKey") ); |
1038 PRINT ( _L("Enter CPcsKeyMap::AddCharactersToKey") ); |
991 |
1039 |
992 TBuf<255> result; |
1040 TBuf<255> result; |
993 GetCharactersForKey(aPtiKeyMappings, aKey, aTextCase, result); |
1041 GetCharactersForKey(aPtiLanguage, aKbType, aKey, aTextCase, result); |
994 |
1042 |
995 PRINT3 ( _L("CPcsKeyMap::AddCharactersToKey: Get mapping chars for Key '%c' (%d) and TextCase %d"), |
1043 PRINT3 ( _L("CPcsKeyMap::AddCharactersToKey: Get mapping chars for Key '%c' (0x%02X) and TextCase %d"), |
996 (TInt) aKey, (TInt) aKey, aTextCase ); |
1044 aKey, aKey, aTextCase ); |
997 PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: Got chars: \"%S\""), &result ); |
1045 PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: Got chars: \"%S\""), &result ); |
998 |
1046 |
999 for ( TInt i = 0; i < result.Length(); i++ ) |
1047 for ( TInt i = 0; i < result.Length(); i++ ) |
1000 { |
1048 { |
1001 if ( !CharacterForKeyMappingExists(aKeyDataList, (TUint) result[i]) ) |
1049 TText character = result[i]; |
1002 { |
1050 if ( !CharacterForKeyMappingExists(aKeyDataList, character ) ) |
1003 PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: ----- Appending char to list: '%c'"), result[i] ); |
1051 { |
1004 aKeyMapLang.Append(result[i]); |
1052 PRINT2 ( _L("CPcsKeyMap::AddCharactersToKey: ----- Appending char to list: '%c' (0x%04X)"), character, character ); |
|
1053 aKeyMapLang.Append(character); |
1005 } |
1054 } |
1006 else |
1055 else |
1007 { |
1056 { |
1008 PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: ***** NOT Appending char to list: '%c'"), result[i] ); |
1057 PRINT2 ( _L("CPcsKeyMap::AddCharactersToKey: ***** NOT Appending char to list: '%c' (0x%04X)"), character, character ); |
1009 } |
1058 } |
1010 |
1059 |
1011 // No language variants handling for ITUT keyboard |
1060 // No language variants handling for ITUT keyboard |
1012 if ( EPtiKeyboard12Key != iKeyboardType ) |
1061 if ( EPtiKeyboard12Key != aKbType ) |
1013 { |
1062 { |
1014 // Support for key guessing given the char in some phone language variants |
1063 // Support for key guessing given the char in some phone language variants |
1015 if ( aIsSingleCharForKey ) |
1064 if ( aIsSingleCharForKey ) |
1016 { |
1065 { |
1017 if ( 0 == aSingleChar ) |
1066 if ( 0 == aSingleChar ) |
1018 { |
1067 { |
1019 aSingleChar = User::LowerCase(result[i]); |
1068 aSingleChar = User::LowerCase(character); |
1020 } |
1069 } |
1021 else |
1070 else |
1022 { |
1071 { |
1023 TInt newChar = User::LowerCase(result[i]); |
1072 TInt newChar = User::LowerCase(character); |
1024 if (newChar != aSingleChar) |
1073 if (newChar != aSingleChar) |
1025 { |
1074 { |
1026 aSingleChar = 0; |
1075 aSingleChar = 0; |
1027 aIsSingleCharForKey = EFalse; |
1076 aIsSingleCharForKey = EFalse; |
1028 } |
1077 } |