|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CPtiKeyMapData class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <PtiKeyMapData.h> |
|
21 #include <languages.hrh> |
|
22 |
|
23 class TPtiLangImplBinding |
|
24 { |
|
25 public: |
|
26 TInt iUid; |
|
27 TInt iLangCode; |
|
28 }; |
|
29 |
|
30 const TInt KPtiDefaultNumMultitapKeys = 12; // Conventional phone keypad. |
|
31 const TInt KPtiDefaultNumQwertyKeys = 48; // 4x12 qwerty keyboard matrix. |
|
32 const TInt KPtiDefaultNum4x10QwertyKeys = 40; // 4x10 Mini qwerty keyboard |
|
33 const TInt KPtiDefaultNum3x11QwertyKeys = 33; // 3x11 Mini qwerty keyboard |
|
34 const TInt KPtiDefaultNumHalfQwertyKeys = 20; // 4x5 Half qwerty keyboard |
|
35 const TInt KPtiLargeNumber = 100000; |
|
36 const TUid KPtiKeymapDataInterfaceUid = { 0x10281896 }; |
|
37 |
|
38 void CleanupArray( TAny* aAny ) |
|
39 { |
|
40 RImplInfoPtrArray* implArray = |
|
41 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
42 implArray->ResetAndDestroy(); |
|
43 implArray->Close(); |
|
44 } |
|
45 |
|
46 const TInt KNumItemsPerDeadKeyDataRow = 6; |
|
47 |
|
48 // |
|
49 // CPtiKeyMapData |
|
50 // |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CPtiKeyMapData::KeyForBindingTableIndex |
|
54 // |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C TPtiKey CPtiKeyMapData::KeyForBindingTableIndex(TPtiKeyboardType aKeyboardType, |
|
58 TInt aIndex, TPtiTextCase& aCase) const |
|
59 { |
|
60 TInt numItems = 0; |
|
61 const TPtiKeyBinding* table = KeyBindingTable(aKeyboardType, numItems); |
|
62 |
|
63 if (table && aIndex < numItems) |
|
64 { |
|
65 aCase = (TPtiTextCase)table[aIndex].iCase; |
|
66 return (TPtiKey)table[aIndex].iScanCode; |
|
67 } |
|
68 |
|
69 return EPtiKeyNone; |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CPtiKeyMapData::~CPtiKeyMapData |
|
75 // |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CPtiKeyMapData::~CPtiKeyMapData() |
|
79 { |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CPtiKeyMapData::LanguageCode |
|
85 // |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C TInt CPtiKeyMapData::LanguageCode() const |
|
89 { |
|
90 return 0; |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CPtiKeyMapData::HasKeyData |
|
96 // |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C TBool CPtiKeyMapData::HasKeyData(TPtiKeyboardType aKeyboardType) const |
|
100 { |
|
101 TInt tmp = 0; |
|
102 return (KeyData(aKeyboardType, tmp) != NULL); |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CPtiKeyMapData::HasDeadKeys |
|
108 // |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C TBool CPtiKeyMapData::HasDeadKeys(TPtiKeyboardType aKeyboardType) const |
|
112 { |
|
113 TInt tmp = 0; |
|
114 return (DeadKeyDataArray(aKeyboardType, tmp) != NULL); |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CPtiKeyMapData::HasVowelSequences |
|
120 // |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C TBool CPtiKeyMapData::HasVowelSequences(TPtiKeyboardType aKeyboardType) const |
|
124 { |
|
125 TInt tmp = 0; |
|
126 return (VowelSequenceTable(aKeyboardType, tmp) != NULL); |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CPtiKeyMapData::DataForKey |
|
132 // |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C TPtrC CPtiKeyMapData::DataForKey(TPtiKeyboardType aKeyboardType, |
|
136 TPtiKey aKey, |
|
137 TPtiTextCase aCase) const |
|
138 { |
|
139 TInt index = CaseBasedIndexInBindingTable(aKeyboardType, aKey, aCase); |
|
140 |
|
141 if (index != KErrNotFound) |
|
142 { |
|
143 return DataForKey(aKeyboardType, index); |
|
144 } |
|
145 |
|
146 return TPtrC(); |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CPtiKeyMapData::DataForKey |
|
152 // |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C TPtrC CPtiKeyMapData::DataForKey(TPtiKeyboardType aKeyboardType, |
|
156 TInt aIndex) const |
|
157 { |
|
158 TInt dataSize = 0; |
|
159 TInt numBindItems = 0; |
|
160 |
|
161 const TPtiKeyBinding* bindPtr = KeyBindingTable(aKeyboardType, numBindItems); |
|
162 const TUint16* dataPtr = KeyData(aKeyboardType, dataSize); |
|
163 |
|
164 if (aIndex < numBindItems) |
|
165 { |
|
166 if (bindPtr[aIndex].iIndex < dataSize) |
|
167 { |
|
168 return TPtrC(&dataPtr[bindPtr[aIndex].iIndex], bindPtr[aIndex].iNumChars); |
|
169 } |
|
170 } |
|
171 |
|
172 return TPtrC(); |
|
173 } |
|
174 |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CPtiKeyMapData::IsDeadKey |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TBool CPtiKeyMapData::IsDeadKey(TPtiKeyboardType /*aKeyboardType*/, |
|
182 TPtiKey /*aKey*/, |
|
183 TPtiTextCase /*aCase*/) const |
|
184 { |
|
185 return EFalse; // ONKO TURHA METODI? |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CPtiKeyMapData::DeadKeyDataForKey |
|
191 // |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 EXPORT_C TPtrC CPtiKeyMapData::DeadKeyDataForKey(TPtiKeyboardType aKeyboardType, |
|
195 TPtiKey aKey, |
|
196 TPtiTextCase aCase) const |
|
197 { |
|
198 if (!HasDeadKeys(aKeyboardType)) |
|
199 { |
|
200 return TPtrC(); |
|
201 } |
|
202 |
|
203 TInt index = CaseBasedIndexInBindingTable(aKeyboardType, aKey, aCase); |
|
204 |
|
205 if (index != KErrNotFound) |
|
206 { |
|
207 TInt numRows = 0; |
|
208 const TUint16* data = DeadKeyDataArray(aKeyboardType, numRows); |
|
209 |
|
210 for (TInt i = 0; i < numRows; i++) |
|
211 { |
|
212 if (data[0] == index) |
|
213 { |
|
214 data++; |
|
215 return TPtrC(data, KNumItemsPerDeadKeyDataRow - 1); |
|
216 } |
|
217 data += KNumItemsPerDeadKeyDataRow; |
|
218 } |
|
219 } |
|
220 |
|
221 return TPtrC(); |
|
222 } |
|
223 |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // CPtiKeyMapData::VowelSequenceTable |
|
227 // |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 EXPORT_C const TVowelSequence* CPtiKeyMapData::VowelSequenceTable(TPtiKeyboardType /*aKeyboardType*/, |
|
231 TInt& aNumEntries) const |
|
232 { |
|
233 aNumEntries = 0; |
|
234 return NULL; |
|
235 } |
|
236 |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CPtiKeyMapData::NumberOfKeys |
|
240 // |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 EXPORT_C TInt CPtiKeyMapData::NumberOfKeys(TPtiKeyboardType aKeyboardType) const |
|
244 { |
|
245 switch (aKeyboardType) |
|
246 { |
|
247 case EPtiKeyboard12Key: |
|
248 return KPtiDefaultNumMultitapKeys; |
|
249 case EPtiKeyboardQwerty4x12: |
|
250 return KPtiDefaultNumQwertyKeys; |
|
251 case EPtiKeyboardQwerty4x10: |
|
252 return KPtiDefaultNum4x10QwertyKeys; |
|
253 case EPtiKeyboardQwerty3x11: |
|
254 return KPtiDefaultNum3x11QwertyKeys; |
|
255 case EPtiKeyboardHalfQwerty: |
|
256 return KPtiDefaultNumHalfQwertyKeys; |
|
257 default: |
|
258 break; |
|
259 } |
|
260 |
|
261 return 0; |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CPtiKeyMapData::KeyData |
|
267 // |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 EXPORT_C const TUint16* CPtiKeyMapData::KeyData(TPtiKeyboardType /*aKeyboardType*/, |
|
271 TInt& aDataSize) const |
|
272 { |
|
273 aDataSize = 0; |
|
274 return NULL; |
|
275 } |
|
276 |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CPtiKeyMapData::KeyBindingTable |
|
280 // |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 EXPORT_C const TPtiKeyBinding* CPtiKeyMapData::KeyBindingTable(TPtiKeyboardType /*aKeyboardType*/, |
|
284 TInt& aNumItems) const |
|
285 { |
|
286 aNumItems = 0; |
|
287 return NULL; |
|
288 } |
|
289 |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // CPtiKeyMapData::GetNumericModeKeysL |
|
293 // |
|
294 // --------------------------------------------------------------------------- |
|
295 // |
|
296 EXPORT_C void CPtiKeyMapData::GetNumericModeKeysL(TPtiKeyboardType aKeyboardType, |
|
297 RArray<TPtiNumericKeyBinding>& aResult) const |
|
298 { |
|
299 TInt numItems = 0; |
|
300 const TPtiNumericKeyBinding* data = NumericModeKeysTable(aKeyboardType, numItems); |
|
301 |
|
302 aResult.Reset(); |
|
303 |
|
304 if (data) |
|
305 { |
|
306 for (TInt i = 0; i < numItems; i++) |
|
307 { |
|
308 User::LeaveIfError(aResult.Append(data[i])); |
|
309 } |
|
310 } |
|
311 } |
|
312 |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CPtiKeyMapData::IsNumberModeKey |
|
316 // |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C TBool CPtiKeyMapData::IsNumberModeKey(TPtiKeyboardType aKeyboardType, |
|
320 TPtiNumericKeyBinding& aWhichKey) const |
|
321 { |
|
322 TInt numItems = 0; |
|
323 aWhichKey.iChar = 0; |
|
324 |
|
325 const TPtiNumericKeyBinding* data = NumericModeKeysTable(aKeyboardType, numItems); |
|
326 |
|
327 if (data) |
|
328 { |
|
329 for (TInt i = 0; i < numItems; i++) |
|
330 { |
|
331 if (aWhichKey.iKey == data[i].iKey && |
|
332 aWhichKey.iCase == data[i].iCase) |
|
333 { |
|
334 aWhichKey.iChar = data[i].iChar; |
|
335 return ETrue; |
|
336 } |
|
337 } |
|
338 } |
|
339 |
|
340 return EFalse; |
|
341 } |
|
342 |
|
343 |
|
344 // --------------------------------------------------------------------------- |
|
345 // CPtiKeyMapData::NumericModeKeysTable |
|
346 // |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 EXPORT_C const TPtiNumericKeyBinding* CPtiKeyMapData::NumericModeKeysTable(TPtiKeyboardType /*aKeyboardType*/, |
|
350 TInt& aNumEntries) const |
|
351 { |
|
352 aNumEntries = 0; |
|
353 return NULL; |
|
354 } |
|
355 |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CPtiKeyMapData::SuitableForLatinOnlyMode |
|
359 // |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 EXPORT_C TBool CPtiKeyMapData::SuitableForLatinOnlyMode() const |
|
363 { |
|
364 return ETrue; |
|
365 } |
|
366 |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // CPtiKeyMapData::DeadKeyDataArray |
|
370 // |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 EXPORT_C const TUint16* CPtiKeyMapData::DeadKeyDataArray(TPtiKeyboardType /*aKeyboardType*/, |
|
374 TInt& aNumRowsInArray) const |
|
375 { |
|
376 aNumRowsInArray = 0; |
|
377 return NULL; |
|
378 } |
|
379 |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CPtiKeyMapData::HasFnKeyBindings |
|
383 // |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 EXPORT_C TBool CPtiKeyMapData::HasFnKeyBindings(TPtiKeyboardType aKeyboardType) const |
|
387 { |
|
388 TInt numItems = 0; |
|
389 KeyBindingTable(aKeyboardType, numItems); |
|
390 |
|
391 if (numItems > 0) |
|
392 { |
|
393 if (numItems > NumberOfKeys(aKeyboardType) * 2) |
|
394 { |
|
395 // If there are data items beyond upper and lower case bindings, |
|
396 // they must be fn-key data. |
|
397 return ETrue; |
|
398 } |
|
399 } |
|
400 |
|
401 return EFalse; |
|
402 } |
|
403 |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CPtiKeyMapData::CaseBasedIndexInBindingTable |
|
407 // |
|
408 // --------------------------------------------------------------------------- |
|
409 // |
|
410 EXPORT_C TInt CPtiKeyMapData::CaseBasedIndexInBindingTable(TPtiKeyboardType aKeyboardType, |
|
411 TPtiKey aKey, |
|
412 TPtiTextCase aCase) const |
|
413 { |
|
414 TInt numItems = 0; |
|
415 const TPtiKeyBinding* table = KeyBindingTable(aKeyboardType, numItems); |
|
416 |
|
417 if (table) |
|
418 { |
|
419 for (TInt i = 0; i < numItems; i++) |
|
420 { |
|
421 if (table[i].iScanCode == aKey && table[i].iCase == aCase) |
|
422 { |
|
423 return i; |
|
424 } |
|
425 } |
|
426 } |
|
427 |
|
428 return KPtiLargeNumber; |
|
429 } |
|
430 |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // Reserved ordinals. |
|
434 // |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C void CPtiKeyMapData::Reserved_1() |
|
438 { |
|
439 } |
|
440 |
|
441 EXPORT_C void CPtiKeyMapData::Reserved_2() |
|
442 { |
|
443 } |
|
444 |
|
445 EXPORT_C void CPtiKeyMapData::Reserved_3() |
|
446 { |
|
447 } |
|
448 |
|
449 EXPORT_C void CPtiKeyMapData::Reserved_4() |
|
450 { |
|
451 } |
|
452 |
|
453 // |
|
454 // CPtiKeyMapDataFactory |
|
455 // |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // CPtiKeyMapDataFactory::CreateImplementationL |
|
459 // |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 EXPORT_C CPtiKeyMapDataFactory* CPtiKeyMapDataFactory::CreateImplementationL(const TUid aImplUid) |
|
463 { |
|
464 TUid dtorIDKey; |
|
465 CPtiKeyMapDataFactory* iface = (CPtiKeyMapDataFactory*)REComSession::CreateImplementationL(aImplUid, dtorIDKey); |
|
466 if (iface) |
|
467 { |
|
468 iface->SetDestructorKeyId(dtorIDKey.iUid); |
|
469 iface->SetImplementationUid(aImplUid. iUid); |
|
470 } |
|
471 return iface; |
|
472 } |
|
473 |
|
474 |
|
475 // --------------------------------------------------------------------------- |
|
476 // CPtiKeyMapDataFactory::ListImplementationsL |
|
477 // |
|
478 // --------------------------------------------------------------------------- |
|
479 // |
|
480 EXPORT_C void CPtiKeyMapDataFactory::ListImplementationsL(RArray<TInt>& aResult) |
|
481 { |
|
482 RImplInfoPtrArray infoArray; |
|
483 TInt i; |
|
484 |
|
485 aResult.Reset(); |
|
486 CleanupStack::PushL( TCleanupItem( CleanupArray, &infoArray ) ); |
|
487 REComSession::ListImplementationsL(KPtiKeymapDataInterfaceUid, infoArray); |
|
488 |
|
489 for (i = 0; i < infoArray.Count(); i++) |
|
490 { |
|
491 aResult.AppendL(infoArray[i]->ImplementationUid().iUid); |
|
492 } |
|
493 |
|
494 CleanupStack::PopAndDestroy(); // infoArray |
|
495 } |
|
496 |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // CPtiKeyMapDataFactory::~CPtiKeyMapDataFactory |
|
500 // |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 EXPORT_C CPtiKeyMapDataFactory::~CPtiKeyMapDataFactory() |
|
504 { |
|
505 REComSession::DestroyedImplementation(TUid::Uid(iDTorId)); |
|
506 } |
|
507 |
|
508 |
|
509 // --------------------------------------------------------------------------- |
|
510 // Reserved ordinals. |
|
511 // |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 EXPORT_C void CPtiKeyMapDataFactory::Reserved_1() |
|
515 { |
|
516 } |
|
517 |
|
518 |
|
519 EXPORT_C void CPtiKeyMapDataFactory::Reserved_2() |
|
520 { |
|
521 } |
|
522 |
|
523 // End of file |
|
524 |
|
525 |