Changeset 7862 in orxonox.OLD for trunk/src/lib/gui
- Timestamp:
- May 25, 2006, 5:34:44 PM (19 years ago)
- Location:
- trunk/src/lib/gui/qt_gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/qt_gui/gui_control.cc
r7861 r7862 28 28 29 29 #include <QtGui/QLayout> 30 #include <QtCore/QEvent> 31 #include <QtGui/QKeyEvent> 32 33 #include "sdlincl.h" 34 #include "lib/event/key_names.h" 35 30 36 #include "globals.h" 31 37 #include "debug.h" … … 79 85 this->bListening = false; 80 86 81 //connect(this, SIGNAL(released()), this, SLOT(listen()));87 connect(this, SIGNAL(released()), this, SLOT(listen())); 82 88 83 89 } … … 87 93 Saveable::load(); 88 94 this->setText(QString().fromStdString(this->value().getString())); 89 } 95 printf("%s\n", this->value().getString().c_str()); 96 } 97 90 98 void GuiControlInput::save() 91 99 { … … 97 105 bool GuiControlInput::event ( QEvent * e ) 98 106 { 99 100 if (!this->bListening) 101 return false; 102 103 104 107 if (!this->bListening || e->type() != QEvent::KeyPress) 108 return QPushButton::event(e); 109 110 111 this->releaseKeyboard(); 105 112 this->bListening = true; 113 if (e->type() == QEvent::KeyPress) 114 { 115 QKeyEvent* event = dynamic_cast<QKeyEvent*>(e); 116 117 int ev = QtKToSDLK(event->key()); 118 if (ev != -1) 119 { 120 this->setText(QString().fromStdString(SDLKToKeyname(ev))); 121 } 122 } 106 123 return true; 107 124 } … … 113 130 } 114 131 132 int GuiControlInput::QtKToSDLK(int key) 133 { 134 135 switch(key) 136 { 137 case Qt::Key_Backspace: return SDLK_BACKSPACE; 138 case Qt::Key_Tab: return SDLK_TAB; 139 case Qt::Key_Clear: return SDLK_CLEAR; 140 case Qt::Key_Return: return SDLK_RETURN; 141 case Qt::Key_Escape: return SDLK_ESCAPE; 142 case Qt::Key_Space: return SDLK_SPACE; 143 case Qt::Key_exclamdown: return SDLK_EXCLAIM; 144 case Qt::Key_QuoteDbl: return SDLK_QUOTEDBL; 145 //case Qt::Key_Hash: return SDLK_HASH; 146 case Qt::Key_Pause: return SDLK_PAUSE; 147 case Qt::Key_Dollar: return SDLK_DOLLAR; 148 case Qt::Key_Ampersand: return SDLK_AMPERSAND; 149 case Qt::Key_QuoteLeft: return SDLK_QUOTE; /// TODO check if correct 150 case Qt::Key_ParenLeft: return SDLK_LEFTPAREN; 151 case Qt::Key_ParenRight: return SDLK_RIGHTPAREN; 152 case Qt::Key_Asterisk: return SDLK_ASTERISK; 153 case Qt::Key_Plus: return SDLK_PLUS; 154 case Qt::Key_Comma: return SDLK_COMMA; 155 case Qt::Key_Minus: return SDLK_MINUS; 156 case Qt::Key_Period: return SDLK_PERIOD; 157 case Qt::Key_Slash: return SDLK_SLASH; 158 case Qt::Key_0: return SDLK_0; 159 case Qt::Key_1: return SDLK_1; 160 case Qt::Key_2: return SDLK_2; 161 case Qt::Key_3: return SDLK_3; 162 case Qt::Key_4: return SDLK_4; 163 case Qt::Key_5: return SDLK_5; 164 case Qt::Key_6: return SDLK_6; 165 case Qt::Key_7: return SDLK_7; 166 case Qt::Key_8: return SDLK_8; 167 case Qt::Key_9: return SDLK_9; 168 case Qt::Key_Colon: return SDLK_COLON; 169 case Qt::Key_Semicolon: return SDLK_SEMICOLON; 170 case Qt::Key_Less: return SDLK_LESS; 171 case Qt::Key_Equal: return SDLK_EQUALS; 172 case Qt::Key_Greater: return SDLK_GREATER; 173 case Qt::Key_Question: return SDLK_QUESTION; 174 case Qt::Key_At: return SDLK_AT; 175 case Qt::Key_BracketLeft: return SDLK_LEFTBRACKET; 176 case Qt::Key_Backslash: return SDLK_BACKSLASH; 177 case Qt::Key_BracketRight: return SDLK_RIGHTBRACKET; 178 ///case Qt::Key_Caret: return SDLK_CARET; 179 case Qt::Key_Underscore: return SDLK_UNDERSCORE; 180 //case Qt::Key_Backquote: return SDLK_BACKQUOTE; 181 case Qt::Key_A: return SDLK_a; 182 case Qt::Key_B: return SDLK_b; 183 case Qt::Key_C: return SDLK_c; 184 case Qt::Key_D: return SDLK_d; 185 case Qt::Key_E: return SDLK_e; 186 case Qt::Key_F: return SDLK_f; 187 case Qt::Key_G: return SDLK_g; 188 case Qt::Key_H: return SDLK_h; 189 case Qt::Key_I: return SDLK_i; 190 case Qt::Key_J: return SDLK_j; 191 case Qt::Key_K: return SDLK_k; 192 case Qt::Key_L: return SDLK_l; 193 case Qt::Key_M: return SDLK_m; 194 case Qt::Key_N: return SDLK_n; 195 case Qt::Key_O: return SDLK_o; 196 case Qt::Key_P: return SDLK_p; 197 case Qt::Key_Q: return SDLK_q; 198 case Qt::Key_R: return SDLK_r; 199 case Qt::Key_S: return SDLK_s; 200 case Qt::Key_T: return SDLK_t; 201 case Qt::Key_U: return SDLK_u; 202 case Qt::Key_V: return SDLK_v; 203 case Qt::Key_W: return SDLK_w; 204 case Qt::Key_X: return SDLK_x; 205 case Qt::Key_Y: return SDLK_y; 206 case Qt::Key_Z: return SDLK_z; 207 case Qt::Key_Delete: return SDLK_DELETE; 208 /* case Qt::Key_KP0: return SDLK_KP0; 209 case Qt::Key_KP1: return SDLK_KP1; 210 case Qt::Key_KP2: return SDLK_KP2; 211 case Qt::Key_KP3: return SDLK_KP3; 212 case Qt::Key_KP4: return SDLK_KP4; 213 case Qt::Key_KP5: return SDLK_KP5; 214 case Qt::Key_KP6: return SDLK_KP6; 215 case Qt::Key_KP7: return SDLK_KP7; 216 case Qt::Key_KP8: return SDLK_KP8; 217 case Qt::Key_KP9: return SDLK_KP9; */ 218 /* case Qt::Key_KP_Period: return SDLK_KP_PERIOD; 219 case Qt::Key_KP_Divide: return SDLK_KP_DIVIDE; 220 case Qt::Key_KP_Multiply: return SDLK_KP_MULTIPLY; 221 case Qt::Key_KP_Minus: return SDLK_KP_MINUS; 222 case Qt::Key_KP_PLUS: return SDLK_KP_PLUS; 223 case Qt::Key_KP_ENTER: return SDLK_KP_ENTER; 224 case Qt::Key_KP_EQUALS: return SDLK_KP_EQUALS;*/ 225 case Qt::Key_Up: return SDLK_UP; 226 case Qt::Key_Down: return SDLK_DOWN; 227 case Qt::Key_Right: return SDLK_RIGHT; 228 case Qt::Key_Left: return SDLK_LEFT; 229 case Qt::Key_Insert: return SDLK_INSERT; 230 case Qt::Key_Home: return SDLK_HOME; 231 case Qt::Key_End: return SDLK_END; 232 case Qt::Key_PageUp: return SDLK_PAGEUP; 233 case Qt::Key_PageDown: return SDLK_PAGEDOWN; 234 case Qt::Key_F1: return SDLK_F1; 235 case Qt::Key_F2: return SDLK_F2; 236 case Qt::Key_F3: return SDLK_F3; 237 case Qt::Key_F4: return SDLK_F4; 238 case Qt::Key_F5: return SDLK_F5; 239 case Qt::Key_F6: return SDLK_F6; 240 case Qt::Key_F7: return SDLK_F7; 241 case Qt::Key_F8: return SDLK_F8; 242 case Qt::Key_F9: return SDLK_F9; 243 case Qt::Key_F10: return SDLK_F10; 244 case Qt::Key_F11: return SDLK_F11; 245 case Qt::Key_F12: return SDLK_F12; 246 case Qt::Key_F13: return SDLK_F13; 247 case Qt::Key_F14: return SDLK_F14; 248 case Qt::Key_F15: return SDLK_F15; 249 case Qt::Key_NumLock: return SDLK_NUMLOCK; 250 case Qt::Key_CapsLock: return SDLK_CAPSLOCK; 251 case Qt::Key_ScrollLock: return SDLK_SCROLLOCK; 252 ///case Qt::Key_RSHIFT: return SDLK_RSHIFT; 253 case Qt::Key_Shift: return SDLK_LSHIFT; 254 ///case Qt::Key_RCTRL: return SDLK_RCTRL; 255 case Qt::Key_Control: return SDLK_LCTRL; 256 ///case Qt::Key_RALT: return SDLK_RALT; 257 case Qt::Key_Alt: return SDLK_LALT; 258 //case Qt::Key_RMETA: return SDLK_RMETA; 259 case Qt::Key_Meta: return SDLK_LMETA; 260 case Qt::Key_Super_L: return SDLK_LSUPER; 261 case Qt::Key_Super_R: return SDLK_RSUPER; 262 case Qt::Key_Mode_switch: return SDLK_MODE; 263 case Qt::Key_Help: return SDLK_HELP; 264 case Qt::Key_Print: return SDLK_PRINT; 265 case Qt::Key_SysReq: return SDLK_SYSREQ; 266 ///case Qt::Key_Break: return SDLK_BREAK; 267 ///case Qt::Key_Menu: return SDLK_MENU; 268 ///case Qt::Key_Power: return SDLK_POWER; 269 ///case Qt::Key_Euro: return SDLK_EURO; 270 return -1; 271 } 272 } 115 273 } -
trunk/src/lib/gui/qt_gui/gui_control.h
r7861 r7862 36 36 37 37 virtual bool event(QEvent* e); 38 public slots: 38 39 static int QtKToSDLK(int key); 40 41 public slots: 39 42 void listen(); 40 43 signals:
Note: See TracChangeset
for help on using the changeset viewer.