17 #ifndef GEPETTO_GUI_QT_OSG_KEYBOARD_HH__
18 #define GEPETTO_GUI_QT_OSG_KEYBOARD_HH__
21 #include <osgGA/GUIEventAdapter>
30 mKeyMap[Qt::Key_Escape] = osgGA::GUIEventAdapter::KEY_Escape;
31 mKeyMap[Qt::Key_Delete] = osgGA::GUIEventAdapter::KEY_Delete;
32 mKeyMap[Qt::Key_Home] = osgGA::GUIEventAdapter::KEY_Home;
33 mKeyMap[Qt::Key_Enter] = osgGA::GUIEventAdapter::KEY_KP_Enter;
34 mKeyMap[Qt::Key_End] = osgGA::GUIEventAdapter::KEY_End;
35 mKeyMap[Qt::Key_Return] = osgGA::GUIEventAdapter::KEY_Return;
36 mKeyMap[Qt::Key_PageUp] = osgGA::GUIEventAdapter::KEY_Page_Up;
37 mKeyMap[Qt::Key_PageDown] = osgGA::GUIEventAdapter::KEY_Page_Down;
38 mKeyMap[Qt::Key_Left] = osgGA::GUIEventAdapter::KEY_Left;
39 mKeyMap[Qt::Key_Right] = osgGA::GUIEventAdapter::KEY_Right;
40 mKeyMap[Qt::Key_Up] = osgGA::GUIEventAdapter::KEY_Up;
41 mKeyMap[Qt::Key_Down] = osgGA::GUIEventAdapter::KEY_Down;
42 mKeyMap[Qt::Key_Backspace] = osgGA::GUIEventAdapter::KEY_BackSpace;
43 mKeyMap[Qt::Key_Tab] = osgGA::GUIEventAdapter::KEY_Tab;
44 mKeyMap[Qt::Key_Space] = osgGA::GUIEventAdapter::KEY_Space;
45 mKeyMap[Qt::Key_Delete] = osgGA::GUIEventAdapter::KEY_Delete;
46 mKeyMap[Qt::Key_Alt] = osgGA::GUIEventAdapter::KEY_Alt_L;
47 mKeyMap[Qt::Key_Shift] = osgGA::GUIEventAdapter::KEY_Shift_L;
48 mKeyMap[Qt::Key_Control] = osgGA::GUIEventAdapter::KEY_Control_L;
49 mKeyMap[Qt::Key_Meta] = osgGA::GUIEventAdapter::KEY_Meta_L;
51 mKeyMap[Qt::Key_F1] = osgGA::GUIEventAdapter::KEY_F1;
52 mKeyMap[Qt::Key_F2] = osgGA::GUIEventAdapter::KEY_F2;
53 mKeyMap[Qt::Key_F3] = osgGA::GUIEventAdapter::KEY_F3;
54 mKeyMap[Qt::Key_F4] = osgGA::GUIEventAdapter::KEY_F4;
55 mKeyMap[Qt::Key_F5] = osgGA::GUIEventAdapter::KEY_F5;
56 mKeyMap[Qt::Key_F6] = osgGA::GUIEventAdapter::KEY_F6;
57 mKeyMap[Qt::Key_F7] = osgGA::GUIEventAdapter::KEY_F7;
58 mKeyMap[Qt::Key_F8] = osgGA::GUIEventAdapter::KEY_F8;
59 mKeyMap[Qt::Key_F9] = osgGA::GUIEventAdapter::KEY_F9;
60 mKeyMap[Qt::Key_F10] = osgGA::GUIEventAdapter::KEY_F10;
61 mKeyMap[Qt::Key_F11] = osgGA::GUIEventAdapter::KEY_F11;
62 mKeyMap[Qt::Key_F12] = osgGA::GUIEventAdapter::KEY_F12;
63 mKeyMap[Qt::Key_F13] = osgGA::GUIEventAdapter::KEY_F13;
64 mKeyMap[Qt::Key_F14] = osgGA::GUIEventAdapter::KEY_F14;
65 mKeyMap[Qt::Key_F15] = osgGA::GUIEventAdapter::KEY_F15;
66 mKeyMap[Qt::Key_F16] = osgGA::GUIEventAdapter::KEY_F16;
67 mKeyMap[Qt::Key_F17] = osgGA::GUIEventAdapter::KEY_F17;
68 mKeyMap[Qt::Key_F18] = osgGA::GUIEventAdapter::KEY_F18;
69 mKeyMap[Qt::Key_F19] = osgGA::GUIEventAdapter::KEY_F19;
70 mKeyMap[Qt::Key_F20] = osgGA::GUIEventAdapter::KEY_F20;
72 mKeyMap[Qt::Key_hyphen] =
'-';
73 mKeyMap[Qt::Key_Equal] =
'=';
75 mKeyMap[Qt::Key_division] = osgGA::GUIEventAdapter::KEY_KP_Divide;
76 mKeyMap[Qt::Key_multiply] = osgGA::GUIEventAdapter::KEY_KP_Multiply;
77 mKeyMap[Qt::Key_Minus] =
'-';
78 mKeyMap[Qt::Key_Plus] =
'+';
89 mKeyMap[Qt::Key_Insert] = osgGA::GUIEventAdapter::KEY_KP_Insert;
92 modKeyMap[osgGA::GUIEventAdapter::MODKEY_CTRL] = Qt::ControlModifier;
98 KeyMap::iterator itr = mKeyMap.find((Qt::Key)event->key());
99 if (itr == mKeyMap.end()) {
100 return int(*(event->text().toLatin1().data()));
106 if (key == 0)
return NULL;
107 for (KeyMap::iterator itr = mKeyMap.begin(); itr != mKeyMap.end(); ++itr) {
108 if (itr->second == key)
109 return new QKeyEvent(QEvent::KeyPress, itr->first, 0);
115 if (modMask == 0)
return NULL;
116 ModKeyMap::const_iterator it = modKeyMap.find(modMask);
117 if (it != modKeyMap.end())
118 return new QKeyEvent(QEvent::KeyPress, it->second, 0);
123 ModKeyMap::const_iterator it = modKeyMap.find(modMask);
124 if (it != modKeyMap.end())
return it->second;
125 return Qt::NoModifier;
129 typedef std::map<Qt::Key, int> KeyMap;
132 typedef std::map<int, Qt::KeyboardModifiers> ModKeyMap;
Definition: qt-osg-keyboard.hh:27
QKeyEvent * remapModKey(int modMask)
Definition: qt-osg-keyboard.hh:114
QtOsgKeyboard()
Definition: qt-osg-keyboard.hh:29
QKeyEvent * remapKey(int key)
Definition: qt-osg-keyboard.hh:105
int remapKey(QKeyEvent *event)
Definition: qt-osg-keyboard.hh:97
Qt::KeyboardModifiers getQtModKey(int modMask)
Definition: qt-osg-keyboard.hh:122
~QtOsgKeyboard()
Definition: qt-osg-keyboard.hh:95
Definition: action-search-bar.hh:27