javauis/lcdui_akn/lcdui/inc/CMIDKeyDecoder.h
branchRCL_3
changeset 14 04becd199f91
child 24 6c158198356e
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDKEYDECODER_H
       
    20 #define CMIDKEYDECODER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <lcdui.h>
       
    24 
       
    25 // CMIDQwertyWatch* iQwertyWatch
       
    26 // monitoring status of qwerty input
       
    27 #include "CMIDQwertyWatch.h"
       
    28 
       
    29 // FORWARD DECLARATION
       
    30 class CMIDDisplayable;
       
    31 class CMIDMenuHandler;
       
    32 class CMIDUIManager;
       
    33 class CMIDRemConObserver;
       
    34 class CRepository;
       
    35 
       
    36 /** A private class containing key information,
       
    37 such as name, key code and so forth. */
       
    38 class TMIDKey
       
    39 {
       
    40 public:
       
    41     TMIDKey(TInt aScanCode, TInt aMIDPCode, TInt aNameResId)
       
    42             : iScanCode(aScanCode), iMIDPCode(aMIDPCode), iNameResId(aNameResId)
       
    43     { }
       
    44 
       
    45 public:
       
    46     /** The symbian physical scan code*/
       
    47     TInt iScanCode;
       
    48 
       
    49     /** They key code to be passed MIDP side */
       
    50     TInt iMIDPCode;
       
    51 
       
    52     /** The resource Id to load the key name from resource file */
       
    53     TInt iNameResId;
       
    54 };
       
    55 
       
    56 /** A private class containing game action information,
       
    57 can have one or more keys associated to it -
       
    58 it must at least have one. */
       
    59 class TMIDGameAction
       
    60 {
       
    61 public:
       
    62     TMIDGameAction(TInt aActionCode) : iActionCode(aActionCode)
       
    63     { }
       
    64 
       
    65     /** The action enumeration code as defined in MMIDUtils */
       
    66     TInt iActionCode;
       
    67 
       
    68     /** The MIDP keys codes associated with this game action */
       
    69     RArray<TInt> iCodes;
       
    70 };
       
    71 
       
    72 /** Decodes scan codes and symbian
       
    73 key codes into MIDP key codes and game actions.
       
    74 It also converts key codes into key names.
       
    75 
       
    76 This class is created and deleted by the menu hander,
       
    77 which stores an instance of TlsStruct in the TLS.
       
    78 
       
    79 @see CMIDMenuHandler, TlsStruct
       
    80 */
       
    81 NONSHARABLE_CLASS(CMIDKeyDecoder): public CBase, public MMIDQwertyObserver
       
    82 {
       
    83 public:
       
    84     //This is the preferred way to get hold of an instance of this object (singleton)
       
    85     static CMIDKeyDecoder* Instance();
       
    86 
       
    87 public:
       
    88     //These are meant to be called only once by the menu handler at startup
       
    89     static CMIDKeyDecoder* NewL(MMIDEnv& aEnv);
       
    90     ~CMIDKeyDecoder();
       
    91 
       
    92 public:
       
    93     //This is the public API
       
    94     TInt GetKeyCode(TInt aGameAction);
       
    95     void GetKeyName(TDes& aText,TInt aKeyCode);
       
    96     TInt GameAction(TInt aKeyCode);
       
    97 
       
    98     TBool IsJavaKey(TInt aScanCode);
       
    99     TInt MapNonUnicodeKey(TUint aScanCode);
       
   100 
       
   101     /**
       
   102      * Checks if media key support is enabled.
       
   103      *
       
   104      * @return  ETrue, if media key support is enabled.
       
   105      * @since S60 3.2
       
   106      */
       
   107     TBool MediaKeysEnabled() const;
       
   108 
       
   109     /**
       
   110      * Returns a pointer to the CMIDRemConObserver object.
       
   111      *
       
   112      * @return  Pointer to CMIDRemConObserver if it exists, or NULL.
       
   113      * @since S60 3.2
       
   114      */
       
   115     CMIDRemConObserver* GetRemConObserver();
       
   116 
       
   117     /**
       
   118      * Returns scan code for additional selection key mapping
       
   119      *
       
   120      * @return scan code for additional selection key mapping
       
   121      * @since S60 5.0
       
   122      */
       
   123     TInt AdditionalSelectionKeyMappingCode();
       
   124 
       
   125 private:
       
   126     //Private two phase construction and destruction
       
   127     CMIDKeyDecoder(MMIDEnv& aEnv);
       
   128     void ConstructL();
       
   129 
       
   130     /** Initialisation of special key translation table, see iSpecialKeys */
       
   131     void InitSpecialKeysL();
       
   132 
       
   133     /** Initialisation of iQwertyWatch and iQwertyModeActive */
       
   134     void CreateQwertyWatchL();
       
   135 
       
   136     /**
       
   137      * Creates RemConObserver. Does nothing if RemConObserver already exists.
       
   138      *
       
   139      * @since S60 3.2
       
   140      */
       
   141     void InitRemConObserverL();
       
   142 
       
   143 private:
       
   144     // MMIDQwertyObserver
       
   145     void NewQwertyValueL(TInt aNewValue);
       
   146 
       
   147 private:
       
   148     //Private helper methods
       
   149     void CreateGameActionsL();
       
   150     void LoadGameActionCodesL();
       
   151 
       
   152     void LoadCentralRepositoryCodesL(CRepository* aRepository);
       
   153     TBool QwertyInputAvailable() const;
       
   154     void AddCodeToActionL(TMIDGameAction* aGameAction, TInt aScanCode);
       
   155 
       
   156     TInt ScanToMidpCode(TInt aScanCode);
       
   157     TBool IsUnicode(TInt aKeyCode) const;
       
   158 
       
   159 private:
       
   160     /** For each MIDP Game action contains a TMIDGameAction*/
       
   161     RPointerArray<TMIDGameAction> iGameActions;
       
   162 
       
   163     /** This is needed by CKeyTranslator::TranslateKey() */
       
   164     CCaptureKeys*   iCaptureKeys;
       
   165 
       
   166     /** The window server key translator for converting SCAN codes to KEY codes */
       
   167     CKeyTranslator* iKeyTranslator;
       
   168 
       
   169     /** Special key translation table */
       
   170     RArray<TMIDKey> iSpecialKeys;
       
   171 
       
   172     /** Monitor status of qwerty input */
       
   173     CMIDQwertyWatch* iQwertyWatch;
       
   174 
       
   175     /** True when qwerty keyboard is available */
       
   176     TBool iQwertyModeActive;
       
   177 
       
   178     /** The action scan codes currently in use, either default ITU-T,
       
   179     or default QWERTY or from Central Repository */
       
   180     TInt* iActionScanCodes;
       
   181 
       
   182     /** True when we must use the scan codes from Central Repository */
       
   183     TBool iUseCRScanCodes;
       
   184 
       
   185     MMIDEnv&                iEnv;
       
   186 
       
   187     /** Receives media key events from RemCon */
       
   188     CMIDRemConObserver*     iRemConObserver;
       
   189 
       
   190     /** ETrue when media key support is enabled */
       
   191     TBool                   iMediaKeysEnabled;
       
   192 
       
   193     /** Scancode of additional Select key is stored here. Used when mapping MIDP special keys. */
       
   194     TUint iAdditionalSelectkeyMapping;
       
   195 
       
   196 };
       
   197 
       
   198 #endif // CMIDKEYDECODER_H