| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 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 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 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 | fillKeyMap();
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | QKeyMapperPrivate::~QKeyMapperPrivate()
|
|---|
| 53 | {
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent * /* e */)
|
|---|
| 57 | {
|
|---|
| 58 | QList<int> result;
|
|---|
| 59 | return result;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | void QKeyMapperPrivate::clearMappings()
|
|---|
| 63 | {
|
|---|
| 64 | // stub
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | QString QKeyMapperPrivate::translateKeyEvent(int keySym, Qt::KeyboardModifiers /* modifiers */)
|
|---|
| 68 | {
|
|---|
| 69 | if (keySym >= Qt::Key_Escape)
|
|---|
| 70 | return QString();
|
|---|
| 71 |
|
|---|
| 72 | // Symbian doesn't actually use modifiers, but gives us the character code directly.
|
|---|
| 73 |
|
|---|
| 74 | return QString(QChar(keySym));
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | void QKeyMapperPrivate::fillKeyMap()
|
|---|
| 78 | {
|
|---|
| 79 | using namespace Qt;
|
|---|
| 80 | static const struct {
|
|---|
| 81 | TUint s60Key;
|
|---|
| 82 | int qtKey;
|
|---|
| 83 | } map[] = {
|
|---|
| 84 | {EKeyBell, Key_unknown},
|
|---|
| 85 | {EKeyBackspace, Key_Backspace},
|
|---|
| 86 | {EKeyTab, Key_Tab},
|
|---|
| 87 | {EKeyLineFeed, Key_unknown},
|
|---|
| 88 | {EKeyVerticalTab, Key_unknown},
|
|---|
| 89 | {EKeyFormFeed, Key_unknown},
|
|---|
| 90 | {EKeyEnter, Key_Enter},
|
|---|
| 91 | {EKeyEscape, Key_Escape},
|
|---|
| 92 | {EKeySpace, Key_Space},
|
|---|
| 93 | {EKeyDelete, Key_Delete},
|
|---|
| 94 | {EKeyPrintScreen, Key_SysReq},
|
|---|
| 95 | {EKeyPause, Key_Pause},
|
|---|
| 96 | {EKeyHome, Key_Home},
|
|---|
| 97 | {EKeyEnd, Key_End},
|
|---|
| 98 | {EKeyPageUp, Key_PageUp},
|
|---|
| 99 | {EKeyPageDown, Key_PageDown},
|
|---|
| 100 | {EKeyInsert, Key_Insert},
|
|---|
| 101 | {EKeyLeftArrow, Key_Left},
|
|---|
| 102 | {EKeyRightArrow, Key_Right},
|
|---|
| 103 | {EKeyUpArrow, Key_Up},
|
|---|
| 104 | {EKeyDownArrow, Key_Down},
|
|---|
| 105 | {EKeyLeftShift, Key_Shift},
|
|---|
| 106 | {EKeyRightShift, Key_Shift},
|
|---|
| 107 | {EKeyLeftAlt, Key_Alt},
|
|---|
| 108 | {EKeyRightAlt, Key_AltGr},
|
|---|
| 109 | {EKeyLeftCtrl, Key_Control},
|
|---|
| 110 | {EKeyRightCtrl, Key_Control},
|
|---|
| 111 | {EKeyLeftFunc, Key_Super_L},
|
|---|
| 112 | {EKeyRightFunc, Key_Super_R},
|
|---|
| 113 | {EKeyCapsLock, Key_CapsLock},
|
|---|
| 114 | {EKeyNumLock, Key_NumLock},
|
|---|
| 115 | {EKeyScrollLock, Key_ScrollLock},
|
|---|
| 116 | {EKeyF1, Key_F1},
|
|---|
| 117 | {EKeyF2, Key_F2},
|
|---|
| 118 | {EKeyF3, Key_F3},
|
|---|
| 119 | {EKeyF4, Key_F4},
|
|---|
| 120 | {EKeyF5, Key_F5},
|
|---|
| 121 | {EKeyF6, Key_F6},
|
|---|
| 122 | {EKeyF7, Key_F7},
|
|---|
| 123 | {EKeyF8, Key_F8},
|
|---|
| 124 | {EKeyF9, Key_F9},
|
|---|
| 125 | {EKeyF10, Key_F10},
|
|---|
| 126 | {EKeyF11, Key_F11},
|
|---|
| 127 | {EKeyF12, Key_F12},
|
|---|
| 128 | {EKeyF13, Key_F13},
|
|---|
| 129 | {EKeyF14, Key_F14},
|
|---|
| 130 | {EKeyF15, Key_F15},
|
|---|
| 131 | {EKeyF16, Key_F16},
|
|---|
| 132 | {EKeyF17, Key_F17},
|
|---|
| 133 | {EKeyF18, Key_F18},
|
|---|
| 134 | {EKeyF19, Key_F19},
|
|---|
| 135 | {EKeyF20, Key_F20},
|
|---|
| 136 | {EKeyF21, Key_F21},
|
|---|
| 137 | {EKeyF22, Key_F22},
|
|---|
| 138 | {EKeyF23, Key_F23},
|
|---|
| 139 | {EKeyF24, Key_F24},
|
|---|
| 140 | {EKeyOff, Key_unknown},
|
|---|
| 141 | {EKeyIncContrast, Key_unknown},
|
|---|
| 142 | {EKeyDecContrast, Key_unknown},
|
|---|
| 143 | {EKeyBacklightOn, Key_unknown},
|
|---|
| 144 | {EKeyBacklightOff, Key_unknown},
|
|---|
| 145 | {EKeyBacklightToggle, Key_unknown},
|
|---|
| 146 | {EKeySliderDown, Key_unknown},
|
|---|
| 147 | {EKeySliderUp, Key_unknown},
|
|---|
| 148 | {EKeyMenu, Key_Menu},
|
|---|
| 149 | {EKeyDictaphonePlay, Key_unknown},
|
|---|
| 150 | {EKeyDictaphoneStop, Key_unknown},
|
|---|
| 151 | {EKeyDictaphoneRecord, Key_unknown},
|
|---|
| 152 | {EKeyHelp, Key_unknown},
|
|---|
| 153 | {EKeyDial, Key_Call},
|
|---|
| 154 | {EKeyScreenDimension0, Key_unknown},
|
|---|
| 155 | {EKeyScreenDimension1, Key_unknown},
|
|---|
| 156 | {EKeyScreenDimension2, Key_unknown},
|
|---|
| 157 | {EKeyScreenDimension3, Key_unknown},
|
|---|
| 158 | {EKeyIncVolume, Key_unknown},
|
|---|
| 159 | {EKeyDecVolume, Key_unknown},
|
|---|
| 160 | {EKeyDevice0, Key_Context1}, // Found by manual testing, left softkey.
|
|---|
| 161 | {EKeyDevice1, Key_Context2}, // Found by manual testing.
|
|---|
| 162 | {EKeyDevice2, Key_unknown},
|
|---|
| 163 | {EKeyDevice3, Key_Select}, // Found by manual testing.
|
|---|
| 164 | {EKeyDevice4, Key_unknown},
|
|---|
| 165 | {EKeyDevice5, Key_unknown},
|
|---|
| 166 | {EKeyDevice6, Key_unknown},
|
|---|
| 167 | {EKeyDevice7, Key_unknown},
|
|---|
| 168 | {EKeyDevice8, Key_unknown},
|
|---|
| 169 | {EKeyDevice9, Key_unknown},
|
|---|
| 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 |
|
|---|
| 236 | int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key)
|
|---|
| 237 | {
|
|---|
| 238 | QHash<TUint, int>::const_iterator mapping;
|
|---|
| 239 | mapping = s60ToQtKeyMap.find(s60key);
|
|---|
| 240 | if (mapping != s60ToQtKeyMap.end()) {
|
|---|
| 241 | return *mapping;
|
|---|
| 242 | } else {
|
|---|
| 243 | return Qt::Key_unknown;
|
|---|
| 244 | }
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | QT_END_NAMESPACE
|
|---|