summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorwasila <qt-info@nokia.com>2010-02-25 15:14:37 (GMT)
committeraxis <qt-info@nokia.com>2010-02-25 16:03:47 (GMT)
commit133f853e569494303fc432f6c6009dd44c504446 (patch)
treeb6adaab24b1b8aa859ae604b9c79461f991399e5 /src/gui
parent1b9f273c3d0e10cb14a35a9a058b379b8777b5d8 (diff)
downloadQt-133f853e569494303fc432f6c6009dd44c504446.zip
Qt-133f853e569494303fc432f6c6009dd44c504446.tar.gz
Qt-133f853e569494303fc432f6c6009dd44c504446.tar.bz2
Enabled Qt key events to work also when native key code is missing.
If it is missing we base the event on the scan code instead. RevBy: Alessandro Portale Signed-off-by: axis <qt-info@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp4
-rw-r--r--src/gui/kernel/qkeymapper_p.h16
-rw-r--r--src/gui/kernel/qkeymapper_s60.cpp285
3 files changed, 141 insertions, 164 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index fdbbeb2..2eecd56 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -597,7 +597,9 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod
TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode,
keyEvent.iCode);
int keyCode;
- if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
+ if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used
+ keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode);
+ } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
// Normal characters keys.
keyCode = s60Keysym;
} else {
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 09c36c88..706ee23 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -137,12 +137,21 @@ struct QXCoreDesc {
KeySym lock_meaning;
};
+#elif defined(Q_OS_SYMBIAN)
+#include <e32keys.h>
+class KeyMapping{
+public:
+ KeyMapping(TKeyCode aS60KeyCode, TStdScanCode aS60ScanCode, Qt::Key aQtKey) : s60KeyCode(aS60KeyCode), s60ScanCode(aS60ScanCode), qtKey(aQtKey) { };
+ TKeyCode s60KeyCode;
+ TStdScanCode s60ScanCode;
+ Qt::Key qtKey;
+};
#endif
struct KeyboardLayoutItem;
typedef struct __TISInputSource * TISInputSourceRef;
class QKeyEvent;
-class QKeyMapperPrivate : public QObjectPrivate
+class Q_GUI_EXPORT QKeyMapperPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QKeyMapper)
public:
@@ -208,11 +217,14 @@ public:
#elif defined(Q_WS_QWS)
#elif defined(Q_OS_SYMBIAN)
private:
- QHash<TUint, int> s60ToQtKeyMap;
+ QList<KeyMapping> keyMapping;
void fillKeyMap();
public:
QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
int mapS60KeyToQt(TUint s60key);
+ int mapS60ScanCodesToQt(TUint s60key);
+ int mapQtToS60Key(int qtKey);
+ int mapQtToS60ScanCodes(int qtKey);
#endif
};
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp
index 6e21420..039be14 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/gui/kernel/qkeymapper_s60.cpp
@@ -77,171 +77,134 @@ QString QKeyMapperPrivate::translateKeyEvent(int keySym, Qt::KeyboardModifiers /
void QKeyMapperPrivate::fillKeyMap()
{
using namespace Qt;
- static const struct {
- TUint s60Key;
- int qtKey;
- } map[] = {
- {EKeyBell, Key_unknown},
- {EKeyBackspace, Key_Backspace},
- {EKeyTab, Key_Tab},
- {EKeyLineFeed, Key_unknown},
- {EKeyVerticalTab, Key_unknown},
- {EKeyFormFeed, Key_unknown},
- {EKeyEnter, Key_Enter},
- {EKeyEscape, Key_Escape},
- {EKeySpace, Key_Space},
- {EKeyDelete, Key_Delete},
- {EKeyPrintScreen, Key_SysReq},
- {EKeyPause, Key_Pause},
- {EKeyHome, Key_Home},
- {EKeyEnd, Key_End},
- {EKeyPageUp, Key_PageUp},
- {EKeyPageDown, Key_PageDown},
- {EKeyInsert, Key_Insert},
- {EKeyLeftArrow, Key_Left},
- {EKeyRightArrow, Key_Right},
- {EKeyUpArrow, Key_Up},
- {EKeyDownArrow, Key_Down},
- {EKeyLeftShift, Key_Shift},
- {EKeyRightShift, Key_Shift},
- {EKeyLeftAlt, Key_Alt},
- {EKeyRightAlt, Key_AltGr},
- {EKeyLeftCtrl, Key_Control},
- {EKeyRightCtrl, Key_Control},
- {EKeyLeftFunc, Key_Super_L},
- {EKeyRightFunc, Key_Super_R},
- {EKeyCapsLock, Key_CapsLock},
- {EKeyNumLock, Key_NumLock},
- {EKeyScrollLock, Key_ScrollLock},
- {EKeyF1, Key_F1},
- {EKeyF2, Key_F2},
- {EKeyF3, Key_F3},
- {EKeyF4, Key_F4},
- {EKeyF5, Key_F5},
- {EKeyF6, Key_F6},
- {EKeyF7, Key_F7},
- {EKeyF8, Key_F8},
- {EKeyF9, Key_F9},
- {EKeyF10, Key_F10},
- {EKeyF11, Key_F11},
- {EKeyF12, Key_F12},
- {EKeyF13, Key_F13},
- {EKeyF14, Key_F14},
- {EKeyF15, Key_F15},
- {EKeyF16, Key_F16},
- {EKeyF17, Key_F17},
- {EKeyF18, Key_F18},
- {EKeyF19, Key_F19},
- {EKeyF20, Key_F20},
- {EKeyF21, Key_F21},
- {EKeyF22, Key_F22},
- {EKeyF23, Key_F23},
- {EKeyF24, Key_F24},
- {EKeyOff, Key_unknown},
- {EKeyIncContrast, Key_unknown},
- {EKeyDecContrast, Key_unknown},
- {EKeyBacklightOn, Key_unknown},
- {EKeyBacklightOff, Key_unknown},
- {EKeyBacklightToggle, Key_unknown},
- {EKeySliderDown, Key_unknown},
- {EKeySliderUp, Key_unknown},
- {EKeyMenu, Key_Menu},
- {EKeyDictaphonePlay, Key_unknown},
- {EKeyDictaphoneStop, Key_unknown},
- {EKeyDictaphoneRecord, Key_unknown},
- {EKeyHelp, Key_unknown},
- {EKeyDial, Key_Call},
- {EKeyScreenDimension0, Key_unknown},
- {EKeyScreenDimension1, Key_unknown},
- {EKeyScreenDimension2, Key_unknown},
- {EKeyScreenDimension3, Key_unknown},
- {EKeyIncVolume, Key_unknown},
- {EKeyDecVolume, Key_unknown},
- {EKeyDevice0, Key_Context1}, // Found by manual testing, left softkey.
- {EKeyDevice1, Key_Context2}, // Found by manual testing.
- {EKeyDevice2, Key_unknown},
- {EKeyDevice3, Key_Select}, // Found by manual testing.
- {EKeyDevice4, Key_unknown},
- {EKeyDevice5, Key_unknown},
- {EKeyDevice6, Key_unknown},
- {EKeyDevice7, Key_unknown},
- {EKeyDevice8, Key_unknown},
- {EKeyDevice9, Key_unknown},
- {EKeyDeviceA, Key_unknown},
- {EKeyDeviceB, Key_unknown},
- {EKeyDeviceC, Key_unknown},
- {EKeyDeviceD, Key_unknown},
- {EKeyDeviceE, Key_unknown},
- {EKeyDeviceF, Key_unknown},
- {EKeyApplication0, Key_Launch0},
- {EKeyApplication1, Key_Launch1},
- {EKeyApplication2, Key_Launch2},
- {EKeyApplication3, Key_Launch3},
- {EKeyApplication4, Key_Launch4},
- {EKeyApplication5, Key_Launch5},
- {EKeyApplication6, Key_Launch6},
- {EKeyApplication7, Key_Launch7},
- {EKeyApplication8, Key_Launch8},
- {EKeyApplication9, Key_Launch9},
- {EKeyApplicationA, Key_LaunchA},
- {EKeyApplicationB, Key_LaunchB},
- {EKeyApplicationC, Key_LaunchC},
- {EKeyApplicationD, Key_LaunchD},
- {EKeyApplicationE, Key_LaunchE},
- {EKeyApplicationF, Key_LaunchF},
- {EKeyYes, Key_Yes},
- {EKeyNo, Key_No},
- {EKeyIncBrightness, Key_unknown},
- {EKeyDecBrightness, Key_unknown},
- {EKeyKeyboardExtend, Key_unknown},
- {EKeyDevice10, Key_unknown},
- {EKeyDevice11, Key_unknown},
- {EKeyDevice12, Key_unknown},
- {EKeyDevice13, Key_unknown},
- {EKeyDevice14, Key_unknown},
- {EKeyDevice15, Key_unknown},
- {EKeyDevice16, Key_unknown},
- {EKeyDevice17, Key_unknown},
- {EKeyDevice18, Key_unknown},
- {EKeyDevice19, Key_unknown},
- {EKeyDevice1A, Key_unknown},
- {EKeyDevice1B, Key_unknown},
- {EKeyDevice1C, Key_unknown},
- {EKeyDevice1D, Key_unknown},
- {EKeyDevice1E, Key_unknown},
- {EKeyDevice1F, Key_unknown},
- {EKeyApplication10, Key_unknown},
- {EKeyApplication11, Key_unknown},
- {EKeyApplication12, Key_unknown},
- {EKeyApplication13, Key_unknown},
- {EKeyApplication14, Key_unknown},
- {EKeyApplication15, Key_unknown},
- {EKeyApplication16, Key_unknown},
- {EKeyApplication17, Key_unknown},
- {EKeyApplication18, Key_unknown},
- {EKeyApplication19, Key_unknown},
- {EKeyApplication1A, Key_unknown},
- {EKeyApplication1B, Key_unknown},
- {EKeyApplication1C, Key_unknown},
- {EKeyApplication1D, Key_unknown},
- {EKeyApplication1E, Key_unknown},
- {EKeyApplication1F, Key_unknown}
- };
- const int mapSize = int(sizeof(map)/sizeof(map[0]));
- s60ToQtKeyMap.reserve(mapSize + 5); // +5? docs: Ideally, slightly more than number of items
- for (int i = 0; i < mapSize; ++i)
- s60ToQtKeyMap.insert(map[i].s60Key, map[i].qtKey);
+ keyMapping.append(KeyMapping(EKeyBackspace, EStdKeyBackspace, Key_Backspace));
+ keyMapping.append(KeyMapping(EKeyTab, EStdKeyTab, Key_Tab));
+ keyMapping.append(KeyMapping(EKeyEnter, EStdKeyEnter, Key_Enter));
+ keyMapping.append(KeyMapping(EKeyEscape, EStdKeyEscape, Key_Escape));
+ keyMapping.append(KeyMapping(EKeySpace, EStdKeySpace, Key_Space));
+ keyMapping.append(KeyMapping(EKeyDelete, EStdKeyDelete, Key_Delete));
+ keyMapping.append(KeyMapping(EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq));
+ keyMapping.append(KeyMapping(EKeyPause, EStdKeyPause, Key_Pause));
+ keyMapping.append(KeyMapping(EKeyHome, EStdKeyHome, Key_Home));
+ keyMapping.append(KeyMapping(EKeyEnd, EStdKeyEnd, Key_End));
+ keyMapping.append(KeyMapping(EKeyPageUp, EStdKeyPageUp, Key_PageUp));
+ keyMapping.append(KeyMapping(EKeyPageDown, EStdKeyPageDown, Key_PageDown));
+ keyMapping.append(KeyMapping(EKeyInsert, EStdKeyInsert, Key_Insert));
+ keyMapping.append(KeyMapping(EKeyLeftArrow, EStdKeyLeftArrow, Key_Left));
+ keyMapping.append(KeyMapping(EKeyRightArrow, EStdKeyRightArrow, Key_Right));
+ keyMapping.append(KeyMapping(EKeyUpArrow, EStdKeyUpArrow, Key_Up));
+ keyMapping.append(KeyMapping(EKeyDownArrow, EStdKeyDownArrow, Key_Down));
+ keyMapping.append(KeyMapping(EKeyLeftShift, EStdKeyLeftShift, Key_Shift));
+ keyMapping.append(KeyMapping(EKeyRightShift, EStdKeyRightShift, Key_Shift));
+ keyMapping.append(KeyMapping(EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt));
+ keyMapping.append(KeyMapping(EKeyRightAlt, EStdKeyRightAlt, Key_AltGr));
+ keyMapping.append(KeyMapping(EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control));
+ keyMapping.append(KeyMapping(EKeyRightCtrl, EStdKeyRightCtrl, Key_Control));
+ keyMapping.append(KeyMapping(EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L));
+ keyMapping.append(KeyMapping(EKeyRightFunc, EStdKeyRightFunc, Key_Super_R));
+ keyMapping.append(KeyMapping(EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock));
+ keyMapping.append(KeyMapping(EKeyNumLock, EStdKeyNumLock, Key_NumLock));
+ keyMapping.append(KeyMapping(EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock));
+ keyMapping.append(KeyMapping(EKeyF1, EStdKeyF1, Key_F1));
+ keyMapping.append(KeyMapping(EKeyF2, EStdKeyF2, Key_F2));
+ keyMapping.append(KeyMapping(EKeyF3, EStdKeyF3, Key_F3));
+ keyMapping.append(KeyMapping(EKeyF4, EStdKeyF4, Key_F4));
+ keyMapping.append(KeyMapping(EKeyF5, EStdKeyF5, Key_F5));
+ keyMapping.append(KeyMapping(EKeyF6, EStdKeyF6, Key_F6));
+ keyMapping.append(KeyMapping(EKeyF7, EStdKeyF7, Key_F7));
+ keyMapping.append(KeyMapping(EKeyF8, EStdKeyF8, Key_F8));
+ keyMapping.append(KeyMapping(EKeyF9, EStdKeyF9, Key_F9));
+ keyMapping.append(KeyMapping(EKeyF10, EStdKeyF10, Key_F10));
+ keyMapping.append(KeyMapping(EKeyF11, EStdKeyF11, Key_F11));
+ keyMapping.append(KeyMapping(EKeyF12, EStdKeyF12, Key_F12));
+ keyMapping.append(KeyMapping(EKeyF13, EStdKeyF13, Key_F13));
+ keyMapping.append(KeyMapping(EKeyF14, EStdKeyF14, Key_F14));
+ keyMapping.append(KeyMapping(EKeyF15, EStdKeyF15, Key_F15));
+ keyMapping.append(KeyMapping(EKeyF16, EStdKeyF16, Key_F16));
+ keyMapping.append(KeyMapping(EKeyF17, EStdKeyF17, Key_F17));
+ keyMapping.append(KeyMapping(EKeyF18, EStdKeyF18, Key_F18));
+ keyMapping.append(KeyMapping(EKeyF19, EStdKeyF19, Key_F19));
+ keyMapping.append(KeyMapping(EKeyF20, EStdKeyF20, Key_F20));
+ keyMapping.append(KeyMapping(EKeyF21, EStdKeyF21, Key_F21));
+ keyMapping.append(KeyMapping(EKeyF22, EStdKeyF22, Key_F22));
+ keyMapping.append(KeyMapping(EKeyF23, EStdKeyF23, Key_F23));
+ keyMapping.append(KeyMapping(EKeyF24, EStdKeyF24, Key_F24));
+ keyMapping.append(KeyMapping(EKeyOff, EStdKeyOff, Key_PowerOff));
+// keyMapping.append(KeyMapping(EKeyMenu, EStdKeyMenu, Key_Menu)); // Menu is EKeyApplication0
+ keyMapping.append(KeyMapping(EKeyHelp, EStdKeyHelp, Key_Help));
+ keyMapping.append(KeyMapping(EKeyDial, EStdKeyDial, Key_Call));
+ keyMapping.append(KeyMapping(EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp));
+ keyMapping.append(KeyMapping(EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown));
+ keyMapping.append(KeyMapping(EKeyDevice0, EStdKeyDevice0, Key_Context1)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyDevice1, EStdKeyDevice1, Key_Context2)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyDevice3, EStdKeyDevice3, Key_Select));
+// keyMapping.append(KeyMapping(EKeyDevice7, EStdKeyDevice7, Key_Camera)); //not supported by qt yet
+ keyMapping.append(KeyMapping(EKeyApplication0, EStdKeyApplication0, Key_Menu)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication1, EStdKeyApplication1, Key_Launch1)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication2, EStdKeyApplication2, Key_MediaPlay)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication3, EStdKeyApplication3, Key_MediaStop)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication4, EStdKeyApplication4, Key_MediaNext)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious)); // Found by manual testing.
+ keyMapping.append(KeyMapping(EKeyApplication6, EStdKeyApplication6, Key_Launch6));
+ keyMapping.append(KeyMapping(EKeyApplication7, EStdKeyApplication7, Key_Launch7));
+ keyMapping.append(KeyMapping(EKeyApplication8, EStdKeyApplication8, Key_Launch8));
+ keyMapping.append(KeyMapping(EKeyApplication9, EStdKeyApplication9, Key_Launch9));
+ keyMapping.append(KeyMapping(EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA));
+ keyMapping.append(KeyMapping(EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB));
+ keyMapping.append(KeyMapping(EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC));
+ keyMapping.append(KeyMapping(EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD));
+ keyMapping.append(KeyMapping(EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE));
+ keyMapping.append(KeyMapping(EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF));
+// keyMapping.append(KeyMapping(EKeyApplication19, EStdKeyApplication19, Key_CameraFocus)); //not supported by qt yet
+ keyMapping.append(KeyMapping(EKeyYes, EStdKeyYes, Key_Yes));
+ keyMapping.append(KeyMapping(EKeyNo, EStdKeyNo, Key_No));
}
int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key)
{
- QHash<TUint, int>::const_iterator mapping;
- mapping = s60ToQtKeyMap.find(s60key);
- if (mapping != s60ToQtKeyMap.end()) {
- return *mapping;
- } else {
- return Qt::Key_unknown;
- }
+ int res = Qt::Key_unknown;
+ for ( int i = 0, size = keyMapping.count(); i<size; i++){
+ if ( keyMapping[i].s60KeyCode == s60key){
+ res = keyMapping[i].qtKey;
+ break;
+ }
+ }
+ return res;
}
+int QKeyMapperPrivate::mapS60ScanCodesToQt(TUint s60scanCode)
+{
+ int res = Qt::Key_unknown;
+ for ( int i = 0, size = keyMapping.count(); i<size; i++){
+ if ( keyMapping[i].s60ScanCode == s60scanCode){
+ res = keyMapping[i].qtKey;
+ break;
+ }
+ }
+ return res;
+}
+
+int QKeyMapperPrivate::mapQtToS60Key(int qtKey)
+{
+ int res = KErrUnknown;
+ for ( int i = 0, size = keyMapping.count(); i<size; i++){
+ if ( keyMapping[i].qtKey == qtKey){
+ res = keyMapping[i].s60KeyCode;
+ break;
+ }
+ }
+ return res;
+}
+
+int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey)
+{
+ int res = KErrUnknown;
+ for ( int i = 0, size = keyMapping.count(); i<size; i++){
+ if ( keyMapping[i].qtKey == qtKey){
+ res = keyMapping[i].s60ScanCode;
+ break;
+ }
+ }
+ return res;
+}
QT_END_NAMESPACE