129 const TInt16 KStrokeDownToRightValue = 0x4e36; |
129 const TInt16 KStrokeDownToRightValue = 0x4e36; |
130 const TInt16 KStrokeBendingValue = 0x4e5b; |
130 const TInt16 KStrokeBendingValue = 0x4e5b; |
131 const TInt16 KStrokeQuestionValue = 0x003f; |
131 const TInt16 KStrokeQuestionValue = 0x003f; |
132 const TInt16 KStrokeUnicode = 0x2461; |
132 const TInt16 KStrokeUnicode = 0x2461; |
133 const TInt16 KZhuyinIndicator = 0x2462; |
133 const TInt16 KZhuyinIndicator = 0x2462; |
|
134 const TText KZhuyinTone2 = 0x02CA; // qwerty key6 |
|
135 const TText KZhuyinTone3 = 0x02C7; // qwerty key3 |
|
136 const TText KZhuyinTone4 = 0x02CB; // qwerty key4 |
|
137 const TText KZhuyinTone5 = 0x02D9; // qwerty key7 |
|
138 static const TUint KShortCombine = 0xF010; |
|
139 const TInt KMaxMapping = 10; |
134 |
140 |
135 // Local method declarations. |
141 // Local method declarations. |
136 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr); |
142 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr); |
137 LOCAL_C TBool IsRegionalLang(TInt aVariantCode, TInt& aMainCode) |
143 LOCAL_C TBool IsRegionalLang(TInt aVariantCode, TInt& aMainCode) |
138 { |
144 { |
760 return KErrNoActiveLanguage; |
766 return KErrNoActiveLanguage; |
761 } |
767 } |
762 |
768 |
763 return KErrNoSuitableCore; |
769 return KErrNoSuitableCore; |
764 } |
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // Group Unicode is that kind of mapping which one visible character with more |
|
774 // than one unicode submitted. |
|
775 // |
|
776 // --------------------------------------------------------------------------- |
|
777 // |
|
778 void CPtiEngineImpl::IsGroupUnicodeExist(TPtiKey aKey, TDes& aResult, TInt aPosition) |
|
779 { |
|
780 TBuf<5> keyMappings; |
|
781 MappingDataForKey( (TPtiKey)aKey, keyMappings, Case()); |
|
782 if(keyMappings.Length() > 0 && keyMappings.Locate(KShortCombine) == aPosition ) |
|
783 { |
|
784 for(TInt i = 0; i < keyMappings.Length(); i++) |
|
785 { |
|
786 aResult.Append(keyMappings[i]); |
|
787 } |
|
788 } |
|
789 else |
|
790 { |
|
791 aResult.Append(aKey); |
|
792 } |
|
793 } |
765 |
794 |
766 |
795 |
767 // --------------------------------------------------------------------------- |
796 // --------------------------------------------------------------------------- |
768 // CPtiEngineImpl::AppendKeyPress |
797 // CPtiEngineImpl::AppendKeyPress |
769 // |
798 // |
847 { |
876 { |
848 iCaseBuffer.Append((TInt8)Case()); |
877 iCaseBuffer.Append((TInt8)Case()); |
849 } |
878 } |
850 |
879 |
851 // Forward to core object |
880 // Forward to core object |
852 Core()->AppendKeyPress(aKey); |
881 TBuf<KMaxMapping> mappings; |
|
882 IsGroupUnicodeExist(aKey, mappings, 0); |
|
883 if(mappings.Length() == 1) |
|
884 { |
|
885 Core()->AppendKeyPress(aKey); |
|
886 } |
|
887 else |
|
888 { |
|
889 for(TInt i = 0; i < mappings.Length(); i++) |
|
890 { |
|
891 TPtiTextCase retCase, oriCase; |
|
892 retCase = oriCase = Case(); |
|
893 TPtiKey key = (TPtiKey)ScanCodeForCharacter(mappings[i], retCase); |
|
894 SetCase(retCase); |
|
895 Core()->AppendKeyPress(key); |
|
896 SetCase(oriCase); |
|
897 } |
|
898 } |
853 |
899 |
854 if(KeyboardType() == EPtiKeyboardHalfQwerty && aKey == EStdKeyFullStop) |
900 if(KeyboardType() == EPtiKeyboardHalfQwerty && aKey == EStdKeyFullStop) |
855 { |
901 { |
856 // check if the key press was valid and resulted in Candidates |
902 // check if the key press was valid and resulted in Candidates |
857 if( iTextBuffer.Length() < iPunctuationsEntered ) |
903 if( iTextBuffer.Length() < iPunctuationsEntered ) |
985 } |
1031 } |
986 #endif |
1032 #endif |
987 return iTextBuffer; |
1033 return iTextBuffer; |
988 } |
1034 } |
989 |
1035 |
|
1036 TBool CPtiEngineImpl::MapAgainst(TInt aKey, TInt aMode, TInt16 aAgainst, TInt aCase) |
|
1037 { |
|
1038 SetInputMode((TPtiEngineInputMode)aMode); |
|
1039 TBuf<KMaxName> data; |
|
1040 MappingDataForKey((TPtiKey)aKey, data, (TPtiTextCase)aCase); |
|
1041 if(data.Length() > 0) |
|
1042 { |
|
1043 return (data[0] == aAgainst); |
|
1044 } |
|
1045 return EFalse; |
|
1046 } |
|
1047 TInt CPtiEngineImpl::ScanCodeForCharacter( TUint aChar, TPtiTextCase& aCase ) |
|
1048 { |
|
1049 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1050 CPtiCoreLanguage *lang = static_cast<CPtiCoreLanguage*>( CurrentLanguage() ); |
|
1051 MPtiKeyMappings* keymapping = lang->GetQwertyKeymappings(); |
|
1052 if ( keymapping ) |
|
1053 { |
|
1054 TPtiEngineInputMode oldInputMode = InputMode(); |
|
1055 SetInputMode( EPtiEngineQwertyPredictive ); |
|
1056 TInt retKey = keymapping->KeyForCharacter( (TUint16)aChar ); |
|
1057 if(MapAgainst(retKey, EPtiEngineQwertyPredictive, aChar, EPtiCaseLower)) |
|
1058 { |
|
1059 aCase = EPtiCaseLower; |
|
1060 } |
|
1061 else if(MapAgainst(retKey, EPtiEngineQwertyPredictive, aChar, EPtiCaseUpper)) |
|
1062 { |
|
1063 aCase = EPtiCaseUpper; |
|
1064 } |
|
1065 else if(MapAgainst(retKey, EPtiEngineQwertyPredictive, aChar, EPtiCaseFnLower)) |
|
1066 { |
|
1067 aCase = EPtiCaseFnLower; |
|
1068 } |
|
1069 else if(MapAgainst(retKey, EPtiEngineQwertyPredictive, aChar, EPtiCaseFnUpper)) |
|
1070 { |
|
1071 aCase = EPtiCaseFnUpper; |
|
1072 } |
|
1073 else |
|
1074 { |
|
1075 } |
|
1076 SetInputMode( oldInputMode ); |
|
1077 #if defined(__WINS__) |
|
1078 if (retKey == EPtiKeyQwertyPlus) |
|
1079 { |
|
1080 retKey = EStdKeyNkpPlus; |
|
1081 } |
|
1082 #endif |
|
1083 return retKey; |
|
1084 } |
|
1085 return EPtiKeyNone; |
|
1086 #else |
|
1087 return EPtiKeyNone; |
|
1088 #endif // RD_INTELLIGENT_TEXT_INPUT |
|
1089 } |
990 |
1090 |
991 // --------------------------------------------------------------------------- |
1091 // --------------------------------------------------------------------------- |
992 // CPtiEngineImpl::DeleteKeyPress |
1092 // CPtiEngineImpl::DeleteKeyPress |
993 // |
1093 // |
994 // --------------------------------------------------------------------------- |
1094 // --------------------------------------------------------------------------- |
1054 // --------------------------------------------------------------------------- |
1154 // --------------------------------------------------------------------------- |
1055 // |
1155 // |
1056 TPtrC CPtiEngineImpl::RedirectKeyForChineseQwerty(TPtiKey aKey, TBool& aRedirected) |
1156 TPtrC CPtiEngineImpl::RedirectKeyForChineseQwerty(TPtiKey aKey, TBool& aRedirected) |
1057 { |
1157 { |
1058 aRedirected = EFalse; |
1158 aRedirected = EFalse; |
1059 TPtiKeyboardType kbdType = KeyboardType(); |
1159 TPtiKeyboardType kbdType = KeyboardType(); |
|
1160 TBuf<KMaxName> data; |
|
1161 TInt key; |
1060 |
1162 |
1061 switch (iInputMode) |
1163 switch (iInputMode) |
1062 { |
1164 { |
1063 case EPtiEnginePinyinQwerty: |
1165 case EPtiEnginePinyinQwerty: |
1064 if (iCase == EPtiCaseLower && aKey == EPtiKeyQwertyApostrophe) |
1166 if (iCase == EPtiCaseLower && aKey == EPtiKeyQwertyApostrophe) |
1110 TPtiKeyboardType keyboardType = ActiveKeyboardType(); |
1212 TPtiKeyboardType keyboardType = ActiveKeyboardType(); |
1111 TBool IsStokeKey = EFalse; |
1213 TBool IsStokeKey = EFalse; |
1112 if(EPtiKeyboardQwerty4x10 == keyboardType || |
1214 if(EPtiKeyboardQwerty4x10 == keyboardType || |
1113 EPtiKeyboardQwerty3x11 == keyboardType ) |
1215 EPtiKeyboardQwerty3x11 == keyboardType ) |
1114 { |
1216 { |
1115 TBuf<KMaxName> lowerdata; |
|
1116 TInt StrokeUnicodePosition =0; |
1217 TInt StrokeUnicodePosition =0; |
1117 MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); |
1218 MappingDataForKey((TPtiKey)aKey, data, EPtiCaseLower); |
1118 if(lowerdata.Length()>0) |
1219 if(data.Length()>0) |
1119 { |
1220 { |
1120 for(TInt i=0;i<lowerdata.Length();i++) |
1221 for(TInt i=0;i<data.Length();i++) |
1121 { |
1222 { |
1122 if(lowerdata[i]==KStrokeUnicode) |
1223 if(data[i]==KStrokeUnicode) |
1123 { |
1224 { |
1124 StrokeUnicodePosition = i + 1; |
1225 StrokeUnicodePosition = i + 1; |
1125 break; |
1226 break; |
1126 } |
1227 } |
|
1228 if(data[0] == KZhuyinTone2 || |
|
1229 data[0] == KZhuyinTone3 || |
|
1230 data[0] == KZhuyinTone4 || |
|
1231 data[0] == KZhuyinTone5 ) |
|
1232 { |
|
1233 return TPtrC(); |
|
1234 } |
1127 } |
1235 } |
1128 } |
1236 } |
1129 if (lowerdata.Length() > StrokeUnicodePosition && iCase |
1237 if (data.Length() > StrokeUnicodePosition && iCase |
1130 == EPtiCaseLower) |
1238 == EPtiCaseLower) |
1131 { |
1239 { |
1132 if (lowerdata[StrokeUnicodePosition] |
1240 if (data[StrokeUnicodePosition] |
1133 == KStrokeHorizontalValue |
1241 == KStrokeHorizontalValue |
1134 || lowerdata[StrokeUnicodePosition] |
1242 || data[StrokeUnicodePosition] |
1135 == KStrokeVerticalValue |
1243 == KStrokeVerticalValue |
1136 || lowerdata[StrokeUnicodePosition] |
1244 || data[StrokeUnicodePosition] |
1137 == KStrokeDownToLeftValue |
1245 == KStrokeDownToLeftValue |
1138 || lowerdata[StrokeUnicodePosition] |
1246 || data[StrokeUnicodePosition] |
1139 == KStrokeDownToRightValue |
1247 == KStrokeDownToRightValue |
1140 || lowerdata[StrokeUnicodePosition] |
1248 || data[StrokeUnicodePosition] |
1141 == KStrokeBendingValue |
1249 == KStrokeBendingValue |
1142 || lowerdata[StrokeUnicodePosition] |
1250 || data[StrokeUnicodePosition] |
1143 == KStrokeQuestionValue) |
1251 == KStrokeQuestionValue) |
1144 |
1252 |
1145 { |
1253 { |
1146 return TPtrC(); |
1254 return TPtrC(); |
1147 } |
1255 } |
1148 } |
1256 } |
1149 if (iCase == EPtiCaseLower && (aKey == EPtiKeyQwertySpace |
1257 |
1150 || aKey == EPtiKeyQwertyChr || aKey |
1258 if(iCase == EPtiCaseLower && (aKey == EPtiKeyQwertySpace || aKey == EPtiKeyQwertyZ)) |
1151 == EPtiKeyQwertyApostrophe)) |
|
1152 { |
|
1153 return TPtrC(); |
|
1154 } |
|
1155 if(iCase == EPtiCaseLower && aKey == EPtiKeyQwertySpace) |
|
1156 { |
1259 { |
1157 return TPtrC(); |
1260 return TPtrC(); |
1158 } |
1261 } |
1159 } |
1262 } |
1160 else if (EPtiKeyboardHalfQwerty == keyboardType || |
1263 else if (EPtiKeyboardHalfQwerty == keyboardType || |
1217 } |
1320 } |
1218 break; |
1321 break; |
1219 case EPtiEngineNormalCangjieQwerty: |
1322 case EPtiEngineNormalCangjieQwerty: |
1220 case EPtiEngineEasyCangjieQwerty: |
1323 case EPtiEngineEasyCangjieQwerty: |
1221 case EPtiEngineAdvCangjieQwerty: |
1324 case EPtiEngineAdvCangjieQwerty: |
|
1325 MappingDataForKey((TPtiKey)aKey, data, EPtiCaseUpper); |
|
1326 key = aKey; |
|
1327 if(data.Length() > 0) |
|
1328 { |
|
1329 key = (TPtiKey)data[0]; |
|
1330 } |
1222 if ((iCase == EPtiCaseLower) && |
1331 if ((iCase == EPtiCaseLower) && |
1223 (aKey >= EPtiKeyQwertyA) && (aKey <= EPtiKeyQwertyY)) |
1332 (key >= EPtiKeyQwertyA) && (key <= EPtiKeyQwertyY)) |
1224 { |
1333 { |
1225 return TPtrC(); |
1334 return TPtrC(); |
1226 } |
1335 } |
1227 break; |
1336 break; |
1228 case EPtiEngineZhuyinQwerty: |
1337 case EPtiEngineZhuyinQwerty: |
1245 } |
1354 } |
1246 } |
1355 } |
1247 else if(EPtiKeyboardQwerty4x10 == kbdType || |
1356 else if(EPtiKeyboardQwerty4x10 == kbdType || |
1248 EPtiKeyboardQwerty3x11 == kbdType ) |
1357 EPtiKeyboardQwerty3x11 == kbdType ) |
1249 { |
1358 { |
1250 TBuf<KMaxName> lowerdata; |
1359 MappingDataForKey((TPtiKey) aKey, data, EPtiCaseLower); |
1251 TInt i; |
1360 if (data.Length() > 0) |
1252 MappingDataForKey((TPtiKey) aKey, lowerdata, EPtiCaseLower); |
|
1253 if (lowerdata.Length() > 0) |
|
1254 { |
1361 { |
1255 for ( i = 0; i < lowerdata.Length(); i++) |
1362 TInt i; |
|
1363 for ( i = 0; i < data.Length(); i++) |
1256 { |
1364 { |
1257 if (lowerdata[i] == KZhuyinIndicator) |
1365 if (data[i] == KZhuyinIndicator) |
1258 { |
1366 { |
1259 break; |
1367 break; |
1260 } |
1368 } |
1261 } |
1369 } |
1262 if(i!=lowerdata.Length() && iCase == EPtiCaseLower ) |
1370 if(i!=data.Length() && iCase == EPtiCaseLower ) |
1263 { |
1371 { |
1264 return TPtrC(); |
1372 return TPtrC(); |
1265 } |
1373 } |
1266 } |
1374 } |
1267 } |
1375 } |