96 iLanguageNotSupported.Append(ELangPrcChinese); |
96 iLanguageNotSupported.Append(ELangPrcChinese); |
97 iLanguageNotSupported.Append(ELangHongKongChinese); |
97 iLanguageNotSupported.Append(ELangHongKongChinese); |
98 iLanguageNotSupported.Append(ELangTaiwanChinese); |
98 iLanguageNotSupported.Append(ELangTaiwanChinese); |
99 iLanguageNotSupported.Append(ELangKorean); |
99 iLanguageNotSupported.Append(ELangKorean); |
100 |
100 |
101 SetupKeyboardTypesL(); |
101 TPtiKeyboardType physicalItutKbType; |
102 |
102 TPtiKeyboardType physicalQwertyKbType; |
103 // Create structure for holding characters<-->key mappings |
103 GetPhysicalKeyboardTypesL( physicalItutKbType, physicalQwertyKbType ); |
104 CreateKeyMappingL( EPredictiveItuT ); |
104 |
105 CreateKeyMappingL( EPredictiveQwerty ); |
105 iItutKeyboardType = EPtiKeyboard12Key; // We want to support Virtual Itu-T in most devices |
|
106 CreateKeyMappingL( EPredictiveItuT ); // Create structure for holding characters<-->key mappings |
|
107 if (iItutKeys.Count() == 0) |
|
108 { |
|
109 iItutKeyboardType = EPtiKeyboardNone; |
|
110 } |
|
111 |
|
112 iQwertyKeyboardType = physicalQwertyKbType; |
|
113 if (physicalQwertyKbType != EPtiKeyboardNone) |
|
114 { |
|
115 CreateKeyMappingL( EPredictiveQwerty ); // Create structure for holding characters<-->key mappings |
|
116 if (iQwertyKeys.Count() == 0) |
|
117 { |
|
118 iQwertyKeyboardType = EPtiKeyboardNone; |
|
119 } |
|
120 } |
|
121 |
|
122 // Set the Default Predictive keyboard mode. If Qwerty keyboard exists, it is always physical. |
|
123 iPredictiveDefaultKeyboardMode = |
|
124 (IsItutPredictiveAvailable() && physicalItutKbType != EPtiKeyboardNone) || !IsQwertyPredictiveAvailable() ? |
|
125 EPredictiveItuT : EPredictiveQwerty; |
|
126 |
|
127 PRINT1 ( _L("CPcsKeyMap::ConstructL: ITU-T Keyboard chosen for Predictive Search = %d"), iItutKeyboardType ); |
|
128 PRINT1 ( _L("CPcsKeyMap::ConstructL: QWERTY Keyboard chosen for Predictive Search = %d"), iQwertyKeyboardType ); |
106 |
129 |
107 // Sets attribute for holding info if "0" and " " are on the same key |
130 // Sets attribute for holding info if "0" and " " are on the same key |
108 // Needed for decision if the "0" should be considered as a possible separator |
131 // Needed for decision if the "0" should be considered as a possible separator |
109 SetSpaceAndZeroOnSameKey(); |
132 SetSpaceAndZeroOnSameKey(); |
110 |
133 |
270 void CPcsKeyMap::CheckPotentialErrorConditions(const RArray<TInt>& aPoolIndexArr, |
311 void CPcsKeyMap::CheckPotentialErrorConditions(const RArray<TInt>& aPoolIndexArr, |
271 const TChar& aChar, |
312 const TChar& aChar, |
272 const RArray<TPtiKey>& aPtiKeys, |
313 const RArray<TPtiKey>& aPtiKeys, |
273 const RPointerArray<TKeyMappingData>& aKeyMappings) const |
314 const RPointerArray<TKeyMappingData>& aKeyMappings) const |
274 { |
315 { |
275 PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: ===================================================") ); |
316 PRINT ( _L("CPcsKeyMap::CheckPotentialErrorConditions: ===================================================") ); |
276 PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Checking potential error conditions") ); |
317 PRINT ( _L("CPcsKeyMap::CheckPotentialErrorConditions: Checking potential error conditions") ); |
277 PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: ---------------------------------------------------") ); |
318 PRINT ( _L("CPcsKeyMap::CheckPotentialErrorConditions: ---------------------------------------------------") ); |
278 |
319 |
279 _LIT(KTextCharArr0, "is single char"); |
320 _LIT(KTextCharArr0, "is single char"); |
280 _LIT(KTextCharArr1, "has \"UI\" priority"); |
321 _LIT(KTextCharArr1, "has \"UI\" priority"); |
281 _LIT(KTextCharArr2, "has \"English\" priority"); |
322 _LIT(KTextCharArr2, "has \"English\" priority"); |
282 _LIT(KTextCharArr3, "has \"Others\" priority"); |
323 _LIT(KTextCharArr3, "has \"Others\" priority"); |
290 countArr[j] = 0; |
331 countArr[j] = 0; |
291 for ( TInt i = 0; i < aPoolIndexArr.Count(); i++ ) |
332 for ( TInt i = 0; i < aPoolIndexArr.Count(); i++ ) |
292 { |
333 { |
293 if ( KErrNotFound != aKeyMappings[aPoolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar) ) |
334 if ( KErrNotFound != aKeyMappings[aPoolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar) ) |
294 { |
335 { |
295 PRINT5 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (0x%04X) %S for pool %d with key '%c'"), |
336 PRINT5 ( _L("CPcsKeyMap::CheckPotentialErrorConditions: Char '%c' (0x%04X) %S for pool %d with key '%c'"), |
296 (TUint) aChar, (TUint) aChar, &charArrStr[j], aPoolIndexArr[i], aPtiKeys[aPoolIndexArr[i]] ); |
337 (TUint) aChar, (TUint) aChar, &charArrStr[j], aPoolIndexArr[i], aPtiKeys[aPoolIndexArr[i]] ); |
297 countArr[j]++; |
338 countArr[j]++; |
298 } |
339 } |
299 } |
340 } |
300 } |
341 } |
301 |
342 |
302 PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: ===================================================") ); |
343 PRINT ( _L("CPcsKeyMap::CheckPotentialErrorConditions: ===================================================") ); |
303 |
344 |
304 #ifdef __WINS__ |
345 #ifdef __WINS__ |
305 /* |
346 /* |
306 The reference 4x10 QWERTY mappings of 9.2 emulator have each number mapped to two keys. |
347 The reference 4x10 QWERTY mappings of 9.2 emulator have each number mapped to two keys. |
307 That kind of mappings can't be handled correctly, so panic in debug would basically be correct. |
348 That kind of mappings can't be handled correctly, so panic in debug would basically be correct. |
496 |
537 |
497 // From logical point of view, the Pool ID is an index of the key in |
538 // From logical point of view, the Pool ID is an index of the key in |
498 // an array which is formed by concatenating QWERTY keys array in the end |
539 // an array which is formed by concatenating QWERTY keys array in the end |
499 // of the ITU-T keys array. |
540 // of the ITU-T keys array. |
500 TInt poolId = KErrNotFound; |
541 TInt poolId = KErrNotFound; |
501 if ( aKbMode == EPredictiveItuT && iItutKeys.Count() ) |
542 if ( aKbMode == EPredictiveItuT && IsItutPredictiveAvailable() ) |
502 { |
543 { |
503 poolId = iItutKeys.Find(aKey); |
544 poolId = iItutKeys.Find(aKey); |
504 // IF the key is not found, then it should go to the special pool, |
545 // 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 |
546 // which is the pool of the dummy key in the ITU-T keys array |
506 if (KErrNotFound == poolId) |
547 if (KErrNotFound == poolId) |
507 { |
548 { |
508 poolId = iItutKeys.Count() - 1; |
549 poolId = iItutKeys.Count() - 1; |
509 } |
550 } |
510 } |
551 } |
511 else if ( aKbMode == EPredictiveQwerty && iQwertyKeys.Count() ) |
552 else if ( aKbMode == EPredictiveQwerty && IsQwertyPredictiveAvailable() ) |
512 { |
553 { |
513 poolId = iQwertyKeys.Find(aKey); |
554 poolId = iQwertyKeys.Find(aKey); |
514 // IF the key is not found, then it should go to the special pool, |
555 // 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 |
556 // which is the pool of the dummy key in the QWERTY keys array |
516 if (KErrNotFound == poolId) |
557 if (KErrNotFound == poolId) |
536 { |
577 { |
537 // Pools are formed according the predictive keyboard mapping(s). |
578 // Pools are formed according the predictive keyboard mapping(s). |
538 // When selecting pool for non-predictive mode, we use the pool of the |
579 // When selecting pool for non-predictive mode, we use the pool of the |
539 // default keyboard. The non-predictive matches should be a sub set of the |
580 // default keyboard. The non-predictive matches should be a sub set of the |
540 // predictive matches of the default keyboard, although strictly speaking, |
581 // predictive matches of the default keyboard, although strictly speaking, |
541 // there' no guarantee for this. |
582 // there is no guarantee for this. |
542 aKbMode = ResolveKeyboardMode( aKbMode, ENonPredictive ); |
583 aKbMode = ResolveKeyboardMode( aKbMode, ENonPredictive ); |
543 |
584 |
544 TPtiKey key = KeyForCharacterMultiMatch( aChar, aKbMode ); |
585 TPtiKey key = KeyForCharacterMultiMatch( aChar, aKbMode ); |
545 |
586 |
546 TInt poolId = (key == EPtiKeyNone) ? KErrNotFound : PoolIdForKey(key, aKbMode); |
587 TInt poolId = PoolIdForKey(key, aKbMode); |
547 |
588 |
548 return poolId; |
589 return poolId; |
549 } |
590 } |
550 |
591 |
551 // ---------------------------------------------------------------------------- |
592 // ---------------------------------------------------------------------------- |
610 |
647 |
611 return result; |
648 return result; |
612 } |
649 } |
613 |
650 |
614 // ---------------------------------------------------------------------------- |
651 // ---------------------------------------------------------------------------- |
615 // CPcsKeyMap::SetupKeyboardTypesL |
652 // CPcsKeyMap::GetPhysicalKeyboardTypesL |
616 // Initialise the keyboard type variables |
653 // Initialise the keyboard type variables |
617 // ---------------------------------------------------------------------------- |
654 // ---------------------------------------------------------------------------- |
618 void CPcsKeyMap::SetupKeyboardTypesL() |
655 void CPcsKeyMap::GetPhysicalKeyboardTypesL( TPtiKeyboardType& aItutKbType, |
|
656 TPtiKeyboardType& aQwertyKbType ) |
619 { |
657 { |
620 TInt physicalKeyboard = 0; |
658 TInt physicalKeyboard = 0; |
621 CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep ); |
659 CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep ); |
622 aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard ); |
660 aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard ); |
623 delete aknFepRepository; |
661 delete aknFepRepository; |
624 |
662 |
625 PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: Physical keyboard support flag = 0x%02X"), physicalKeyboard ); |
663 PRINT1 ( _L("CPcsKeyMap::GetPhysicalKeyboardTypesL: Physical keyboard support flag = 0x%02X"), physicalKeyboard ); |
626 |
664 |
627 // Constants follow the definition of KAknFepPhysicalKeyboards |
665 // Constants follow the definition of KAknFepPhysicalKeyboards |
628 const TInt KPtiKeyboard12Key = 0x01; |
666 const TInt KPtiKeyboard12Key = 0x01; |
629 const TInt KPtiKeyboardQwerty4x12 = 0x02; |
667 const TInt KPtiKeyboardQwerty4x12 = 0x02; |
630 const TInt KPtiKeyboardQwerty4x10 = 0x04; |
668 const TInt KPtiKeyboardQwerty4x10 = 0x04; |
631 const TInt KPtiKeyboardQwerty3x11 = 0x08; |
669 const TInt KPtiKeyboardQwerty3x11 = 0x08; |
632 const TInt KPtiKeyboardHalfQwerty = 0x10; |
670 const TInt KPtiKeyboardHalfQwerty = 0x10; |
633 const TInt KPtiKeyboardCustomQwerty = 0x20; |
671 const TInt KPtiKeyboardCustomQwerty = 0x20; |
634 |
672 |
635 // Setup ITU-T mode first. |
673 // Get ITU-T mode first. |
636 // Use always 12-key mode since all the supported devices should have at least |
674 // Use always 12-key mode since all the supported devices should have at least |
637 // virtual ITU-T available. |
675 // virtual ITU-T available. |
638 iItutKeyboardType = EPtiKeyboard12Key; |
676 // It will be set to EPtiKeyboardNone if getting the key list will fail. |
639 // TODO: ITU-T type could be set to "none" if device does not have either |
677 if ( physicalKeyboard & KPtiKeyboard12Key ) |
640 // virtual keypad or hardware ITU-T available. This could be decided according |
678 { |
641 // some cenrep value, feature flag, device model, or platform version. |
679 aItutKbType = EPtiKeyboard12Key; |
642 |
680 } |
643 // Then setup QWERTY mode. On real-life devices there should never |
681 else |
|
682 { |
|
683 aItutKbType = EPtiKeyboardNone; |
|
684 } |
|
685 |
|
686 // Then get QWERTY mode. On real-life devices there should never |
644 // be more than one QWERTY keyboard available but on emulator there can be several. |
687 // be more than one QWERTY keyboard available but on emulator there can be several. |
645 // Use the first one found in the following precedence |
688 // Use the first one found in the following precedence |
|
689 // It will be set to EPtiKeyboardNone if getting the key list will fail. |
646 if ( physicalKeyboard & KPtiKeyboardQwerty3x11 ) |
690 if ( physicalKeyboard & KPtiKeyboardQwerty3x11 ) |
647 { |
691 { |
648 iQwertyKeyboardType = EPtiKeyboardQwerty3x11; |
692 aQwertyKbType = EPtiKeyboardQwerty3x11; |
649 } |
693 } |
650 else if ( physicalKeyboard & KPtiKeyboardQwerty4x10 ) |
694 else if ( physicalKeyboard & KPtiKeyboardQwerty4x10 ) |
651 { |
695 { |
652 iQwertyKeyboardType = EPtiKeyboardQwerty4x10; |
696 aQwertyKbType = EPtiKeyboardQwerty4x10; |
653 } |
697 } |
654 else if ( physicalKeyboard & KPtiKeyboardQwerty4x12 ) |
698 else if ( physicalKeyboard & KPtiKeyboardQwerty4x12 ) |
655 { |
699 { |
656 iQwertyKeyboardType = EPtiKeyboardQwerty4x12; |
700 aQwertyKbType = EPtiKeyboardQwerty4x12; |
657 } |
701 } |
658 else if ( physicalKeyboard & KPtiKeyboardCustomQwerty ) |
702 else if ( physicalKeyboard & KPtiKeyboardCustomQwerty ) |
659 { |
703 { |
660 iQwertyKeyboardType = EPtiKeyboardCustomQwerty; |
704 aQwertyKbType = EPtiKeyboardCustomQwerty; |
661 } |
705 } |
662 else if ( physicalKeyboard & KPtiKeyboardHalfQwerty ) |
706 else if ( physicalKeyboard & KPtiKeyboardHalfQwerty ) |
663 { |
707 { |
664 iQwertyKeyboardType = EPtiKeyboardHalfQwerty; |
708 aQwertyKbType = EPtiKeyboardHalfQwerty; |
665 } |
709 } |
666 else |
710 else |
667 { |
711 { |
668 iQwertyKeyboardType = EPtiKeyboardNone; |
712 aQwertyKbType = EPtiKeyboardNone; |
669 } |
713 } |
670 |
714 |
671 // Set the Default Predictive keyboard mode |
715 PRINT1 ( _L("CPcsKeyMap::GetPhysicalKeyboardTypesL: Physical ITU-T Keyboard = %d"), aItutKbType ); |
672 iPredictiveDefaultKeyboardMode = ( |
716 PRINT1 ( _L("CPcsKeyMap::GetPhysicalKeyboardTypesL: Physical QWERTY Keyboard = %d"), aQwertyKbType ); |
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 ); |
|
678 } |
717 } |
679 |
718 |
680 // ---------------------------------------------------------------------------- |
719 // ---------------------------------------------------------------------------- |
681 // CPcsKeyMap::AppendEntryWithFakeKeyToKeyList |
720 // CPcsKeyMap::AppendEntryWithFakeKeyToKeyList |
682 // Add pool with unused id for for key |
721 // Add pool with unused id for for key |
1114 TPtiKeyboardType& aKbType ) const |
1153 TPtiKeyboardType& aKbType ) const |
1115 { |
1154 { |
1116 PRINT1 ( _L("CPcsKeyMap::GetPredictiveKeyboardData: aKbMode=%d "), aKbMode ); |
1155 PRINT1 ( _L("CPcsKeyMap::GetPredictiveKeyboardData: aKbMode=%d "), aKbMode ); |
1117 |
1156 |
1118 // EPredictiveItuT or EPredictiveQwerty mode to ENonPredictive mode if keyboard is not mapped |
1157 // EPredictiveItuT or EPredictiveQwerty mode to ENonPredictive mode if keyboard is not mapped |
1119 if ( aKbMode == EPredictiveItuT && iItutKeyboardType == EPtiKeyboardNone ) |
1158 if ( aKbMode == EPredictiveItuT && !IsItutPredictiveAvailable() ) |
1120 { |
1159 { |
1121 aKbMode = ENonPredictive; |
1160 aKbMode = ENonPredictive; |
1122 } |
1161 } |
1123 if ( aKbMode == EPredictiveQwerty && iQwertyKeyboardType == EPtiKeyboardNone ) |
1162 if ( aKbMode == EPredictiveQwerty && !IsQwertyPredictiveAvailable() ) |
1124 { |
1163 { |
1125 aKbMode = ENonPredictive; |
1164 aKbMode = ENonPredictive; |
1126 } |
1165 } |
1127 |
1166 |
1128 // Get Predictive Keyboard Data |
1167 // Get Predictive Keyboard Data |
1129 switch (aKbMode) |
1168 switch (aKbMode) |
1130 { |
1169 { |
1131 case EPredictiveItuT: |
1170 case EPredictiveItuT: |
1132 { |
|
1133 aPtiKeys = &iItutKeys; |
1171 aPtiKeys = &iItutKeys; |
1134 aKeyMappings = &iItutKeyMaps; |
1172 aKeyMappings = &iItutKeyMaps; |
1135 aKbType = iItutKeyboardType; |
1173 aKbType = iItutKeyboardType; |
1136 break; |
1174 break; |
1137 } |
|
1138 |
1175 |
1139 case EPredictiveQwerty: |
1176 case EPredictiveQwerty: |
1140 { |
|
1141 aPtiKeys = &iQwertyKeys; |
1177 aPtiKeys = &iQwertyKeys; |
1142 aKeyMappings = &iQwertyKeyMaps; |
1178 aKeyMappings = &iQwertyKeyMaps; |
1143 aKbType = iQwertyKeyboardType; |
1179 aKbType = iQwertyKeyboardType; |
1144 break; |
1180 break; |
1145 } |
|
1146 |
1181 |
1147 case ENonPredictive: |
1182 case ENonPredictive: |
1148 { |
|
1149 aPtiKeys = NULL; |
1183 aPtiKeys = NULL; |
1150 aKeyMappings = NULL; |
1184 aKeyMappings = NULL; |
1151 aKbType = EPtiKeyboardNone; |
1185 aKbType = EPtiKeyboardNone; |
1152 break; |
1186 break; |
1153 } |
|
1154 |
1187 |
1155 // EPredictiveDefaultKeyboard must have been resolved previously |
1188 // EPredictiveDefaultKeyboard must have been resolved previously |
1156 // to EPredictiveItuT or EPredictiveQwerty mode |
1189 // to EPredictiveItuT or EPredictiveQwerty mode |
1157 case EPredictiveDefaultKeyboard: |
1190 case EPredictiveDefaultKeyboard: |
1158 default: |
1191 default: |
1159 { |
|
1160 aPtiKeys = NULL; |
1192 aPtiKeys = NULL; |
1161 aKeyMappings = NULL; |
1193 aKeyMappings = NULL; |
1162 aKbType = EPtiKeyboardNone; |
1194 aKbType = EPtiKeyboardNone; |
1163 __ASSERT_DEBUG( EFalse, Panic( EPanic_InvalidKeyboardType ) ); |
1195 __ASSERT_DEBUG( EFalse, Panic( EPanic_InvalidKeyboardType ) ); |
1164 break; |
1196 break; |
1165 } |
|
1166 } |
1197 } |
1167 } |
1198 } |
1168 |
1199 |
1169 // End of file |
1200 // End of file |