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. Thanks for all your past and future contributions.

Mapping of physical keys across language variants on Symbian

From Wiki
Jump to: navigation, search

Article Metadata
Platform(s): S60 3rd Edition, S60 3rd Edition FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Created: User:Technical writer 2 (21 Sep 2006)
Last edited: hamishwillee (14 Jun 2012)


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:
    CPtiEngine *iEngine;
    CPtiCoreLanguage* iCoreLanguage;    
    CPtiKeyMappings* iPtiKeyMappings;
    CPtiQwertyKeyMappings* iQwertyKeyMappings;
    TBuf<50> iResult;
    // 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
    iCoreLanguage =
    // Get the keyboard mappings for the language
    iQwertyKeyMappings =
    // Finally, get mapping for a particular key.
        key, iResult, case);
    // iResult now contains the correct mapping
    // for the key

This page was last modified on 14 June 2012, at 06:36.
19 page views in the last 30 days.