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