|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "private/qkeymapper_p.h" |
|
43 #include <e32keys.h> |
|
44 |
|
45 QT_BEGIN_NAMESPACE |
|
46 |
|
47 QKeyMapperPrivate::QKeyMapperPrivate() |
|
48 { |
|
49 } |
|
50 |
|
51 QKeyMapperPrivate::~QKeyMapperPrivate() |
|
52 { |
|
53 } |
|
54 |
|
55 QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent * /* e */) |
|
56 { |
|
57 QList<int> result; |
|
58 return result; |
|
59 } |
|
60 |
|
61 void QKeyMapperPrivate::clearMappings() |
|
62 { |
|
63 // stub |
|
64 } |
|
65 |
|
66 QString QKeyMapperPrivate::translateKeyEvent(int keySym, Qt::KeyboardModifiers /* modifiers */) |
|
67 { |
|
68 if (keySym >= Qt::Key_Escape) |
|
69 return QString(); |
|
70 |
|
71 // Symbian doesn't actually use modifiers, but gives us the character code directly. |
|
72 |
|
73 return QString(QChar(keySym)); |
|
74 } |
|
75 |
|
76 #include <e32keys.h> |
|
77 struct KeyMapping{ |
|
78 TKeyCode s60KeyCode; |
|
79 TStdScanCode s60ScanCode; |
|
80 Qt::Key qtKey; |
|
81 }; |
|
82 |
|
83 using namespace Qt; |
|
84 |
|
85 static const KeyMapping keyMapping[] = { |
|
86 {EKeyBackspace, EStdKeyBackspace, Key_Backspace}, |
|
87 {EKeyTab, EStdKeyTab, Key_Tab}, |
|
88 {EKeyEnter, EStdKeyEnter, Key_Enter}, |
|
89 {EKeyEscape, EStdKeyEscape, Key_Escape}, |
|
90 {EKeySpace, EStdKeySpace, Key_Space}, |
|
91 {EKeyDelete, EStdKeyDelete, Key_Delete}, |
|
92 {EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq}, |
|
93 {EKeyPause, EStdKeyPause, Key_Pause}, |
|
94 {EKeyHome, EStdKeyHome, Key_Home}, |
|
95 {EKeyEnd, EStdKeyEnd, Key_End}, |
|
96 {EKeyPageUp, EStdKeyPageUp, Key_PageUp}, |
|
97 {EKeyPageDown, EStdKeyPageDown, Key_PageDown}, |
|
98 {EKeyInsert, EStdKeyInsert, Key_Insert}, |
|
99 {EKeyLeftArrow, EStdKeyLeftArrow, Key_Left}, |
|
100 {EKeyRightArrow, EStdKeyRightArrow, Key_Right}, |
|
101 {EKeyUpArrow, EStdKeyUpArrow, Key_Up}, |
|
102 {EKeyDownArrow, EStdKeyDownArrow, Key_Down}, |
|
103 {EKeyLeftShift, EStdKeyLeftShift, Key_Shift}, |
|
104 {EKeyRightShift, EStdKeyRightShift, Key_Shift}, |
|
105 {EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt}, |
|
106 {EKeyRightAlt, EStdKeyRightAlt, Key_AltGr}, |
|
107 {EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control}, |
|
108 {EKeyRightCtrl, EStdKeyRightCtrl, Key_Control}, |
|
109 {EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L}, |
|
110 {EKeyRightFunc, EStdKeyRightFunc, Key_Super_R}, |
|
111 {EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock}, |
|
112 {EKeyNumLock, EStdKeyNumLock, Key_NumLock}, |
|
113 {EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock}, |
|
114 {EKeyF1, EStdKeyF1, Key_F1}, |
|
115 {EKeyF2, EStdKeyF2, Key_F2}, |
|
116 {EKeyF3, EStdKeyF3, Key_F3}, |
|
117 {EKeyF4, EStdKeyF4, Key_F4}, |
|
118 {EKeyF5, EStdKeyF5, Key_F5}, |
|
119 {EKeyF6, EStdKeyF6, Key_F6}, |
|
120 {EKeyF7, EStdKeyF7, Key_F7}, |
|
121 {EKeyF8, EStdKeyF8, Key_F8}, |
|
122 {EKeyF9, EStdKeyF9, Key_F9}, |
|
123 {EKeyF10, EStdKeyF10, Key_F10}, |
|
124 {EKeyF11, EStdKeyF11, Key_F11}, |
|
125 {EKeyF12, EStdKeyF12, Key_F12}, |
|
126 {EKeyF13, EStdKeyF13, Key_F13}, |
|
127 {EKeyF14, EStdKeyF14, Key_F14}, |
|
128 {EKeyF15, EStdKeyF15, Key_F15}, |
|
129 {EKeyF16, EStdKeyF16, Key_F16}, |
|
130 {EKeyF17, EStdKeyF17, Key_F17}, |
|
131 {EKeyF18, EStdKeyF18, Key_F18}, |
|
132 {EKeyF19, EStdKeyF19, Key_F19}, |
|
133 {EKeyF20, EStdKeyF20, Key_F20}, |
|
134 {EKeyF21, EStdKeyF21, Key_F21}, |
|
135 {EKeyF22, EStdKeyF22, Key_F22}, |
|
136 {EKeyF23, EStdKeyF23, Key_F23}, |
|
137 {EKeyF24, EStdKeyF24, Key_F24}, |
|
138 {EKeyOff, EStdKeyOff, Key_PowerOff}, |
|
139 // {EKeyMenu, EStdKeyMenu, Key_Menu}, // Menu is EKeyApplication0 |
|
140 {EKeyHelp, EStdKeyHelp, Key_Help}, |
|
141 {EKeyDial, EStdKeyDial, Key_Call}, |
|
142 {EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp}, |
|
143 {EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown}, |
|
144 {EKeyDevice0, EStdKeyDevice0, Key_Context1}, // Found by manual testing. |
|
145 {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing. |
|
146 {EKeyDevice3, EStdKeyDevice3, Key_Select}, |
|
147 // {EKeyDevice7, EStdKeyDevice7, Key_Camera}, //not supported by qt yet |
|
148 {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing. |
|
149 {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing. |
|
150 {EKeyApplication2, EStdKeyApplication2, Key_MediaPlay}, // Found by manual testing. |
|
151 {EKeyApplication3, EStdKeyApplication3, Key_MediaStop}, // Found by manual testing. |
|
152 {EKeyApplication4, EStdKeyApplication4, Key_MediaNext}, // Found by manual testing. |
|
153 {EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious}, // Found by manual testing. |
|
154 {EKeyApplication6, EStdKeyApplication6, Key_Launch6}, |
|
155 {EKeyApplication7, EStdKeyApplication7, Key_Launch7}, |
|
156 {EKeyApplication8, EStdKeyApplication8, Key_Launch8}, |
|
157 {EKeyApplication9, EStdKeyApplication9, Key_Launch9}, |
|
158 {EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA}, |
|
159 {EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB}, |
|
160 {EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC}, |
|
161 {EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD}, |
|
162 {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE}, |
|
163 {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF}, |
|
164 // {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, //not supported by qt yet |
|
165 {EKeyYes, EStdKeyYes, Key_Yes}, |
|
166 {EKeyNo, EStdKeyNo, Key_No}, |
|
167 {TKeyCode(0), TStdScanCode(0), Qt::Key(0)} |
|
168 }; |
|
169 |
|
170 int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key) |
|
171 { |
|
172 int res = Qt::Key_unknown; |
|
173 for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { |
|
174 if (keyMapping[i].s60KeyCode == s60key) { |
|
175 res = keyMapping[i].qtKey; |
|
176 break; |
|
177 } |
|
178 } |
|
179 return res; |
|
180 } |
|
181 |
|
182 int QKeyMapperPrivate::mapS60ScanCodesToQt(TUint s60scanCode) |
|
183 { |
|
184 int res = Qt::Key_unknown; |
|
185 for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { |
|
186 if (keyMapping[i].s60ScanCode == s60scanCode) { |
|
187 res = keyMapping[i].qtKey; |
|
188 break; |
|
189 } |
|
190 } |
|
191 return res; |
|
192 } |
|
193 |
|
194 int QKeyMapperPrivate::mapQtToS60Key(int qtKey) |
|
195 { |
|
196 int res = KErrUnknown; |
|
197 for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { |
|
198 if (keyMapping[i].qtKey == qtKey) { |
|
199 res = keyMapping[i].s60KeyCode; |
|
200 break; |
|
201 } |
|
202 } |
|
203 return res; |
|
204 } |
|
205 |
|
206 int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey) |
|
207 { |
|
208 int res = KErrUnknown; |
|
209 for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { |
|
210 if (keyMapping[i].qtKey == qtKey) { |
|
211 res = keyMapping[i].s60ScanCode; |
|
212 break; |
|
213 } |
|
214 } |
|
215 return res; |
|
216 } |
|
217 QT_END_NAMESPACE |