×
Namespaces

Variants
Actions

Mapping of physical keys across language variants on Symbian

From Nokia Developer Wiki
Jump to: navigation, search



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

Overview

Mapping of physical keys across language variants

Description

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).

Solution

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 =
        static_cast<CPtiCoreLanguage*>(
            iEngine->GetLanguage(lang));
    // Get the keyboard mappings for the language
    iQwertyKeyMappings =
        static_cast<CPtiQwertyKeyMappings*>(
            iCoreLanguage->GetQwertyKeymappings());
    // Finally, get mapping for a particular key.
    iQwertyKeyMappings->GetDataForKey(
        key, iResult, case);
    // iResult now contains the correct mapping
    // for the key

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

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×