os/boardsupport/emulator/emulatorbsp/specific/keyboard.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // wins\specific\keyboard.cpp
    15 // 
    16 //
    17 
    18 #include "gui.h"
    19 
    20 class KeySet
    21 	{
    22 public:
    23 	struct SEntry
    24 		{
    25 		const char* iName;
    26 		TInt iVal;
    27 		};
    28 public:
    29 	inline KeySet(const SEntry aMap[], TInt aSize)
    30 		:iMap(aMap), iSize(aSize)
    31 		{}
    32 	TInt operator[](const TDesC8& aName) const;
    33 private:
    34 	const SEntry* iMap;
    35 	TInt iSize;
    36 	};
    37 
    38 
    39 const TUint8 StandardKeyMap[KStandardKeyMapSize]=
    40 	{
    41 	EStdKeyNull,
    42 	EStdKeyEscape,
    43 	'1',
    44 	'2',
    45 	'3',
    46 	'4',
    47 	'5',
    48 	'6',
    49 	'7',
    50 	'8',
    51 	'9',
    52 	'0',
    53 	EStdKeyMinus,
    54 	EStdKeyEquals,
    55 	EStdKeyBackspace,
    56 	EStdKeyTab,
    57 	'Q',
    58 	'W',
    59 	'E',
    60 	'R',
    61 	'T',
    62 	'Y',
    63 	'U',
    64 	'I',
    65 	'O',
    66 	'P',
    67 	EStdKeySquareBracketLeft,
    68 	EStdKeySquareBracketRight,
    69 	EStdKeyEnter,
    70 	EStdKeyLeftCtrl,
    71 	'A',
    72 	'S',
    73 	'D',
    74 	'F',
    75 	'G',
    76 	'H',
    77 	'J',
    78 	'K',
    79 	'L',
    80 	EStdKeySemiColon,
    81 	EStdKeySingleQuote,
    82 	EStdKeyXXX,
    83 	EStdKeyLeftShift,
    84 	EStdKeyHash,
    85 	'Z',
    86 	'X',
    87 	'C',
    88 	'V',
    89 	'B',
    90 	'N',
    91 	'M',
    92 	EStdKeyComma,
    93 	EStdKeyFullStop,
    94 	EStdKeyForwardSlash,
    95 	EStdKeyRightShift,
    96 	EStdKeyNkpAsterisk,
    97 	EStdKeyLeftFunc,        // Alt key used as Func Key
    98 	EStdKeySpace,
    99 	EStdKeyCapsLock,
   100 	EStdKeyMenu,
   101 	EStdKeyHelp,
   102 	EStdKeyDial,
   103 	EStdKeyF4,
   104 	EStdKeyF5,
   105     EStdKeyF6,
   106     EStdKeyF7,
   107     EStdKeyF8,
   108 	EStdKeyOff,
   109 	EStdKeyF10,
   110 	EStdKeyPause,
   111 	EStdKeyScrollLock,
   112 	EStdKeyNkp7,
   113 	EStdKeyNkp8,
   114 	EStdKeyNkp9,
   115 	EStdKeyNkpMinus,
   116 	EStdKeyNkp4,
   117 	EStdKeyNkp5,
   118 	EStdKeyNkp6,
   119 	EStdKeyNkpPlus,
   120 	EStdKeyNkp1,
   121 	EStdKeyNkp2,
   122 	EStdKeyNkp3,
   123 	EStdKeyNkp0,
   124 	EStdKeyNkpFullStop,
   125 	EStdKeyNull,
   126 	EStdKeyNull,
   127 	EStdKeyBackSlash,
   128 	EStdKeyF11,
   129 	EStdKeyF12
   130 	};
   131 
   132 const TUint8 ExtendedKeyMap[]=
   133 	{
   134 //	EStdKeyNumLock,
   135 //	EStdKeyNull,
   136 //	EStdKeyHome,
   137 //	EStdKeyUpArrow,
   138 //	EStdKeyPageUp,
   139 //	EStdKeyNull,
   140 //	EStdKeyLeftArrow,
   141 //	EStdKeyNull,
   142 //	EStdKeyRightArrow,
   143 //	EStdKeyNull,
   144 //	EStdKeyEnd,
   145 //	EStdKeyDownArrow,
   146 //	EStdKeyPageDown,
   147 //	EStdKeyInsert,
   148 //	EStdKeyDelete
   149 	/*1c*/	EStdKeyNkpEnter,
   150 	/*1d*/	EStdKeyRightCtrl,
   151 	/*1e*/	EStdKeyNull,
   152 	/*1f*/	EStdKeyNull,
   153 	/*20*/	EStdKeyNull,
   154 	/*21*/	EStdKeyNull,
   155 	/*22*/	EStdKeyNull,
   156 	/*23*/	EStdKeyNull,
   157 	/*24*/	EStdKeyNull,
   158 	/*25*/	EStdKeyNull,
   159 	/*26*/	EStdKeyNull,
   160 	/*27*/	EStdKeyNull,
   161 	/*28*/	EStdKeyNull,
   162 	/*29*/	EStdKeyNull,
   163 	/*2a*/	EStdKeyNull,
   164 	/*2b*/	EStdKeyNull,
   165 	/*2c*/	EStdKeyNull,
   166 	/*2d*/	EStdKeyNull,
   167 	/*2e*/	EStdKeyNull,
   168 	/*2f*/	EStdKeyNull,
   169 	/*30*/	EStdKeyNull,
   170 	/*31*/	EStdKeyNull,
   171 	/*32*/	EStdKeyNull,
   172 	/*33*/	EStdKeyNull,
   173 	/*34*/	EStdKeyNull,
   174 	/*35*/	EStdKeyNkpForwardSlash,
   175 	/*36*/	EStdKeyNull,
   176 	/*37*/	EStdKeyPrintScreen, // Actually e0 2a e0 37
   177 	/*38*/	EStdKeyRightFunc,
   178 	/*39*/	EStdKeyNull,
   179 	/*3a*/	EStdKeyNull,
   180 	/*3b*/	EStdKeyNull,
   181 	/*3c*/	EStdKeyNull,
   182 	/*3d*/	EStdKeyNull,
   183 	/*3e*/	EStdKeyNull,
   184 	/*3f*/	EStdKeyNull,
   185 	/*40*/	EStdKeyNull,
   186 	/*41*/	EStdKeyNull,
   187 	/*42*/	EStdKeyNull,
   188 	/*43*/	EStdKeyNull,
   189 	/*44*/	EStdKeyNull,
   190 	/*45*/	EStdKeyNumLock,
   191 	/*46*/	EStdKeyNull,
   192 	/*47*/	EStdKeyHome,
   193 	/*48*/	EStdKeyUpArrow,
   194 	/*49*/	EStdKeyPageUp,
   195 	/*4a*/	EStdKeyNull,
   196 	/*4b*/	EStdKeyLeftArrow,
   197 	/*4c*/	EStdKeyNull,
   198 	/*4d*/	EStdKeyRightArrow,
   199 	/*4e*/	EStdKeyNull,
   200 	/*4f*/	EStdKeyEnd,
   201 	/*50*/	EStdKeyDownArrow,
   202 	/*51*/	EStdKeyPageDown,
   203 	/*52*/	EStdKeyInsert,
   204 	/*53*/	EStdKeyDelete,
   205 	/*54*/	EStdKeyNull,
   206 	/*55*/	EStdKeyNull,
   207 	/*56*/	EStdKeyNull,
   208 	/*57*/	EStdKeyNull,
   209 	/*58*/	EStdKeyNull,
   210 	/*59*/	EStdKeyNull,
   211 	/*5a*/	EStdKeyNull,
   212 	/*5b*/	EStdKeyLeftAlt,	//left windows key
   213 	/*5c*/	EStdKeyMenu,	//right windows key
   214 	/*5d*/	EStdKeyHelp		//right mouse button key
   215 	};
   216 
   217 
   218 const KeySet::SEntry EPOCKeyNameToKeyMap[] =
   219 	{
   220 	{"EStdKeyNull",EStdKeyNull},
   221 	{"EStdKeyBackspace",EStdKeyBackspace},
   222 	{"EStdKeyTab",EStdKeyTab},
   223 	{"EStdKeyEnter",EStdKeyEnter},
   224 	{"EStdKeyEscape",EStdKeyEscape},
   225 	{"EStdKeySpace",EStdKeySpace},
   226 	{"EStdKeyPrintScreen",EStdKeyPrintScreen},
   227 	{"EStdKeyPause",EStdKeyPause},
   228 	{"EStdKeyHome",EStdKeyHome},
   229 	{"EStdKeyEnd",EStdKeyEnd},
   230 	{"EStdKeyPageUp",EStdKeyPageUp},
   231 	{"EStdKeyPageDown",EStdKeyPageDown},
   232 	{"EStdKeyInsert",EStdKeyInsert},
   233 	{"EStdKeyDelete",EStdKeyDelete},
   234 	{"EStdKeyLeftArrow",EStdKeyLeftArrow},
   235 	{"EStdKeyRightArrow",EStdKeyRightArrow},
   236 	{"EStdKeyUpArrow",EStdKeyUpArrow},
   237 	{"EStdKeyDownArrow",EStdKeyDownArrow},
   238 	{"EStdKeyLeftShift",EStdKeyLeftShift},
   239 	{"EStdKeyRightShift",EStdKeyRightShift},
   240 	{"EStdKeyLeftAlt",EStdKeyLeftAlt},
   241 	{"EStdKeyRightAlt",EStdKeyRightAlt},
   242 	{"EStdKeyLeftCtrl",EStdKeyLeftCtrl},
   243 	{"EStdKeyRightCtrl",EStdKeyRightCtrl},
   244 	{"EStdKeyLeftFunc",EStdKeyLeftFunc},
   245 	{"EStdKeyRightFunc",EStdKeyRightFunc},
   246 	{"EStdKeyCapsLock",EStdKeyCapsLock},
   247 	{"EStdKeyNumLock",EStdKeyNumLock},
   248 	{"EStdKeyScrollLock",EStdKeyScrollLock},
   249 	{"EStdKeyF1",EStdKeyF1},
   250 	{"EStdKeyF2",EStdKeyF2},
   251 	{"EStdKeyF3",EStdKeyF3},
   252 	{"EStdKeyF4",EStdKeyF4},
   253 	{"EStdKeyF5",EStdKeyF5},
   254 	{"EStdKeyF6",EStdKeyF6},
   255 	{"EStdKeyF7",EStdKeyF7},
   256 	{"EStdKeyF8",EStdKeyF8},
   257 	{"EStdKeyF9",EStdKeyF9},
   258 	{"EStdKeyF10",EStdKeyF10},
   259 	{"EStdKeyF11",EStdKeyF11},
   260 	{"EStdKeyF12",EStdKeyF12},
   261 	{"EStdKeyF13",EStdKeyF13},
   262 	{"EStdKeyF14",EStdKeyF14},
   263 	{"EStdKeyF15",EStdKeyF15},
   264 	{"EStdKeyF16",EStdKeyF16},
   265 	{"EStdKeyF17",EStdKeyF17},
   266 	{"EStdKeyF18",EStdKeyF18},
   267 	{"EStdKeyF19",EStdKeyF19},
   268 	{"EStdKeyF20",EStdKeyF20},
   269 	{"EStdKeyF21",EStdKeyF21},
   270 	{"EStdKeyF22",EStdKeyF22},
   271 	{"EStdKeyF23",EStdKeyF23},
   272 	{"EStdKeyF24",EStdKeyF24},
   273 	{"EStdKeyXXX",EStdKeyXXX},
   274 	{"EStdKeyComma",EStdKeyComma},
   275 	{"EStdKeyFullStop",EStdKeyFullStop},
   276 	{"EStdKeyForwardSlash",EStdKeyForwardSlash},
   277 	{"EStdKeyBackSlash",EStdKeyBackSlash},
   278 	{"EStdKeySemiColon",EStdKeySemiColon},
   279 	{"EStdKeySingleQuote",EStdKeySingleQuote},
   280 	{"EStdKeyHash",EStdKeyHash},
   281 	{"EStdKeySquareBracketLeft",EStdKeySquareBracketLeft},
   282 	{"EStdKeySquareBracketRight",EStdKeySquareBracketRight},
   283 	{"EStdKeyMinus",EStdKeyMinus},
   284 	{"EStdKeyEquals",EStdKeyEquals},
   285 	{"EStdKeyNkpForwardSlash",EStdKeyNkpForwardSlash},
   286 	{"EStdKeyNkpAsterisk",EStdKeyNkpAsterisk},
   287 	{"EStdKeyNkpMinus",EStdKeyNkpMinus},
   288 	{"EStdKeyNkpPlus",EStdKeyNkpPlus},
   289 	{"EStdKeyNkpEnter",EStdKeyNkpEnter},
   290 	{"EStdKeyNkp1",EStdKeyNkp1},
   291 	{"EStdKeyNkp2",EStdKeyNkp2},
   292 	{"EStdKeyNkp3",EStdKeyNkp3},
   293 	{"EStdKeyNkp4",EStdKeyNkp4},
   294 	{"EStdKeyNkp5",EStdKeyNkp5},
   295 	{"EStdKeyNkp6",EStdKeyNkp6},
   296 	{"EStdKeyNkp7",EStdKeyNkp7},
   297 	{"EStdKeyNkp8",EStdKeyNkp8},
   298 	{"EStdKeyNkp9",EStdKeyNkp9},
   299 	{"EStdKeyNkp0",EStdKeyNkp0},
   300 	{"EStdKeyNkpFullStop",EStdKeyNkpFullStop},
   301 	{"EStdKeyMenu",EStdKeyMenu},
   302 	{"EStdKeyBacklightOn",EStdKeyBacklightOn},
   303 	{"EStdKeyBacklightOff",EStdKeyBacklightOff},
   304 	{"EStdKeyBacklightToggle",EStdKeyBacklightToggle},
   305 	{"EStdKeyIncContrast",EStdKeyIncContrast},
   306 	{"EStdKeyDecContrast",EStdKeyDecContrast},
   307 	{"EStdKeySliderDown",EStdKeySliderDown},
   308 	{"EStdKeySliderUp",EStdKeySliderUp},
   309 	{"EStdKeyDictaphonePlay",EStdKeyDictaphonePlay},
   310 	{"EStdKeyDictaphoneStop",EStdKeyDictaphoneStop},
   311 	{"EStdKeyDictaphoneRecord",EStdKeyDictaphoneRecord},
   312 	{"EStdKeyHelp",EStdKeyHelp},
   313 	{"EStdKeyOff",EStdKeyOff},
   314 	{"EStdKeyDial",EStdKeyDial},
   315 	{"EStdKeyIncVolume",EStdKeyIncVolume},
   316 	{"EStdKeyDecVolume",EStdKeyDecVolume},
   317 	{"EStdKeyDevice0",EStdKeyDevice0},
   318 	{"EStdKeyDevice1",EStdKeyDevice1},
   319 	{"EStdKeyDevice2",EStdKeyDevice2},
   320 	{"EStdKeyDevice3",EStdKeyDevice3},
   321 	{"EStdKeyDevice4",EStdKeyDevice4},
   322 	{"EStdKeyDevice5",EStdKeyDevice5},
   323 	{"EStdKeyDevice6",EStdKeyDevice6},
   324 	{"EStdKeyDevice7",EStdKeyDevice7},
   325 	{"EStdKeyDevice8",EStdKeyDevice8},
   326 	{"EStdKeyDevice9",EStdKeyDevice9},
   327 	{"EStdKeyDeviceA",EStdKeyDeviceA},
   328 	{"EStdKeyDeviceB",EStdKeyDeviceB},
   329 	{"EStdKeyDeviceC",EStdKeyDeviceC},
   330 	{"EStdKeyDeviceD",EStdKeyDeviceD},
   331 	{"EStdKeyDeviceE",EStdKeyDeviceE},
   332 	{"EStdKeyDeviceF",EStdKeyDeviceF},
   333 	{"EStdKeyDevice10",EStdKeyDevice10},
   334 	{"EStdKeyDevice11",EStdKeyDevice11},
   335 	{"EStdKeyDevice12",EStdKeyDevice12},
   336 	{"EStdKeyDevice13",EStdKeyDevice13},
   337 	{"EStdKeyDevice14",EStdKeyDevice14},
   338 	{"EStdKeyDevice15",EStdKeyDevice15},
   339 	{"EStdKeyDevice16",EStdKeyDevice16},
   340 	{"EStdKeyDevice17",EStdKeyDevice17},
   341 	{"EStdKeyDevice18",EStdKeyDevice18},
   342 	{"EStdKeyDevice19",EStdKeyDevice19},
   343 	{"EStdKeyDevice1A",EStdKeyDevice1A},
   344 	{"EStdKeyDevice1B",EStdKeyDevice1B},
   345 	{"EStdKeyDevice1C",EStdKeyDevice1C},
   346 	{"EStdKeyDevice1D",EStdKeyDevice1D},
   347 	{"EStdKeyDevice1E",EStdKeyDevice1E},
   348 	{"EStdKeyDevice1F",EStdKeyDevice1F},
   349 	{"EStdKeyDevice20",EStdKeyDevice20},
   350 	{"EStdKeyDevice21",EStdKeyDevice21},
   351 	{"EStdKeyDevice22",EStdKeyDevice22},
   352 	{"EStdKeyDevice23",EStdKeyDevice23},
   353 	{"EStdKeyDevice24",EStdKeyDevice24},
   354 	{"EStdKeyDevice25",EStdKeyDevice25},
   355 	{"EStdKeyDevice26",EStdKeyDevice26},
   356 	{"EStdKeyDevice27",EStdKeyDevice27},
   357 	{"EStdKeyApplication0",EStdKeyApplication0},
   358 	{"EStdKeyApplication1",EStdKeyApplication1},
   359 	{"EStdKeyApplication2",EStdKeyApplication2},
   360 	{"EStdKeyApplication3",EStdKeyApplication3},
   361 	{"EStdKeyApplication4",EStdKeyApplication4},
   362 	{"EStdKeyApplication5",EStdKeyApplication5},
   363 	{"EStdKeyApplication6",EStdKeyApplication6},
   364 	{"EStdKeyApplication7",EStdKeyApplication7},
   365 	{"EStdKeyApplication8",EStdKeyApplication8},
   366 	{"EStdKeyApplication9",EStdKeyApplication9},
   367 	{"EStdKeyApplicationA",EStdKeyApplicationA},
   368 	{"EStdKeyApplicationB",EStdKeyApplicationB},
   369 	{"EStdKeyApplicationC",EStdKeyApplicationC},
   370 	{"EStdKeyApplicationD",EStdKeyApplicationD},
   371 	{"EStdKeyApplicationE",EStdKeyApplicationE},
   372 	{"EStdKeyApplicationF",EStdKeyApplicationF},
   373 	{"EStdKeyApplication10",EStdKeyApplication10},
   374 	{"EStdKeyApplication11",EStdKeyApplication11},
   375 	{"EStdKeyApplication12",EStdKeyApplication12},
   376 	{"EStdKeyApplication13",EStdKeyApplication13},
   377 	{"EStdKeyApplication14",EStdKeyApplication14},
   378 	{"EStdKeyApplication15",EStdKeyApplication15},
   379 	{"EStdKeyApplication16",EStdKeyApplication16},
   380 	{"EStdKeyApplication17",EStdKeyApplication17},
   381 	{"EStdKeyApplication18",EStdKeyApplication18},
   382 	{"EStdKeyApplication19",EStdKeyApplication19},
   383 	{"EStdKeyApplication1A",EStdKeyApplication1A},
   384 	{"EStdKeyApplication1B",EStdKeyApplication1B},
   385 	{"EStdKeyApplication1C",EStdKeyApplication1C},
   386 	{"EStdKeyApplication1D",EStdKeyApplication1D},
   387 	{"EStdKeyApplication1E",EStdKeyApplication1E},
   388 	{"EStdKeyApplication1F",EStdKeyApplication1F},
   389 	{"EStdKeyApplication20",EStdKeyApplication20},
   390 	{"EStdKeyApplication21",EStdKeyApplication21},
   391 	{"EStdKeyApplication22",EStdKeyApplication22},
   392 	{"EStdKeyApplication23",EStdKeyApplication23},
   393 	{"EStdKeyApplication24",EStdKeyApplication24},
   394 	{"EStdKeyApplication25",EStdKeyApplication25},
   395 	{"EStdKeyApplication26",EStdKeyApplication26},
   396 	{"EStdKeyApplication27",EStdKeyApplication27},
   397 	{"EStdKeyYes",EStdKeyYes},
   398 	{"EStdKeyNo",EStdKeyNo},
   399 	{"EStdKeyIncBrightness",EStdKeyIncBrightness},
   400 	{"EStdKeyDecBrightness",EStdKeyDecBrightness},
   401 	{"A", 'A'},
   402 	{"B", 'B'},
   403 	{"C", 'C'},
   404 	{"D", 'D'},
   405 	{"E", 'E'},
   406 	{"F", 'F'},
   407 	{"G", 'G'},
   408 	{"H", 'H'},
   409 	{"I", 'I'},
   410 	{"J", 'J'},
   411 	{"K", 'K'},
   412 	{"L", 'L'},
   413 	{"M", 'M'},
   414 	{"N", 'N'},
   415 	{"O", 'O'},
   416 	{"P", 'P'},
   417 	{"Q", 'Q'},
   418 	{"R", 'R'},
   419 	{"S", 'S'},
   420 	{"T", 'T'},
   421 	{"U", 'U'},
   422 	{"V", 'V'},
   423 	{"W", 'W'},
   424 	{"X", 'X'},
   425 	{"Y", 'Y'},
   426 	{"Z", 'Z'},
   427 	{"0", '0'},
   428 	{"1", '1'},
   429 	{"2", '2'},
   430 	{"3", '3'},
   431 	{"4", '4'},
   432 	{"5", '5'},
   433 	{"6", '6'},
   434 	{"7", '7'},
   435 	{"8", '8'},
   436 	{"9", '9'},
   437 	{"EKeyScreenDimension0",EKeyScreenDimension0<<16},
   438 	{"EKeyScreenDimension1",EKeyScreenDimension1<<16},
   439 	{"EKeyScreenDimension2",EKeyScreenDimension2<<16},
   440 	{"EKeyScreenDimension3",EKeyScreenDimension3<<16}
   441 	};
   442 
   443 const KeySet::SEntry RealKeyNames[] = 
   444 	{
   445 	{"Escape",1},
   446 	{"1",2},
   447 	{"2",3},
   448 	{"3",4},
   449 	{"4",5},
   450 	{"5",6},
   451 	{"6",7},
   452 	{"7",8},
   453 	{"8",9},
   454 	{"9",10},
   455 	{"0",11},
   456 	{"Minus",12},
   457 	{"Equals",13},
   458 	{"BackSpace",14},
   459 	{"Tab",15},
   460 	{"Q",16},
   461 	{"W",17},
   462 	{"E",18},
   463 	{"R",19},
   464 	{"T",20},
   465 	{"Y",21},
   466 	{"U",22},
   467 	{"I",23},
   468 	{"O",24},
   469 	{"P",25},
   470 	{"SquareBracketLeft",26},
   471 	{"SquareBracketRight",27},
   472 	{"Enter",28},
   473 	{"LeftCtrl",29},
   474 	{"A",30},
   475 	{"S",31},
   476 	{"D",32},
   477 	{"F",33},
   478 	{"G",34},
   479 	{"H",35},
   480 	{"J",36},
   481 	{"K",37},
   482 	{"L",38},
   483 	{"SemiColon",39},
   484 	{"SingleQuote",40},
   485 	{"BackTick",41},
   486 	{"LeftShift",42},
   487 	{"Hash",43},
   488 	{"Z",44},
   489 	{"X",45},
   490 	{"C",46},
   491 	{"V",47},
   492 	{"B",48},
   493 	{"N",49},
   494 	{"M",50},
   495 	{"Comma",51},
   496 	{"FullStop",52},
   497 	{"ForwardSlash",53},
   498 	{"RightShift",54},
   499 	{"NkpAsterisk",55},
   500 	{"LeftAlt",56},        // Alt key used as Func Key
   501 	{"Space",57},
   502 	{"CapsLock",58},
   503 	{"F1",59},
   504 	{"F2",60},
   505 	{"F3",61},
   506 	{"F4",62},
   507 	{"F5",63},
   508     {"F6",64},
   509     {"F7",65},
   510     {"F8",66},
   511 	{"F9",67},
   512 	{"F10",68},
   513 	{"Pause",69},
   514 	{"ScrollLock",70},
   515 	{"Nkp7",71},
   516 	{"Nkp8",72},
   517 	{"Nkp9",73},
   518 	{"NkpMinus",74},
   519 	{"Nkp4",75},
   520 	{"Nkp5",76},
   521 	{"Nkp6",77},
   522 	{"NkpPlus",78},
   523 	{"Nkp1",79},
   524 	{"Nkp2",80},
   525 	{"Nkp3",81},
   526 	{"Nkp0",82},
   527 	{"NkpFullStop",83},
   528 	{"BackSlash",86},
   529 	{"F11",87},
   530 	{"F12",88}
   531 	};
   532 
   533 const KeySet::SEntry RealExtendedKeyNames[] = 
   534 	{
   535 	{"NkpEnter",0},
   536 	{"RightCtrl",1},
   537 	{"NkpForwardSlash", 25},
   538 	{"PrintScreen",27},
   539 	{"RightAlt", 28},
   540 	{"NumLock", 41},
   541 	{"Home",43},
   542 	{"UpArrow",44},
   543 	{"PageUp",45},
   544 	{"LeftArrow",47},
   545 	{"RightArrow",49},
   546 	{"End",51},
   547 	{"DownArrow",52},
   548 	{"PageDown",53},
   549 	{"Insert",54},
   550 	{"Delete",55},
   551 	{"LeftWindows",63},
   552 	{"RightWindows",64},
   553 	{"ContextMenu",65}
   554 	};
   555 
   556 const KeySet EpocKeys(EPOCKeyNameToKeyMap, sizeof(EPOCKeyNameToKeyMap)/sizeof(KeySet::SEntry));
   557 const KeySet StandardKeys(RealKeyNames, sizeof(RealKeyNames)/sizeof(KeySet::SEntry));
   558 const KeySet ExtendedKeys(RealExtendedKeyNames, sizeof(RealExtendedKeyNames)/sizeof(KeySet::SEntry));
   559 
   560 TInt KeySet::operator[](const TDesC8& aName) const
   561 	{
   562 	TInt len = aName.Length();
   563 	const char* p = (const char*)aName.Ptr();
   564 	for (const SEntry* e = iMap + iSize; --e >= iMap; )
   565 		{
   566 		if (_strnicmp(e->iName, p, len) == 0 && e->iName[len] == '\0')
   567 			return e->iVal;
   568 		}
   569 	return KErrNotFound;
   570 	}
   571 
   572 // Class Alias
   573 
   574 Alias::Alias()
   575 	:iMap(10)
   576 	{}
   577 
   578 TInt Alias::Add(const TDesC8& aAlias, const TDesC8& aName)
   579 //
   580 // add a new alias
   581 //
   582 	{
   583 	TInt r = KErrNoMemory;
   584 	SEntry e;
   585 	e.iAlias = HBuf8::New(aAlias);
   586 	if (e.iAlias)
   587 		{
   588 		e.iName = HBuf8::New(aName);
   589 		if (e.iName)
   590 			{
   591 			r = iMap.InsertInOrder(e, &Alias::Compare);
   592 			if (r == KErrNone)
   593 				return KErrNone;
   594 			delete e.iName;
   595 			}
   596 		delete e.iAlias;
   597 		}
   598 	return r;
   599 	}
   600 
   601 const TDesC8* Alias::operator[](const TDesC8& aAlias)
   602 //
   603 // Look up an alias
   604 //
   605 	{
   606 	SEntry e;
   607 	e.iAlias = const_cast<TDesC8*>(&aAlias);
   608 	TInt ix = iMap.FindInOrder(e, &Alias::Compare);
   609 	return ix >= 0 ? iMap[ix].iName : NULL;
   610 	}
   611 
   612 TInt Alias::Compare(const SEntry& aLhs, const SEntry& aRhs)
   613 	{
   614 	return CompareI(*aLhs.iAlias, *aRhs.iAlias);
   615 	}
   616 
   617 
   618 
   619 // keyboard mapping
   620 
   621 DWinsKeyboard::DWinsKeyboard()
   622 	{
   623 	memcpy(iStandardKeyMap, StandardKeyMap, KStandardKeyMapSize);
   624 	memcpy(iExtendedKeyMap, ExtendedKeyMap, KExtendedKeyMapSize);
   625 	memcpy(iAltStandardKeyMap, StandardKeyMap, KStandardKeyMapSize);
   626 	memcpy(iAltExtendedKeyMap, ExtendedKeyMap, KExtendedKeyMapSize);
   627 	memcpy(iCtrlStandardKeyMap, StandardKeyMap, KStandardKeyMapSize);
   628 	memcpy(iCtrlExtendedKeyMap, ExtendedKeyMap, KExtendedKeyMapSize);
   629 	}
   630 
   631 TInt DWinsKeyboard::Init(TInt aId)
   632 //
   633 // Initialise the alias and key maps from the properties
   634 //
   635 	{
   636 	char property[50];
   637 	wsprintfA(property, "Configuration[%d]DefineKeyName",aId);
   638 	TInt r = MultiProperty(&DWinsKeyboard::DoDefineAlias, this, property);
   639 	if (r != KErrNone)
   640 		return r;
   641 	wsprintfA(property, "Configuration[%d]KeyMap",aId);
   642 	r = MultiProperty(&DWinsKeyboard::DoMapKey, this, property);
   643 	return r;
   644 	}
   645 
   646 TInt DWinsKeyboard::DoDefineAlias(TAny* aPtr, const char* aValue)
   647 	{
   648 	return static_cast<DWinsKeyboard*>(aPtr)->DefineAlias(aValue);
   649 	}
   650 
   651 TInt DWinsKeyboard::DefineAlias(const char* aValue)
   652 //
   653 // The character string terminates in a ';' or a '\0'
   654 //
   655 	{
   656 	//get the alias name
   657 	const char* beg = skipws(aValue);
   658 	const char* end = skiptok(beg);
   659 	TPtrC8 alias((const TUint8*)beg, end-beg);
   660 
   661 	//get the real name
   662 	beg = skipws(end);
   663 	end = skiptok(beg);
   664 	TPtrC8 name((const TUint8*)beg, end-beg);
   665 
   666 	//prevent an alias being made of an alias
   667 	if (iAliasedKeys[name] != NULL)
   668 		return KErrArgument;
   669 
   670 	// ensure this is valid name
   671 	TInt r = GetEPOCKeyCode(name);
   672 	if (r == KErrNotFound)
   673 		return r;
   674 
   675 	//now we need to record the alias name and the real key name
   676 	return iAliasedKeys.Add(alias, name);
   677 	}
   678 
   679 
   680 TInt DWinsKeyboard::DoMapKey(TAny* aPtr, const char* aValue)
   681 	{
   682 	return static_cast<DWinsKeyboard*>(aPtr)->MapKey(aValue);
   683 	}
   684 
   685 TInt DWinsKeyboard::MapKey(const char* aValue)
   686 	{
   687 	//get the win32 name
   688 	const char* beg = skipws(aValue);
   689 	const char* end = skiptok(beg);
   690 
   691 	// check to see if a modifier key has been specified
   692 	TBool altModifier = !_strnicmp(beg, "LeftAlt", 7);
   693 	altModifier |= !_strnicmp(beg, "RightAlt", 8);
   694 	TBool ctrlModifier = !_strnicmp(beg, "LeftCtrl", 8);
   695 	ctrlModifier |= !_strnicmp(beg, "RightCtrl", 9);
   696 
   697 	// if modifier was found, skip to next token
   698 	if (altModifier || ctrlModifier)
   699 		{
   700 		beg = skipws(end);
   701 		end = skiptok(beg);
   702 		}
   703 
   704 	TPtrC8 name((const TUint8*)beg, end-beg);
   705 
   706 	//get the epoc key
   707 	beg = skipws(end);
   708 	end = skiptok(beg);
   709 	TInt key = GetEPOCKeyCode(TPtrC8((const TUint8*)beg, end-beg));
   710 	if (key == KErrNotFound)
   711 		return key;
   712 
   713 	TInt scancode = StandardKeys[name];
   714 
   715 	// if alt modifier was specified, change the alt key map
   716 	if (altModifier)
   717 		{
   718 		if (scancode >= 0)
   719 			iAltStandardKeyMap[scancode] = (TUint8)key;
   720 		else
   721 			{
   722 			scancode = ExtendedKeys[name];
   723 			if (scancode >= 0)
   724 				iAltExtendedKeyMap[scancode] = (TUint8)key;
   725 			else
   726 				return KErrNotFound;
   727 			}
   728 		}
   729 
   730 	// if ctrl modifier was specified, change the ctrl key map
   731 	else if (ctrlModifier)
   732 		{
   733 		if (scancode >= 0)
   734 			iCtrlStandardKeyMap[scancode] = (TUint8)key;
   735 		else
   736 			{
   737 			scancode = ExtendedKeys[name];
   738 			if (scancode >= 0)
   739 				iCtrlExtendedKeyMap[scancode] = (TUint8)key;
   740 			else
   741 				return KErrNotFound;
   742 			}
   743 		}
   744 
   745 	// no modifier, change the default key map
   746 	else
   747 		{
   748 		if (scancode >= 0)
   749 			iStandardKeyMap[scancode] = (TUint8)key;
   750 		else
   751 			{
   752 			scancode = ExtendedKeys[name];
   753 			if (scancode >= 0)
   754 				iExtendedKeyMap[scancode] = (TUint8)key;
   755 			else
   756 				return KErrNotFound;
   757 			}
   758 		}
   759 
   760 	return KErrNone;
   761 	}
   762 
   763 TInt DWinsKeyboard::GetEPOCKeyCode(const TDesC8& aStr)
   764 	{
   765 	// look for an alias
   766 	const TDesC8* arg = iAliasedKeys[aStr];
   767 	return EpocKeys[arg ? *arg : aStr];
   768 	}
   769 
   770 TInt DWinsKeyboard::ScanCodeToKey(TInt aScanCode, const TUint8* aStandardMap, const TUint8* aExtendedMap)
   771 //
   772 // Map Windows scan codes to Epoc key
   773 //
   774 	{
   775 	TInt stdCode = EStdKeyNull;
   776 	TInt extended = aScanCode&KKeyExtendedBit;
   777 	aScanCode &= KKeyNormalBits;
   778 	if (extended)
   779 		{
   780 		if (aScanCode >= KExtendedKeyBase && aScanCode <= KMaxExtendedKey)
   781 			stdCode = aExtendedMap[aScanCode - KExtendedKeyBase];
   782 		}
   783 	else if (aScanCode < KStandardKeyMapSize)
   784 		stdCode = aStandardMap[aScanCode];
   785 	return stdCode;
   786 	}
   787 
   788 TInt DWinsKeyboard::ScanCodeToStandardKey(TInt aScanCode)
   789 //
   790 // Map Windows scan codes to standard keys
   791 //
   792 	{
   793 	return ScanCodeToKey(aScanCode, StandardKeyMap, ExtendedKeyMap );
   794 	}
   795 
   796 TInt DWinsKeyboard::ScanCodeToRemappedKey(TInt aScanCode)
   797 //
   798 // Map Windows scan codes to remapped keys
   799 //
   800 	{
   801 	if (HIBYTE(GetKeyState(VK_MENU)))      // Alt key is pressed
   802 		return ScanCodeToKey(aScanCode, iAltStandardKeyMap, iAltExtendedKeyMap );
   803 
   804 	if (HIBYTE(GetKeyState(VK_CONTROL)))   // Ctrl key is pressed
   805 		return ScanCodeToKey(aScanCode, iCtrlStandardKeyMap, iCtrlExtendedKeyMap );
   806 
   807 	return ScanCodeToKey(aScanCode, iStandardKeyMap, iExtendedKeyMap );
   808 	}
   809 
   810 
   811 
   812 
   813 TInt DWinsKeyboard::GetScanCode(const TDesC8& aStr)
   814 	{
   815 	return  StandardKeys[aStr];	
   816 	}
   817