Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Mapping of physical keys across language variants on Symbian
Mapping of physical keys across language variants
It is a common requirement for applications to be independent of language variants. This requires mapping of physical keys to logical keys. The mapping is language dependent. Note that all FEP-aware controls, such as standard S60 UI (Avkon) editors, take care of this mapping automatically. However, if the application needs to accept text input by handling individual key events, key mapping for different language variants may cause problems, especially in S60 devices that feature a QWERTY keyboard (Nokia E61, Nokia E70).
CPtiEngine class can be used for resolving the correct mapping for each key. Required header files, PtiEngine.h and PtiKeyMappings.h, are available in the SDK from S60 3rd Edition onwards.
Important classes in this API are CPtiEngine, CPtiCoreLanguage, TPtiKey, and CPtiQwertyKeyMappings.
Below is a simplified example for getting the key mapping for a particular scan code:
// Get the current language
TLanguage lang = User::Language();
// scan code of the key you are interested in
TPtiKey key = (TPtiKey)aScanCode;
TPtiTextCase case = EPtiCaseLower;
// Instantiate the engine
iEngine = CPtiEngine::NewL(ETrue);
// Make a language object based on current language
// Get the keyboard mappings for the language
// Finally, get mapping for a particular key.
key, iResult, case);
// iResult now contains the correct mapping
// for the key