97 // CPhoneQwertyHandler::IsQwertyInput |
100 // CPhoneQwertyHandler::IsQwertyInput |
98 // ----------------------------------------------------------------------------- |
101 // ----------------------------------------------------------------------------- |
99 // |
102 // |
100 EXPORT_C TBool CPhoneQwertyHandler::IsQwertyInput() const |
103 EXPORT_C TBool CPhoneQwertyHandler::IsQwertyInput() const |
101 { |
104 { |
102 return iQwertyMode > 0 ? ETrue : EFalse; |
105 return iQwertyMode > 0 ? ETrue : EFalse; |
103 } |
106 } |
104 |
107 |
105 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
106 // CPhoneQwertyHandler::HandleLanguageSettingChange |
109 // CPhoneQwertyHandler::HandleLanguageSettingChange |
107 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
123 // |
126 // |
124 void CPhoneQwertyHandler::HandleQwertyModeChange( TInt aMode ) |
127 void CPhoneQwertyHandler::HandleQwertyModeChange( TInt aMode ) |
125 { |
128 { |
126 iQwertyMode = aMode; |
129 iQwertyMode = aMode; |
127 #ifndef RD_INTELLIGENT_TEXT_INPUT |
130 #ifndef RD_INTELLIGENT_TEXT_INPUT |
128 if ( iQwertyMode && !iNumericKeys.Count() ) |
131 if ( iQwertyMode && !iNumericKeys.Count() ) |
129 { |
132 { |
130 LoadNumericKeyBindings( iInputLanguageId, iQwertyModeMonitor->Keyboard() ); |
133 LoadNumericKeyBindings( iInputLanguageId, iQwertyModeMonitor->Keyboard() ); |
131 } |
134 } |
132 #endif |
135 #endif |
133 } |
136 } |
134 |
137 |
135 // ----------------------------------------------------------------------------- |
138 // ----------------------------------------------------------------------------- |
136 // CPhoneQwertyHandler::HandleKeyboardLayoutChange |
139 // CPhoneQwertyHandler::HandleKeyboardLayoutChange |
137 // This event comes after HandleQwertyModeChange |
140 // This event comes after HandleQwertyModeChange |
138 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
139 // |
142 // |
140 void CPhoneQwertyHandler::HandleKeyboardLayoutChange() |
143 void CPhoneQwertyHandler::HandleKeyboardLayoutChange() |
141 { |
144 { |
142 |
145 LoadNumericKeyBindings( iInputLanguageId, iQwertyModeMonitor->Keyboard() ); |
143 LoadNumericKeyBindings( iInputLanguageId, iQwertyModeMonitor->Keyboard() ); |
|
144 |
|
145 } |
146 } |
146 |
147 |
147 // ----------------------------------------------------------------------------- |
148 // ----------------------------------------------------------------------------- |
148 // CPhoneQwertyHandler::LoadNumericKeyBindings |
149 // CPhoneQwertyHandler::LoadNumericKeyBindings |
149 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
159 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
160 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
160 CleanupStack::PushL( ptiEngine ); |
161 CleanupStack::PushL( ptiEngine ); |
161 |
162 |
162 ptiEngine->GetNumericModeKeysForQwertyL( aLanguage, |
163 ptiEngine->GetNumericModeKeysForQwertyL( aLanguage, |
163 iNumericKeys, |
164 iNumericKeys, |
164 keyboard ); |
165 keyboard ); |
165 CleanupStack::PopAndDestroy( ptiEngine ); |
166 CleanupStack::PopAndDestroy( ptiEngine ); |
166 } ); // TRAP |
167 } ); // TRAP |
167 #else |
168 #else |
168 TRAPD( err, |
169 TRAPD( err, |
169 { |
170 { |
170 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
171 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
171 CleanupStack::PushL( ptiEngine ); |
172 CleanupStack::PushL( ptiEngine ); |
172 ptiEngine->GetNumericModeKeysForQwertyL( aLanguage, |
173 ptiEngine->GetNumericModeKeysForQwertyL( aLanguage, |
173 iNumericKeys ); |
174 iNumericKeys ); |
174 CleanupStack::PopAndDestroy( ptiEngine ); |
175 CleanupStack::PopAndDestroy( ptiEngine ); |
175 } ); // TRAP |
176 } ); // TRAP |
176 #endif |
177 #endif |
177 |
178 |
178 if ( err ) |
179 if ( err ) |
179 { |
180 { |
180 iNumericKeys.Reset(); |
181 iNumericKeys.Reset(); |
181 iQwertyMode = 0; // To default mode |
182 iQwertyMode = 0; // To default mode |
182 } |
183 } |
183 else |
184 else |
189 TPtiNumericKeyBinding numKeyBind = iNumericKeys[numericKeysCount]; |
190 TPtiNumericKeyBinding numKeyBind = iNumericKeys[numericKeysCount]; |
190 |
191 |
191 // This is PTI bug? Should not be in numeric keys list. |
192 // This is PTI bug? Should not be in numeric keys list. |
192 if ( numKeyBind.iKey == EPtiKeyQwertySpace ) |
193 if ( numKeyBind.iKey == EPtiKeyQwertySpace ) |
193 { |
194 { |
194 iNumericKeys.Remove( numericKeysCount ); |
195 iNumericKeys.Remove( numericKeysCount ); |
195 } |
196 } |
196 } |
197 } |
197 } |
198 } |
198 } |
199 } |
199 |
200 |
200 // ----------------------------------------------------------------------------- |
201 // ----------------------------------------------------------------------------- |
201 // CPhoneQwertyHandler::NumericKeyCode |
202 // CPhoneQwertyHandler::NumericKeyCode |
202 // ----------------------------------------------------------------------------- |
203 // ----------------------------------------------------------------------------- |
203 // |
204 // |
204 EXPORT_C TInt CPhoneQwertyHandler::NumericKeyCode( const TKeyEvent& aKeyEvent ) |
205 EXPORT_C TInt CPhoneQwertyHandler::NumericKeyCode( const TKeyEvent& aKeyEvent ) |
205 { |
206 { |
206 |
207 TInt keyCode( EKeyNull ); |
207 // Check shift state |
208 |
208 TBool shiftActive(EFalse); |
209 // It's possible that there are several numeric mode characters in same |
209 shiftActive = aKeyEvent.iModifiers & EModifierLeftShift || |
210 // QWERTY key (for example, '2' and 'w' may be on same button) and there must |
210 aKeyEvent.iModifiers & EModifierRightShift; //|| |
211 // be a way to enter each of these. |
211 |
212 // Select numeric mode key code for the key event with the following logic: |
212 TInt numericKeysCount = iNumericKeys.Count(); |
213 // 1. If key contains exactly one numeric mode character, return that |
213 |
214 // regardless of the current modifiers. |
214 while ( numericKeysCount-- ) |
215 // 2a. If key has two numeric mode characters, then actual numbers are preferred. |
215 { |
216 // Pressing such key without modifiers will produce the number character. |
216 TPtiNumericKeyBinding numKeyBind = iNumericKeys[numericKeysCount]; |
217 // 2b. Pressing key with two numeric mode characters together with any modifier |
217 |
218 // (Fn, Shift, Chr) will produce the secondary numeric mode character. |
218 TBool shiftRequired = ( numKeyBind.iCase ==EPtiCaseUpper ) || |
219 // 3. More than two numeric mode characters on one key are not supported. |
219 ( numKeyBind.iCase ==EPtiCaseChrUpper ); |
220 // Such cases shouldn't ever occur, but if they will, then this algorithm |
220 |
221 // must be changed. |
221 if ( numKeyBind.iKey == aKeyEvent.iScanCode && |
222 |
222 (shiftRequired == shiftActive ) ) |
223 // Check modifier state |
|
224 TBool modifierActive = ( aKeyEvent.iModifiers & KNumKeyModifiers ); |
|
225 |
|
226 TInt numBindIdx = iNumericKeys.Count(); |
|
227 |
|
228 while ( numBindIdx-- ) |
|
229 { |
|
230 const TPtiNumericKeyBinding& numKeyBind = iNumericKeys[numBindIdx]; |
|
231 |
|
232 if ( numKeyBind.iKey == aKeyEvent.iScanCode ) |
223 { |
233 { |
224 return numKeyBind.iChar; |
234 if ( !keyCode ) |
|
235 { |
|
236 // first match for this key |
|
237 keyCode = numKeyBind.iChar; |
|
238 } |
|
239 else |
|
240 { |
|
241 // Second numeric mode character for this key. Override |
|
242 // previous code if it was the number character but some |
|
243 // modifier is active or it was not number character and no |
|
244 // modifiers are active. |
|
245 if ( ( IsNumber(keyCode) && modifierActive ) || |
|
246 ( !IsNumber(keyCode) && !modifierActive ) ) |
|
247 { |
|
248 keyCode = numKeyBind.iChar; |
|
249 } |
|
250 } |
225 } |
251 } |
226 } |
252 } |
227 |
253 |
228 return EKeyNull; |
254 return keyCode; |
229 } |
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CPhoneQwertyHandler::ConvertToNumeric |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 EXPORT_C TBool CPhoneQwertyHandler::ConvertToNumeric( TKeyEvent& aKeyEvent ) |
|
262 { |
|
263 TBool ret( EFalse ); |
|
264 TInt numericCode = NumericKeyCode( aKeyEvent ); |
|
265 if ( numericCode ) |
|
266 { |
|
267 aKeyEvent.iCode = numericCode; |
|
268 aKeyEvent.iModifiers &= ~KNumKeyModifiers; |
|
269 ret = ETrue; |
|
270 } |
|
271 return ret; |
|
272 } |
230 |
273 |
231 // ----------------------------------------------------------------------------- |
274 // ----------------------------------------------------------------------------- |
232 // CPhoneQwertyHandler::AddQwertyModeObserverL |
275 // CPhoneQwertyHandler::AddQwertyModeObserverL |
233 // ----------------------------------------------------------------------------- |
276 // ----------------------------------------------------------------------------- |
234 // |
277 // |