|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 // |
|
23 // TODO: this file is only tempral while we wait for Qt patch approval and include |
|
24 // |
|
25 |
|
26 #include "keymapper.h" |
|
27 #include <e32keys.h> |
|
28 |
|
29 QKeyMapperPrivate::QKeyMapperPrivate() |
|
30 { |
|
31 fillKeyMap(); |
|
32 } |
|
33 |
|
34 QKeyMapperPrivate::~QKeyMapperPrivate() |
|
35 { |
|
36 } |
|
37 |
|
38 void QKeyMapperPrivate::fillKeyMap() |
|
39 { |
|
40 using namespace Qt; |
|
41 keyMapping.append(KeyMapping(EKeyBackspace, EStdKeyBackspace, Key_Backspace)); |
|
42 keyMapping.append(KeyMapping(EKeyTab, EStdKeyTab, Key_Tab)); |
|
43 keyMapping.append(KeyMapping(EKeyEnter, EStdKeyEnter, Key_Enter)); |
|
44 keyMapping.append(KeyMapping(EKeyEscape, EStdKeyEscape, Key_Escape)); |
|
45 keyMapping.append(KeyMapping(EKeySpace, EStdKeySpace, Key_Space)); |
|
46 keyMapping.append(KeyMapping(EKeyDelete, EStdKeyDelete, Key_Delete)); |
|
47 keyMapping.append(KeyMapping(EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq)); |
|
48 keyMapping.append(KeyMapping(EKeyPause, EStdKeyPause, Key_Pause)); |
|
49 keyMapping.append(KeyMapping(EKeyHome, EStdKeyHome, Key_Home)); |
|
50 keyMapping.append(KeyMapping(EKeyEnd, EStdKeyEnd, Key_End)); |
|
51 keyMapping.append(KeyMapping(EKeyPageUp, EStdKeyPageUp, Key_PageUp)); |
|
52 keyMapping.append(KeyMapping(EKeyPageDown, EStdKeyPageDown, Key_PageDown)); |
|
53 keyMapping.append(KeyMapping(EKeyInsert, EStdKeyInsert, Key_Insert)); |
|
54 keyMapping.append(KeyMapping(EKeyLeftArrow, EStdKeyLeftArrow, Key_Left)); |
|
55 keyMapping.append(KeyMapping(EKeyRightArrow, EStdKeyRightArrow, Key_Right)); |
|
56 keyMapping.append(KeyMapping(EKeyUpArrow, EStdKeyUpArrow, Key_Up)); |
|
57 keyMapping.append(KeyMapping(EKeyDownArrow, EStdKeyDownArrow, Key_Down)); |
|
58 keyMapping.append(KeyMapping(EKeyLeftShift, EStdKeyLeftShift, Key_Shift)); |
|
59 keyMapping.append(KeyMapping(EKeyRightShift, EStdKeyRightShift, Key_Shift)); |
|
60 keyMapping.append(KeyMapping(EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt)); |
|
61 keyMapping.append(KeyMapping(EKeyRightAlt, EStdKeyRightAlt, Key_AltGr)); |
|
62 keyMapping.append(KeyMapping(EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control)); |
|
63 keyMapping.append(KeyMapping(EKeyRightCtrl, EStdKeyRightCtrl, Key_Control)); |
|
64 keyMapping.append(KeyMapping(EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L)); |
|
65 keyMapping.append(KeyMapping(EKeyRightFunc, EStdKeyRightFunc, Key_Super_R)); |
|
66 keyMapping.append(KeyMapping(EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock)); |
|
67 keyMapping.append(KeyMapping(EKeyNumLock, EStdKeyNumLock, Key_NumLock)); |
|
68 keyMapping.append(KeyMapping(EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock)); |
|
69 keyMapping.append(KeyMapping(EKeyF1, EStdKeyF1, Key_F1)); |
|
70 keyMapping.append(KeyMapping(EKeyF2, EStdKeyF2, Key_F2)); |
|
71 keyMapping.append(KeyMapping(EKeyF3, EStdKeyF3, Key_F3)); |
|
72 keyMapping.append(KeyMapping(EKeyF4, EStdKeyF4, Key_F4)); |
|
73 keyMapping.append(KeyMapping(EKeyF5, EStdKeyF5, Key_F5)); |
|
74 keyMapping.append(KeyMapping(EKeyF6, EStdKeyF6, Key_F6)); |
|
75 keyMapping.append(KeyMapping(EKeyF7, EStdKeyF7, Key_F7)); |
|
76 keyMapping.append(KeyMapping(EKeyF8, EStdKeyF8, Key_F8)); |
|
77 keyMapping.append(KeyMapping(EKeyF9, EStdKeyF9, Key_F9)); |
|
78 keyMapping.append(KeyMapping(EKeyF10, EStdKeyF10, Key_F10)); |
|
79 keyMapping.append(KeyMapping(EKeyF11, EStdKeyF11, Key_F11)); |
|
80 keyMapping.append(KeyMapping(EKeyF12, EStdKeyF12, Key_F12)); |
|
81 keyMapping.append(KeyMapping(EKeyF13, EStdKeyF13, Key_F13)); |
|
82 keyMapping.append(KeyMapping(EKeyF14, EStdKeyF14, Key_F14)); |
|
83 keyMapping.append(KeyMapping(EKeyF15, EStdKeyF15, Key_F15)); |
|
84 keyMapping.append(KeyMapping(EKeyF16, EStdKeyF16, Key_F16)); |
|
85 keyMapping.append(KeyMapping(EKeyF17, EStdKeyF17, Key_F17)); |
|
86 keyMapping.append(KeyMapping(EKeyF18, EStdKeyF18, Key_F18)); |
|
87 keyMapping.append(KeyMapping(EKeyF19, EStdKeyF19, Key_F19)); |
|
88 keyMapping.append(KeyMapping(EKeyF20, EStdKeyF20, Key_F20)); |
|
89 keyMapping.append(KeyMapping(EKeyF21, EStdKeyF21, Key_F21)); |
|
90 keyMapping.append(KeyMapping(EKeyF22, EStdKeyF22, Key_F22)); |
|
91 keyMapping.append(KeyMapping(EKeyF23, EStdKeyF23, Key_F23)); |
|
92 keyMapping.append(KeyMapping(EKeyF24, EStdKeyF24, Key_F24)); |
|
93 keyMapping.append(KeyMapping(EKeyOff, EStdKeyOff, Key_PowerOff)); |
|
94 // keyMapping.append(KeyMapping(EKeyMenu, EStdKeyMenu, Key_Menu)); // Menu is EKeyApplication0 |
|
95 keyMapping.append(KeyMapping(EKeyHelp, EStdKeyHelp, Key_Help)); |
|
96 keyMapping.append(KeyMapping(EKeyDial, EStdKeyDial, Key_Call)); |
|
97 keyMapping.append(KeyMapping(EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp)); |
|
98 keyMapping.append(KeyMapping(EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown)); |
|
99 keyMapping.append(KeyMapping(EKeyDevice0, EStdKeyDevice0, Key_Context1)); // Found by manual testing. |
|
100 keyMapping.append(KeyMapping(EKeyDevice1, EStdKeyDevice1, Key_Context2)); // Found by manual testing. |
|
101 keyMapping.append(KeyMapping(EKeyDevice3, EStdKeyDevice3, Key_Select)); |
|
102 // keyMapping.append(KeyMapping(EKeyDevice7, EStdKeyDevice7, Key_Camera)); //not supported by qt yet |
|
103 keyMapping.append(KeyMapping(EKeyApplication0, EStdKeyApplication0, Key_Menu)); // Found by manual testing. |
|
104 keyMapping.append(KeyMapping(EKeyApplication1, EStdKeyApplication1, Key_Launch1)); // Found by manual testing. |
|
105 keyMapping.append(KeyMapping(EKeyApplication2, EStdKeyApplication2, Key_MediaPlay)); // Found by manual testing. |
|
106 keyMapping.append(KeyMapping(EKeyApplication3, EStdKeyApplication3, Key_MediaStop)); // Found by manual testing. |
|
107 keyMapping.append(KeyMapping(EKeyApplication4, EStdKeyApplication4, Key_MediaNext)); // Found by manual testing. |
|
108 keyMapping.append(KeyMapping(EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious)); // Found by manual testing. |
|
109 keyMapping.append(KeyMapping(EKeyApplication6, EStdKeyApplication6, Key_Launch6)); |
|
110 keyMapping.append(KeyMapping(EKeyApplication7, EStdKeyApplication7, Key_Launch7)); |
|
111 keyMapping.append(KeyMapping(EKeyApplication8, EStdKeyApplication8, Key_Launch8)); |
|
112 keyMapping.append(KeyMapping(EKeyApplication9, EStdKeyApplication9, Key_Launch9)); |
|
113 keyMapping.append(KeyMapping(EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA)); |
|
114 keyMapping.append(KeyMapping(EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB)); |
|
115 keyMapping.append(KeyMapping(EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC)); |
|
116 keyMapping.append(KeyMapping(EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD)); |
|
117 keyMapping.append(KeyMapping(EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE)); |
|
118 keyMapping.append(KeyMapping(EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF)); |
|
119 // keyMapping.append(KeyMapping(EKeyApplication19, EStdKeyApplication19, Key_CameraFocus)); //not supported by qt yet |
|
120 keyMapping.append(KeyMapping(EKeyYes, EStdKeyYes, Key_Yes)); |
|
121 keyMapping.append(KeyMapping(EKeyNo, EStdKeyNo, Key_No)); |
|
122 } |
|
123 |
|
124 int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key) |
|
125 { |
|
126 int res = Qt::Key_unknown; |
|
127 for ( int i = 0, size = keyMapping.count(); i<size; i++){ |
|
128 if ( keyMapping[i].s60KeyCode == s60key){ |
|
129 res = keyMapping[i].qtKey; |
|
130 break; |
|
131 } |
|
132 } |
|
133 return res; |
|
134 } |
|
135 |
|
136 int QKeyMapperPrivate::mapS60ScanCodesToQt(TUint s60scanCode) |
|
137 { |
|
138 int res = Qt::Key_unknown; |
|
139 for ( int i = 0, size = keyMapping.count(); i<size; i++){ |
|
140 if ( keyMapping[i].s60ScanCode == s60scanCode){ |
|
141 res = keyMapping[i].qtKey; |
|
142 break; |
|
143 } |
|
144 } |
|
145 return res; |
|
146 } |
|
147 |
|
148 int QKeyMapperPrivate::mapQtToS60Key(int qtKey) |
|
149 { |
|
150 int res = KErrUnknown; |
|
151 for ( int i = 0, size = keyMapping.count(); i<size; i++){ |
|
152 if ( keyMapping[i].qtKey == qtKey){ |
|
153 res = keyMapping[i].s60KeyCode; |
|
154 break; |
|
155 } |
|
156 } |
|
157 return res; |
|
158 } |
|
159 |
|
160 int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey) |
|
161 { |
|
162 int res = KErrUnknown; |
|
163 for ( int i = 0, size = keyMapping.count(); i<size; i++){ |
|
164 if ( keyMapping[i].qtKey == qtKey){ |
|
165 res = keyMapping[i].s60ScanCode; |
|
166 break; |
|
167 } |
|
168 } |
|
169 return res; |
|
170 } |