|
1 // keymappings.cpp |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 |
|
14 #define WIN32_LEAN_AND_MEAN |
|
15 #include <windows.h> |
|
16 #include <e32keys.h> |
|
17 #include <e32def.h> |
|
18 #include "keymappings.h" |
|
19 |
|
20 |
|
21 static const TKeyMapping KKeyMapping[] = |
|
22 { |
|
23 { VK_ESCAPE, EKeyEscape }, |
|
24 { VK_LEFT, EKeyLeftArrow }, |
|
25 { VK_UP, EKeyUpArrow }, |
|
26 { VK_RIGHT, EKeyRightArrow }, |
|
27 { VK_DOWN, EKeyDownArrow }, |
|
28 { VK_HOME, EKeyHome }, |
|
29 { VK_END, EKeyEnd }, |
|
30 { VK_PRIOR, EKeyPageUp }, |
|
31 { VK_NEXT, EKeyPageDown }, |
|
32 { VK_PAUSE, EKeyPause }, |
|
33 { VK_PRINT, EKeyPrintScreen }, |
|
34 { VK_INSERT, EKeyInsert }, |
|
35 { VK_DELETE, EKeyDelete }, |
|
36 { VK_CAPITAL, EKeyCapsLock }, |
|
37 { VK_NUMLOCK, EKeyNumLock }, |
|
38 { VK_SCROLL, EKeyScrollLock }, |
|
39 { VK_F1, EKeyF1 }, |
|
40 { VK_F2, EKeyF2 }, |
|
41 { VK_F3, EKeyF3 }, |
|
42 { VK_F4, EKeyF4 }, |
|
43 { VK_F5, EKeyF5 }, |
|
44 { VK_F6, EKeyF6 }, |
|
45 { VK_F7, EKeyF7 }, |
|
46 { VK_F8, EKeyF8 }, |
|
47 { VK_F9, EKeyF9 }, |
|
48 { VK_F10, EKeyF10 }, |
|
49 { VK_F11, EKeyF11 }, |
|
50 { VK_F12, EKeyF12 }, |
|
51 { VK_F13, EKeyF13 }, |
|
52 { VK_F14, EKeyF14 }, |
|
53 { VK_F15, EKeyF15 }, |
|
54 { VK_F16, EKeyF16 }, |
|
55 { VK_F17, EKeyF17 }, |
|
56 { VK_F18, EKeyF18 }, |
|
57 { VK_F19, EKeyF19 }, |
|
58 { VK_F20, EKeyF20 }, |
|
59 { VK_F21, EKeyF21 }, |
|
60 { VK_F22, EKeyF22 }, |
|
61 { VK_F23, EKeyF23 }, |
|
62 { VK_F24, EKeyF24 }, |
|
63 }; |
|
64 |
|
65 TKeyCode GetSymbianKeyCode(int aWindowsKeyCode) |
|
66 { |
|
67 for (int i=0; i<sizeof(KKeyMapping) / sizeof(TKeyMapping); ++i) |
|
68 { |
|
69 if (KKeyMapping[i].iWindowsKey == aWindowsKeyCode) return KKeyMapping[i].iSymbianKey; |
|
70 } |
|
71 return EKeyNull; |
|
72 } |
|
73 |
|
74 TUint GetSymbianModifiers(TUint aWindowsModifiers) |
|
75 { |
|
76 TUint32 symMod = 0; |
|
77 if (aWindowsModifiers & CAPSLOCK_ON) symMod |= EModifierCapsLock; |
|
78 if (aWindowsModifiers & LEFT_ALT_PRESSED) symMod |= EModifierLeftAlt | EModifierAlt; |
|
79 if (aWindowsModifiers & LEFT_CTRL_PRESSED) symMod |= EModifierLeftCtrl | EModifierCtrl; |
|
80 if (aWindowsModifiers & NUMLOCK_ON) symMod |= EModifierNumLock; |
|
81 if (aWindowsModifiers & RIGHT_ALT_PRESSED) symMod |= EModifierRightAlt | EModifierAlt; |
|
82 if (aWindowsModifiers & RIGHT_CTRL_PRESSED) symMod |= EModifierLeftAlt | EModifierCtrl; |
|
83 if (aWindowsModifiers & SCROLLLOCK_ON) symMod |= EModifierScrollLock; |
|
84 if (aWindowsModifiers & SHIFT_PRESSED) symMod |= EModifierShift; |
|
85 return symMod; |
|
86 } |