72 // Symbian doesn't actually use modifiers, but gives us the character code directly. |
71 // Symbian doesn't actually use modifiers, but gives us the character code directly. |
73 |
72 |
74 return QString(QChar(keySym)); |
73 return QString(QChar(keySym)); |
75 } |
74 } |
76 |
75 |
77 void QKeyMapperPrivate::fillKeyMap() |
76 #include <e32keys.h> |
78 { |
77 struct KeyMapping{ |
79 using namespace Qt; |
78 TKeyCode s60KeyCode; |
80 static const struct { |
79 TStdScanCode s60ScanCode; |
81 TUint s60Key; |
80 Qt::Key qtKey; |
82 int qtKey; |
81 }; |
83 } map[] = { |
82 |
84 {EKeyBell, Key_unknown}, |
83 using namespace Qt; |
85 {EKeyBackspace, Key_Backspace}, |
84 |
86 {EKeyTab, Key_Tab}, |
85 static const KeyMapping keyMapping[] = { |
87 {EKeyLineFeed, Key_unknown}, |
86 {EKeyBackspace, EStdKeyBackspace, Key_Backspace}, |
88 {EKeyVerticalTab, Key_unknown}, |
87 {EKeyTab, EStdKeyTab, Key_Tab}, |
89 {EKeyFormFeed, Key_unknown}, |
88 {EKeyEnter, EStdKeyEnter, Key_Enter}, |
90 {EKeyEnter, Key_Enter}, |
89 {EKeyEscape, EStdKeyEscape, Key_Escape}, |
91 {EKeyEscape, Key_Escape}, |
90 {EKeySpace, EStdKeySpace, Key_Space}, |
92 {EKeySpace, Key_Space}, |
91 {EKeyDelete, EStdKeyDelete, Key_Delete}, |
93 {EKeyDelete, Key_Delete}, |
92 {EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq}, |
94 {EKeyPrintScreen, Key_SysReq}, |
93 {EKeyPause, EStdKeyPause, Key_Pause}, |
95 {EKeyPause, Key_Pause}, |
94 {EKeyHome, EStdKeyHome, Key_Home}, |
96 {EKeyHome, Key_Home}, |
95 {EKeyEnd, EStdKeyEnd, Key_End}, |
97 {EKeyEnd, Key_End}, |
96 {EKeyPageUp, EStdKeyPageUp, Key_PageUp}, |
98 {EKeyPageUp, Key_PageUp}, |
97 {EKeyPageDown, EStdKeyPageDown, Key_PageDown}, |
99 {EKeyPageDown, Key_PageDown}, |
98 {EKeyInsert, EStdKeyInsert, Key_Insert}, |
100 {EKeyInsert, Key_Insert}, |
99 {EKeyLeftArrow, EStdKeyLeftArrow, Key_Left}, |
101 {EKeyLeftArrow, Key_Left}, |
100 {EKeyRightArrow, EStdKeyRightArrow, Key_Right}, |
102 {EKeyRightArrow, Key_Right}, |
101 {EKeyUpArrow, EStdKeyUpArrow, Key_Up}, |
103 {EKeyUpArrow, Key_Up}, |
102 {EKeyDownArrow, EStdKeyDownArrow, Key_Down}, |
104 {EKeyDownArrow, Key_Down}, |
103 {EKeyLeftShift, EStdKeyLeftShift, Key_Shift}, |
105 {EKeyLeftShift, Key_Shift}, |
104 {EKeyRightShift, EStdKeyRightShift, Key_Shift}, |
106 {EKeyRightShift, Key_Shift}, |
105 {EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt}, |
107 {EKeyLeftAlt, Key_Alt}, |
106 {EKeyRightAlt, EStdKeyRightAlt, Key_AltGr}, |
108 {EKeyRightAlt, Key_AltGr}, |
107 {EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control}, |
109 {EKeyLeftCtrl, Key_Control}, |
108 {EKeyRightCtrl, EStdKeyRightCtrl, Key_Control}, |
110 {EKeyRightCtrl, Key_Control}, |
109 {EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L}, |
111 {EKeyLeftFunc, Key_Super_L}, |
110 {EKeyRightFunc, EStdKeyRightFunc, Key_Super_R}, |
112 {EKeyRightFunc, Key_Super_R}, |
111 {EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock}, |
113 {EKeyCapsLock, Key_CapsLock}, |
112 {EKeyNumLock, EStdKeyNumLock, Key_NumLock}, |
114 {EKeyNumLock, Key_NumLock}, |
113 {EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock}, |
115 {EKeyScrollLock, Key_ScrollLock}, |
114 {EKeyF1, EStdKeyF1, Key_F1}, |
116 {EKeyF1, Key_F1}, |
115 {EKeyF2, EStdKeyF2, Key_F2}, |
117 {EKeyF2, Key_F2}, |
116 {EKeyF3, EStdKeyF3, Key_F3}, |
118 {EKeyF3, Key_F3}, |
117 {EKeyF4, EStdKeyF4, Key_F4}, |
119 {EKeyF4, Key_F4}, |
118 {EKeyF5, EStdKeyF5, Key_F5}, |
120 {EKeyF5, Key_F5}, |
119 {EKeyF6, EStdKeyF6, Key_F6}, |
121 {EKeyF6, Key_F6}, |
120 {EKeyF7, EStdKeyF7, Key_F7}, |
122 {EKeyF7, Key_F7}, |
121 {EKeyF8, EStdKeyF8, Key_F8}, |
123 {EKeyF8, Key_F8}, |
122 {EKeyF9, EStdKeyF9, Key_F9}, |
124 {EKeyF9, Key_F9}, |
123 {EKeyF10, EStdKeyF10, Key_F10}, |
125 {EKeyF10, Key_F10}, |
124 {EKeyF11, EStdKeyF11, Key_F11}, |
126 {EKeyF11, Key_F11}, |
125 {EKeyF12, EStdKeyF12, Key_F12}, |
127 {EKeyF12, Key_F12}, |
126 {EKeyF13, EStdKeyF13, Key_F13}, |
128 {EKeyF13, Key_F13}, |
127 {EKeyF14, EStdKeyF14, Key_F14}, |
129 {EKeyF14, Key_F14}, |
128 {EKeyF15, EStdKeyF15, Key_F15}, |
130 {EKeyF15, Key_F15}, |
129 {EKeyF16, EStdKeyF16, Key_F16}, |
131 {EKeyF16, Key_F16}, |
130 {EKeyF17, EStdKeyF17, Key_F17}, |
132 {EKeyF17, Key_F17}, |
131 {EKeyF18, EStdKeyF18, Key_F18}, |
133 {EKeyF18, Key_F18}, |
132 {EKeyF19, EStdKeyF19, Key_F19}, |
134 {EKeyF19, Key_F19}, |
133 {EKeyF20, EStdKeyF20, Key_F20}, |
135 {EKeyF20, Key_F20}, |
134 {EKeyF21, EStdKeyF21, Key_F21}, |
136 {EKeyF21, Key_F21}, |
135 {EKeyF22, EStdKeyF22, Key_F22}, |
137 {EKeyF22, Key_F22}, |
136 {EKeyF23, EStdKeyF23, Key_F23}, |
138 {EKeyF23, Key_F23}, |
137 {EKeyF24, EStdKeyF24, Key_F24}, |
139 {EKeyF24, Key_F24}, |
138 {EKeyOff, EStdKeyOff, Key_PowerOff}, |
140 {EKeyOff, Key_unknown}, |
139 // {EKeyMenu, EStdKeyMenu, Key_Menu}, // Menu is EKeyApplication0 |
141 {EKeyIncContrast, Key_unknown}, |
140 {EKeyHelp, EStdKeyHelp, Key_Help}, |
142 {EKeyDecContrast, Key_unknown}, |
141 {EKeyDial, EStdKeyDial, Key_Call}, |
143 {EKeyBacklightOn, Key_unknown}, |
142 {EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp}, |
144 {EKeyBacklightOff, Key_unknown}, |
143 {EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown}, |
145 {EKeyBacklightToggle, Key_unknown}, |
144 {EKeyDevice0, EStdKeyDevice0, Key_Context1}, // Found by manual testing. |
146 {EKeySliderDown, Key_unknown}, |
145 {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing. |
147 {EKeySliderUp, Key_unknown}, |
146 {EKeyDevice3, EStdKeyDevice3, Key_Select}, |
148 {EKeyMenu, Key_Menu}, |
147 // {EKeyDevice7, EStdKeyDevice7, Key_Camera}, //not supported by qt yet |
149 {EKeyDictaphonePlay, Key_unknown}, |
148 {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing. |
150 {EKeyDictaphoneStop, Key_unknown}, |
149 {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing. |
151 {EKeyDictaphoneRecord, Key_unknown}, |
150 {EKeyApplication2, EStdKeyApplication2, Key_MediaPlay}, // Found by manual testing. |
152 {EKeyHelp, Key_unknown}, |
151 {EKeyApplication3, EStdKeyApplication3, Key_MediaStop}, // Found by manual testing. |
153 {EKeyDial, Key_Call}, |
152 {EKeyApplication4, EStdKeyApplication4, Key_MediaNext}, // Found by manual testing. |
154 {EKeyScreenDimension0, Key_unknown}, |
153 {EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious}, // Found by manual testing. |
155 {EKeyScreenDimension1, Key_unknown}, |
154 {EKeyApplication6, EStdKeyApplication6, Key_Launch6}, |
156 {EKeyScreenDimension2, Key_unknown}, |
155 {EKeyApplication7, EStdKeyApplication7, Key_Launch7}, |
157 {EKeyScreenDimension3, Key_unknown}, |
156 {EKeyApplication8, EStdKeyApplication8, Key_Launch8}, |
158 {EKeyIncVolume, Key_unknown}, |
157 {EKeyApplication9, EStdKeyApplication9, Key_Launch9}, |
159 {EKeyDecVolume, Key_unknown}, |
158 {EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA}, |
160 {EKeyDevice0, Key_Context1}, // Found by manual testing, left softkey. |
159 {EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB}, |
161 {EKeyDevice1, Key_Context2}, // Found by manual testing. |
160 {EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC}, |
162 {EKeyDevice2, Key_unknown}, |
161 {EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD}, |
163 {EKeyDevice3, Key_Select}, // Found by manual testing. |
162 {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE}, |
164 {EKeyDevice4, Key_unknown}, |
163 {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF}, |
165 {EKeyDevice5, Key_unknown}, |
164 // {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, //not supported by qt yet |
166 {EKeyDevice6, Key_unknown}, |
165 {EKeyYes, EStdKeyYes, Key_Yes}, |
167 {EKeyDevice7, Key_unknown}, |
166 {EKeyNo, EStdKeyNo, Key_No}, |
168 {EKeyDevice8, Key_unknown}, |
167 {TKeyCode(0), TStdScanCode(0), Qt::Key(0)} |
169 {EKeyDevice9, Key_unknown}, |
168 }; |
170 {EKeyDeviceA, Key_unknown}, |
|
171 {EKeyDeviceB, Key_unknown}, |
|
172 {EKeyDeviceC, Key_unknown}, |
|
173 {EKeyDeviceD, Key_unknown}, |
|
174 {EKeyDeviceE, Key_unknown}, |
|
175 {EKeyDeviceF, Key_unknown}, |
|
176 {EKeyApplication0, Key_Launch0}, |
|
177 {EKeyApplication1, Key_Launch1}, |
|
178 {EKeyApplication2, Key_Launch2}, |
|
179 {EKeyApplication3, Key_Launch3}, |
|
180 {EKeyApplication4, Key_Launch4}, |
|
181 {EKeyApplication5, Key_Launch5}, |
|
182 {EKeyApplication6, Key_Launch6}, |
|
183 {EKeyApplication7, Key_Launch7}, |
|
184 {EKeyApplication8, Key_Launch8}, |
|
185 {EKeyApplication9, Key_Launch9}, |
|
186 {EKeyApplicationA, Key_LaunchA}, |
|
187 {EKeyApplicationB, Key_LaunchB}, |
|
188 {EKeyApplicationC, Key_LaunchC}, |
|
189 {EKeyApplicationD, Key_LaunchD}, |
|
190 {EKeyApplicationE, Key_LaunchE}, |
|
191 {EKeyApplicationF, Key_LaunchF}, |
|
192 {EKeyYes, Key_Yes}, |
|
193 {EKeyNo, Key_No}, |
|
194 {EKeyIncBrightness, Key_unknown}, |
|
195 {EKeyDecBrightness, Key_unknown}, |
|
196 {EKeyKeyboardExtend, Key_unknown}, |
|
197 {EKeyDevice10, Key_unknown}, |
|
198 {EKeyDevice11, Key_unknown}, |
|
199 {EKeyDevice12, Key_unknown}, |
|
200 {EKeyDevice13, Key_unknown}, |
|
201 {EKeyDevice14, Key_unknown}, |
|
202 {EKeyDevice15, Key_unknown}, |
|
203 {EKeyDevice16, Key_unknown}, |
|
204 {EKeyDevice17, Key_unknown}, |
|
205 {EKeyDevice18, Key_unknown}, |
|
206 {EKeyDevice19, Key_unknown}, |
|
207 {EKeyDevice1A, Key_unknown}, |
|
208 {EKeyDevice1B, Key_unknown}, |
|
209 {EKeyDevice1C, Key_unknown}, |
|
210 {EKeyDevice1D, Key_unknown}, |
|
211 {EKeyDevice1E, Key_unknown}, |
|
212 {EKeyDevice1F, Key_unknown}, |
|
213 {EKeyApplication10, Key_unknown}, |
|
214 {EKeyApplication11, Key_unknown}, |
|
215 {EKeyApplication12, Key_unknown}, |
|
216 {EKeyApplication13, Key_unknown}, |
|
217 {EKeyApplication14, Key_unknown}, |
|
218 {EKeyApplication15, Key_unknown}, |
|
219 {EKeyApplication16, Key_unknown}, |
|
220 {EKeyApplication17, Key_unknown}, |
|
221 {EKeyApplication18, Key_unknown}, |
|
222 {EKeyApplication19, Key_unknown}, |
|
223 {EKeyApplication1A, Key_unknown}, |
|
224 {EKeyApplication1B, Key_unknown}, |
|
225 {EKeyApplication1C, Key_unknown}, |
|
226 {EKeyApplication1D, Key_unknown}, |
|
227 {EKeyApplication1E, Key_unknown}, |
|
228 {EKeyApplication1F, Key_unknown} |
|
229 }; |
|
230 const int mapSize = int(sizeof(map)/sizeof(map[0])); |
|
231 s60ToQtKeyMap.reserve(mapSize + 5); // +5? docs: Ideally, slightly more than number of items |
|
232 for (int i = 0; i < mapSize; ++i) |
|
233 s60ToQtKeyMap.insert(map[i].s60Key, map[i].qtKey); |
|
234 } |
|
235 |
169 |
236 int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key) |
170 int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key) |
237 { |
171 { |
238 QHash<TUint, int>::const_iterator mapping; |
172 int res = Qt::Key_unknown; |
239 mapping = s60ToQtKeyMap.find(s60key); |
173 for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { |
240 if (mapping != s60ToQtKeyMap.end()) { |
174 if (keyMapping[i].s60KeyCode == s60key) { |
241 return *mapping; |
175 res = keyMapping[i].qtKey; |
242 } else { |
176 break; |
243 return Qt::Key_unknown; |
177 } |
244 } |
178 } |
245 } |
179 return res; |
246 |
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 } |
247 QT_END_NAMESPACE |
217 QT_END_NAMESPACE |