Ticket #4759: complete patch.patch
File complete patch.patch, 46.7 KB (added by , 15 years ago) |
---|
-
gui/PopUpWidget.cpp
222 222 return; 223 223 224 224 switch (state.keycode) { 225 225 226 case Common::KEYCODE_RETURN: 226 227 case Common::KEYCODE_KP_ENTER: 227 228 setResult(_selection); 228 229 close(); 229 230 break; 230 case Common::KEYCODE_UP: 231 moveUp(); 231 232 // Keypad & special keys 233 // - if num lock is set, we ignore the keypress 234 // - if num lock is not set, we fall down to the special key case 235 236 case Common::KEYCODE_KP1: 237 if (state.flags & Common::KBD_NUM) 238 break; 239 case Common::KEYCODE_END: 240 setSelection(_popUpBoss->_entries.size()-1); 232 241 break; 242 243 case Common::KEYCODE_KP2: 244 if (state.flags & Common::KBD_NUM) 245 break; 233 246 case Common::KEYCODE_DOWN: 234 247 moveDown(); 235 248 break; 249 250 case Common::KEYCODE_KP7: 251 if (state.flags & Common::KBD_NUM) 252 break; 236 253 case Common::KEYCODE_HOME: 237 254 setSelection(0); 238 255 break; 239 case Common::KEYCODE_END: 240 setSelection(_popUpBoss->_entries.size()-1); 256 257 case Common::KEYCODE_KP8: 258 if (state.flags & Common::KBD_NUM) 259 break; 260 case Common::KEYCODE_UP: 261 moveUp(); 241 262 break; 263 242 264 default: 243 265 break; 244 266 } -
gui/console.h
178 178 void updateScrollBuffer(); 179 179 void scrollToCurrent(); 180 180 181 void defaultKeyDownHandler(Common::KeyState &state); 182 181 183 // Line editing 182 184 void specialKeys(int keycode); 183 185 void nextLine(); -
gui/editable.cpp
100 100 endEditMode(); 101 101 dirty = true; 102 102 break; 103 103 104 case Common::KEYCODE_ESCAPE: 104 105 abortEditMode(); 105 106 dirty = true; 106 107 break; 108 107 109 case Common::KEYCODE_BACKSPACE: 108 110 if (_caretPos > 0) { 109 111 _caretPos--; … … 114 116 } 115 117 forcecaret = true; 116 118 break; 119 120 // Keypad & special keys 121 // - if num lock is set, we always go to the default case 122 // - if num lock is not set, we either fall down to the special key case 123 // or ignore the key press in case of 0 (INSERT), 2 (DOWN), 3 (PGDWN) 124 // 5, 8 (UP) and 9 (PGUP) 125 126 case Common::KEYCODE_KP0: 127 case Common::KEYCODE_KP2: 128 case Common::KEYCODE_KP3: 129 case Common::KEYCODE_KP5: 130 case Common::KEYCODE_KP8: 131 case Common::KEYCODE_KP9: 132 if (state.flags & Common::KBD_NUM) 133 defaultKeyDownHandler(state, dirty, forcecaret, handled); 134 break; 135 136 case Common::KEYCODE_KP_PERIOD: 137 if (state.flags & Common::KBD_NUM) { 138 defaultKeyDownHandler(state, dirty, forcecaret, handled); 139 break; 140 } 117 141 case Common::KEYCODE_DELETE: 118 142 if (_caretPos < (int)_editString.size()) { 119 143 _editString.deleteChar(_caretPos); … … 123 147 } 124 148 forcecaret = true; 125 149 break; 150 151 case Common::KEYCODE_KP1: 152 if (state.flags & Common::KBD_NUM) { 153 defaultKeyDownHandler(state, dirty, forcecaret, handled); 154 break; 155 } 156 case Common::KEYCODE_END: 157 dirty = setCaretPos(_editString.size()); 158 forcecaret = true; 159 break; 160 161 case Common::KEYCODE_KP4: 162 if (state.flags & Common::KBD_NUM) { 163 defaultKeyDownHandler(state, dirty, forcecaret, handled); 164 break; 165 } 126 166 case Common::KEYCODE_LEFT: 127 167 if (_caretPos > 0) { 128 168 dirty = setCaretPos(_caretPos - 1); … … 130 170 forcecaret = true; 131 171 dirty = true; 132 172 break; 173 174 case Common::KEYCODE_KP6: 175 if (state.flags & Common::KBD_NUM) { 176 defaultKeyDownHandler(state, dirty, forcecaret, handled); 177 break; 178 } 133 179 case Common::KEYCODE_RIGHT: 134 180 if (_caretPos < (int)_editString.size()) { 135 181 dirty = setCaretPos(_caretPos + 1); … … 137 183 forcecaret = true; 138 184 dirty = true; 139 185 break; 186 187 case Common::KEYCODE_KP7: 188 if (state.flags & Common::KBD_NUM) { 189 defaultKeyDownHandler(state, dirty, forcecaret, handled); 190 break; 191 } 140 192 case Common::KEYCODE_HOME: 141 193 dirty = setCaretPos(0); 142 194 forcecaret = true; 143 195 break; 144 case Common::KEYCODE_END: 145 dirty = setCaretPos(_editString.size()); 146 forcecaret = true; 147 break; 196 148 197 default: 149 if (tryInsertChar((byte)state.ascii, _caretPos)) { 150 _caretPos++; 151 dirty = true; 152 forcecaret = true; 153 154 sendCommand(_cmd, 0); 155 } else { 156 handled = false; 157 } 198 defaultKeyDownHandler(state, dirty, forcecaret, handled); 158 199 } 159 200 160 201 if (dirty) … … 166 207 return handled; 167 208 } 168 209 210 void EditableWidget::defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled) { 211 if (tryInsertChar((byte)state.ascii, _caretPos)) { 212 _caretPos++; 213 dirty = true; 214 forcecaret = true; 215 216 sendCommand(_cmd, 0); 217 } else { 218 handled = false; 219 } 220 } 221 169 222 int EditableWidget::getCaretOffset() const { 170 223 int caretpos = 0; 171 224 for (int i = 0; i < _caretPos; i++) -
gui/ListWidget.cpp
286 286 bool dirty = false; 287 287 int oldSelectedItem = _selectedItem; 288 288 289 if (!_editMode && isprint((unsigned char)state.ascii)) {289 if (!_editMode && state.keycode <= Common::KEYCODE_z && isprint((unsigned char)state.ascii)) { 290 290 // Quick selection mode: Go to first list item starting with this key 291 291 // (or a substring accumulated from the last couple key presses). 292 292 // Only works in a useful fashion if the list entries are sorted. … … 339 339 sendCommand(kListItemActivatedCmd, _selectedItem); 340 340 } 341 341 break; 342 343 // Keypad & special keys 344 // - if num lock is set, we do not handle the keypress 345 // - if num lock is not set, we either fall down to the special key case 346 // or ignore the key press for 0, 4, 5 and 6 347 348 case Common::KEYCODE_KP_PERIOD: 349 if (state.flags & Common::KBD_NUM) { 350 handled = false; 351 break; 352 } 342 353 case Common::KEYCODE_BACKSPACE: 343 case Common::KEYCODE_KP_PERIOD:344 354 case Common::KEYCODE_DELETE: 345 355 if (_selectedItem >= 0) { 346 356 if (_editable) { … … 350 360 } 351 361 } 352 362 break; 353 case Common::KEYCODE_UP: 354 if (_selectedItem > 0) 355 _selectedItem--; 363 364 case Common::KEYCODE_KP1: 365 if (state.flags & Common::KBD_NUM) { 366 handled = false; 367 break; 368 } 369 case Common::KEYCODE_END: 370 _selectedItem = _list.size() - 1; 356 371 break; 372 373 374 case Common::KEYCODE_KP2: 375 if (state.flags & Common::KBD_NUM) { 376 handled = false; 377 break; 378 } 357 379 case Common::KEYCODE_DOWN: 358 380 if (_selectedItem < (int)_list.size() - 1) 359 381 _selectedItem++; 360 382 break; 361 case Common::KEYCODE_PAGEUP: 362 _selectedItem -= _entriesPerPage - 1; 363 if (_selectedItem < 0) 364 _selectedItem = 0; 365 break; 383 384 case Common::KEYCODE_KP3: 385 if (state.flags & Common::KBD_NUM) { 386 handled = false; 387 break; 388 } 366 389 case Common::KEYCODE_PAGEDOWN: 367 390 _selectedItem += _entriesPerPage - 1; 368 391 if (_selectedItem >= (int)_list.size() ) 369 392 _selectedItem = _list.size() - 1; 370 393 break; 394 395 case Common::KEYCODE_KP7: 396 if (state.flags & Common::KBD_NUM) { 397 handled = false; 398 break; 399 } 371 400 case Common::KEYCODE_HOME: 372 401 _selectedItem = 0; 373 402 break; 374 case Common::KEYCODE_END: 375 _selectedItem = _list.size() - 1; 403 404 case Common::KEYCODE_KP8: 405 if (state.flags & Common::KBD_NUM) { 406 handled = false; 407 break; 408 } 409 case Common::KEYCODE_UP: 410 if (_selectedItem > 0) 411 _selectedItem--; 376 412 break; 413 414 case Common::KEYCODE_KP9: 415 if (state.flags & Common::KBD_NUM) { 416 handled = false; 417 break; 418 } 419 case Common::KEYCODE_PAGEUP: 420 _selectedItem -= _entriesPerPage - 1; 421 if (_selectedItem < 0) 422 _selectedItem = 0; 423 break; 424 377 425 default: 378 426 handled = false; 379 427 } -
gui/console.cpp
302 302 slideUpAndClose(); 303 303 break; 304 304 } 305 305 306 case Common::KEYCODE_ESCAPE: 306 307 slideUpAndClose(); 307 308 break; 309 308 310 case Common::KEYCODE_BACKSPACE: 309 311 if (_caretVisible) 310 312 drawCaret(true); … … 316 318 scrollToCurrent(); 317 319 drawLine(pos2line(_currentPos)); 318 320 break; 319 case Common::KEYCODE_TAB: 320 {321 322 case Common::KEYCODE_TAB: { 321 323 if (_completionCallbackProc) { 322 324 int len = _currentPos - _promptStartPos; 323 325 assert(len >= 0); … … 339 341 delete[] str; 340 342 } 341 343 break; 342 } 344 } 345 346 // Keypad & special keys 347 // - if num lock is set, we always go to the default case 348 // - if num lock is not set, we either fall down to the special key case 349 // or ignore the key press in case of 0 (INSERT) or 5 350 351 case Common::KEYCODE_KP0: 352 case Common::KEYCODE_KP5: 353 if (state.flags & Common::KBD_NUM) 354 defaultKeyDownHandler(state); 355 break; 356 357 case Common::KEYCODE_KP_PERIOD: 358 if (state.flags & Common::KBD_NUM) { 359 defaultKeyDownHandler(state); 360 break; 361 } 343 362 case Common::KEYCODE_DELETE: 344 363 if (_currentPos < _promptEndPos) { 345 364 killChar(); 346 365 drawLine(pos2line(_currentPos)); 347 366 } 348 367 break; 349 case Common::KEYCODE_PAGEUP: 350 if (state.flags == Common::KBD_SHIFT) { 351 _scrollLine -= _linesPerPage - 1; 352 if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1) 353 _scrollLine = _firstLineInBuffer + _linesPerPage - 1; 368 369 case Common::KEYCODE_KP1: 370 if (state.flags & Common::KBD_NUM) { 371 defaultKeyDownHandler(state); 372 break; 373 } 374 case Common::KEYCODE_END: 375 if (state.hasFlags(Common::KBD_SHIFT)) { 376 _scrollLine = _promptEndPos / kCharsPerLine; 377 if (_scrollLine < _linesPerPage - 1) 378 _scrollLine = _linesPerPage - 1; 354 379 updateScrollBuffer(); 355 draw(); 380 } else { 381 _currentPos = _promptEndPos; 356 382 } 383 draw(); 357 384 break; 385 386 case Common::KEYCODE_KP2: 387 if (state.flags & Common::KBD_NUM) { 388 defaultKeyDownHandler(state); 389 break; 390 } 391 case Common::KEYCODE_DOWN: 392 historyScroll(-1); 393 break; 394 395 case Common::KEYCODE_KP3: 396 if (state.flags & Common::KBD_NUM) { 397 defaultKeyDownHandler(state); 398 break; 399 } 358 400 case Common::KEYCODE_PAGEDOWN: 359 if (state. flags == Common::KBD_SHIFT) {401 if (state.hasFlags(Common::KBD_SHIFT)) { 360 402 _scrollLine += _linesPerPage - 1; 361 403 if (_scrollLine > _promptEndPos / kCharsPerLine) { 362 404 _scrollLine = _promptEndPos / kCharsPerLine; … … 367 409 draw(); 368 410 } 369 411 break; 412 413 case Common::KEYCODE_KP4: 414 if (state.flags & Common::KBD_NUM) { 415 defaultKeyDownHandler(state); 416 break; 417 } 418 case Common::KEYCODE_LEFT: 419 if (_currentPos > _promptStartPos) 420 _currentPos--; 421 drawLine(pos2line(_currentPos)); 422 break; 423 424 case Common::KEYCODE_KP6: 425 if (state.flags & Common::KBD_NUM) { 426 defaultKeyDownHandler(state); 427 break; 428 } 429 case Common::KEYCODE_RIGHT: 430 if (_currentPos < _promptEndPos) 431 _currentPos++; 432 drawLine(pos2line(_currentPos)); 433 break; 434 435 case Common::KEYCODE_KP7: 436 if (state.flags & Common::KBD_NUM) { 437 defaultKeyDownHandler(state); 438 break; 439 } 370 440 case Common::KEYCODE_HOME: 371 if (state. flags == Common::KBD_SHIFT) {441 if (state.hasFlags(Common::KBD_SHIFT)) { 372 442 _scrollLine = _firstLineInBuffer + _linesPerPage - 1; 373 443 updateScrollBuffer(); 374 444 } else { … … 376 446 } 377 447 draw(); 378 448 break; 379 case Common::KEYCODE_END: 380 if (state.flags == Common::KBD_SHIFT) { 381 _scrollLine = _promptEndPos / kCharsPerLine; 382 if (_scrollLine < _linesPerPage - 1) 383 _scrollLine = _linesPerPage - 1; 384 updateScrollBuffer(); 385 } else { 386 _currentPos = _promptEndPos; 449 450 case Common::KEYCODE_KP8: 451 if (state.flags & Common::KBD_NUM) { 452 defaultKeyDownHandler(state); 453 break; 387 454 } 388 draw();389 break;390 455 case Common::KEYCODE_UP: 391 456 historyScroll(+1); 392 457 break; 393 case Common::KEYCODE_DOWN: 394 historyScroll(-1); 458 459 case Common::KEYCODE_KP9: 460 if (state.flags & Common::KBD_NUM) { 461 defaultKeyDownHandler(state); 462 break; 463 } 464 case Common::KEYCODE_PAGEUP: 465 if (state.hasFlags(Common::KBD_SHIFT)) { 466 _scrollLine -= _linesPerPage - 1; 467 if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1) 468 _scrollLine = _firstLineInBuffer + _linesPerPage - 1; 469 updateScrollBuffer(); 470 draw(); 471 } 395 472 break; 396 case Common::KEYCODE_RIGHT: 397 if (_currentPos < _promptEndPos) 398 _currentPos++; 399 drawLine(pos2line(_currentPos)); 400 break; 401 case Common::KEYCODE_LEFT: 402 if (_currentPos > _promptStartPos) 403 _currentPos--; 404 drawLine(pos2line(_currentPos)); 405 break; 473 406 474 default: 407 if (state.ascii == '~' || state.ascii == '#') { 408 slideUpAndClose(); 409 } else if (state.flags == Common::KBD_CTRL) { 410 specialKeys(state.keycode); 411 } else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) { 412 for (i = _promptEndPos - 1; i >= _currentPos; i--) 413 buffer(i + 1) = buffer(i); 414 _promptEndPos++; 415 putchar((byte)state.ascii); 416 scrollToCurrent(); 417 } 475 defaultKeyDownHandler(state); 418 476 } 419 477 } 420 478 479 void ConsoleDialog::defaultKeyDownHandler(Common::KeyState &state) { 480 if (state.ascii == '~' || state.ascii == '#') { 481 slideUpAndClose(); 482 } else if (state.hasFlags(Common::KBD_CTRL)) { 483 specialKeys(state.keycode); 484 } else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) { 485 for (int i = _promptEndPos - 1; i >= _currentPos; i--) 486 buffer(i + 1) = buffer(i); 487 _promptEndPos++; 488 putchar((byte)state.ascii); 489 scrollToCurrent(); 490 } 491 } 492 421 493 void ConsoleDialog::insertIntoPrompt(const char* str) { 422 494 unsigned int l = strlen(str); 423 495 for (int i = _promptEndPos - 1; i >= _currentPos; i--) -
gui/editable.h
81 81 bool adjustOffset(); 82 82 void makeCaretVisible(); 83 83 84 void defaultKeyDownHandler(Common::KeyState &state, bool &dirty, bool &forcecaret, bool &handled); 85 84 86 void setFontStyle(ThemeEngine::FontStyle font) { _font = font; } 85 87 86 88 virtual bool tryInsertChar(byte c, int pos); -
engines/m4/events.cpp
73 73 if ((_event.kbd.keycode == Common::KEYCODE_LCTRL) || (_event.kbd.keycode == Common::KEYCODE_RCTRL)) 74 74 _ctrlFlag = true; 75 75 76 else if (_event.kbd. flags == Common::KBD_CTRL) {76 else if (_event.kbd.hasFlags(Common::KBD_CTRL)) { 77 77 if ((_event.kbd.keycode == Common::KEYCODE_d) && _ctrlFlag) { 78 78 _console->attach(); 79 79 _console->onFrame(); -
engines/m4/mads_views.cpp
362 362 363 363 // Capitalise the letter if necessary 364 364 if (_cheatKeyCtr < CHEAT_SEQUENCE_MAX) { 365 if ((flags ==Common::KBD_CTRL) && (kc == CHEAT_SEQUENCE[_cheatKeyCtr])) {365 if ((flags & Common::KBD_CTRL) && (kc == CHEAT_SEQUENCE[_cheatKeyCtr])) { 366 366 ++_cheatKeyCtr; 367 367 if (_cheatKeyCtr == CHEAT_SEQUENCE_MAX) 368 368 Dialog::display(_vm, 22, cheatingEnabledDesc); -
engines/tucker/tucker.cpp
607 607 case Common::EVENT_KEYDOWN: 608 608 switch (ev.kbd.keycode) { 609 609 case Common::KEYCODE_f: 610 if (ev.kbd. flags == Common::KBD_CTRL) {610 if (ev.kbd.hasFlags(Common::KBD_CTRL)) { 611 611 _fastMode = !_fastMode; 612 612 } 613 613 break; -
engines/agi/agi.cpp
121 121 _mouse.y = event.mouse.y; 122 122 break; 123 123 case Common::EVENT_KEYDOWN: 124 if (event.kbd. flags == Common::KBD_CTRL&& event.kbd.keycode == Common::KEYCODE_d) {124 if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) { 125 125 _console->attach(); 126 126 break; 127 127 } -
engines/agi/preagi_troll.cpp
104 104 case Common::KEYCODE_KP_ENTER: 105 105 return true; 106 106 case Common::KEYCODE_s: 107 if (event.kbd. flags == Common::KBD_CTRL) {107 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 108 108 if (_soundOn) { 109 109 playTune(2, 1); 110 110 _soundOn = !_soundOn; -
engines/kyra/gui.cpp
421 421 while (_vm->_eventMan->pollEvent(event) && running) { 422 422 switch (event.type) { 423 423 case Common::EVENT_KEYDOWN: 424 if (event.kbd.keycode == Common::KEYCODE_q && event.kbd. flags == Common::KBD_CTRL)424 if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL)) 425 425 _vm->quitGame(); 426 426 else 427 427 _keyPressed = event.kbd; -
engines/kyra/kyra_v1.cpp
262 262 switch (event.type) { 263 263 case Common::EVENT_KEYDOWN: 264 264 if (event.kbd.keycode >= Common::KEYCODE_1 && event.kbd.keycode <= Common::KEYCODE_9 && 265 (event.kbd. flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && mainLoop) {265 (event.kbd.hasFlags(Common::KBD_CTRL) || event.kbd.hasFlags(Common::KBD_ALT)) && mainLoop) { 266 266 int saveLoadSlot = 9 - (event.kbd.keycode - Common::KEYCODE_0) + 990; 267 267 268 if (event.kbd. flags == Common::KBD_CTRL) {268 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 269 269 loadGameStateCheck(saveLoadSlot); 270 270 _eventList.clear(); 271 271 breakLoop = true; … … 274 274 sprintf(savegameName, "Quicksave %d", event.kbd.keycode - Common::KEYCODE_0); 275 275 saveGameState(saveLoadSlot, savegameName, 0); 276 276 } 277 } else if (event.kbd. flags == Common::KBD_CTRL) {277 } else if (event.kbd.hasFlags(Common::KBD_CTRL)) { 278 278 if (event.kbd.keycode == Common::KEYCODE_d) { 279 279 if (_debugger) 280 280 _debugger->attach(); … … 384 384 event.kbd.keycode == Common::KEYCODE_UP || event.kbd.keycode == Common::KEYCODE_RIGHT || 385 385 event.kbd.keycode == Common::KEYCODE_DOWN || event.kbd.keycode == Common::KEYCODE_LEFT) 386 386 _eventList.push_back(Event(event, true)); 387 else if (event.kbd.keycode == Common::KEYCODE_q && event.kbd. flags == Common::KBD_CTRL)387 else if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL)) 388 388 quitGame(); 389 389 else 390 390 _eventList.push_back(event); -
engines/gob/util.cpp
114 114 _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsRight)); 115 115 break; 116 116 case Common::EVENT_KEYDOWN: 117 if (event.kbd. flags == Common::KBD_CTRL) {117 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 118 118 if (event.kbd.keycode == Common::KEYCODE_f) 119 119 _fastMode ^= 1; 120 120 else if (event.kbd.keycode == Common::KEYCODE_g) -
engines/gob/gob.cpp
109 109 110 110 void PauseDialog::handleKeyDown(Common::KeyState state) { 111 111 // Close on CTRL+p 112 if ((state. flags == Common::KBD_CTRL) && (state.keycode == Common::KEYCODE_p))112 if ((state.hasFlags(Common::KBD_CTRL)) && (state.keycode == Common::KEYCODE_p)) 113 113 close(); 114 114 } 115 115 -
engines/saga/input.cpp
44 44 while (_eventMan->pollEvent(event)) { 45 45 switch (event.type) { 46 46 case Common::EVENT_KEYDOWN: 47 if (event.kbd. flags == Common::KBD_CTRL) {47 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 48 48 if (event.kbd.keycode == Common::KEYCODE_d) 49 49 _console->attach(); 50 50 } … … 56 56 switch (event.kbd.keycode) { 57 57 case Common::KEYCODE_HASH: 58 58 case Common::KEYCODE_BACKQUOTE: 59 case Common::KEYCODE_ QUOTE: // tilde ("~")59 case Common::KEYCODE_TILDE: // tilde ("~") 60 60 _console->attach(); 61 61 break; 62 62 case Common::KEYCODE_r: -
engines/saga/interface.cpp
651 651 return true; 652 652 } 653 653 } 654 if (keystate.keycode == Common::KEYCODE_o && keystate. flags == Common::KBD_CTRL) { // ctrl-o654 if (keystate.keycode == Common::KEYCODE_o && keystate.hasFlags(Common::KBD_CTRL)) { // ctrl-o 655 655 if (_saveReminderState > 0) { 656 656 setMode(kPanelOption); 657 657 return true; -
engines/queen/input.cpp
100 100 _idleTime = 0; 101 101 switch (event.type) { 102 102 case Common::EVENT_KEYDOWN: 103 if (event.kbd. flags == Common::KBD_CTRL) {104 if (event.kbd.keycode == 'd') {103 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 104 if (event.kbd.keycode == Common::KEYCODE_d) { 105 105 _debugger = true; 106 } else if (event.kbd.keycode == 'f') {106 } else if (event.kbd.keycode == Common::KEYCODE_f) { 107 107 _fastMode = !_fastMode; 108 108 } 109 109 } else { -
engines/sci/event.cpp
120 120 int modifiers = em->getModifierState(); 121 121 122 122 // We add the modifier key status to buckybits 123 // SDL sends a keydown event if a modifier key is turned on and a keyup event if it's off124 //125 // FIXME: This code is semi-bogus. It only records the modifier key being *pressed*.126 // It does not track correctly whether capslock etc. is active. To do that, we127 // would have to record the fact that the modifier was pressed in global var,128 // and also watch for Common::EVENT_KEYUP events.129 // But this is still not quite good enough, because not all events might130 // pass through here (e.g. the GUI might be running with its own event loop).131 //132 // The best solution likely would be to add code to the EventManager class133 // for tracking which keys are pressed and which are not...134 if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {135 switch (ev.kbd.keycode) {136 case Common::KEYCODE_CAPSLOCK:137 if (ev.type == Common::EVENT_KEYDOWN) {138 _modifierStates |= SCI_KEYMOD_CAPSLOCK;139 } else {140 _modifierStates &= ~SCI_KEYMOD_CAPSLOCK;141 }142 break;143 case Common::KEYCODE_NUMLOCK:144 if (ev.type == Common::EVENT_KEYDOWN) {145 _modifierStates |= SCI_KEYMOD_NUMLOCK;146 } else {147 _modifierStates &= ~SCI_KEYMOD_NUMLOCK;148 }149 break;150 case Common::KEYCODE_SCROLLOCK:151 if (ev.type == Common::EVENT_KEYDOWN) {152 _modifierStates |= SCI_KEYMOD_SCRLOCK;153 } else {154 _modifierStates &= ~SCI_KEYMOD_SCRLOCK;155 }156 break;157 default:158 break;159 }160 }161 123 //TODO: SCI_EVM_INSERT 162 124 163 125 input.modifiers = 164 126 ((modifiers & Common::KBD_ALT) ? SCI_KEYMOD_ALT : 0) | 165 127 ((modifiers & Common::KBD_CTRL) ? SCI_KEYMOD_CTRL : 0) | 166 128 ((modifiers & Common::KBD_SHIFT) ? SCI_KEYMOD_LSHIFT | SCI_KEYMOD_RSHIFT : 0) | 129 ((ev.kbd.flags & Common::KBD_NUM) ? SCI_KEYMOD_NUMLOCK : 0) | 130 ((ev.kbd.flags & Common::KBD_CAPS) ? SCI_KEYMOD_CAPSLOCK : 0) | 131 ((ev.kbd.flags & Common::KBD_SCRL) ? SCI_KEYMOD_SCRLOCK : 0) | 167 132 _modifierStates; 168 133 169 134 switch (ev.type) { … … 173 138 input.character = ev.kbd.ascii; 174 139 175 140 // Debug console 176 if (ev.kbd. flags == Common::KBD_CTRL&& ev.kbd.keycode == Common::KEYCODE_d) {141 if (ev.kbd.hasFlags(Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) { 177 142 // Open debug console 178 143 Console *con = g_sci->getSciDebugger(); 179 144 con->attach(); -
engines/sword2/sword2.cpp
491 491 KeyboardEvent *ke = keyboardEvent(); 492 492 493 493 if (ke) { 494 if ((ke->kbd. flags == Common::KBD_CTRL&& ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') {494 if ((ke->kbd.hasFlags(Common::KBD_CTRL) && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') { 495 495 _debugger->attach(); 496 } else if (ke->kbd. flags == 0 || ke->kbd.flags == Common::KBD_SHIFT) {496 } else if (ke->kbd.hasFlags(0) || ke->kbd.hasFlags(Common::KBD_SHIFT)) { 497 497 switch (ke->kbd.keycode) { 498 498 case Common::KEYCODE_p: 499 499 if (_gamePaused) … … 654 654 while (_eventMan->pollEvent(event)) { 655 655 switch (event.type) { 656 656 case Common::EVENT_KEYDOWN: 657 if (event.kbd. flags == Common::KBD_CTRL) {658 if (event.kbd.keycode == 'f') {657 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 658 if (event.kbd.keycode == Common::KEYCODE_f) { 659 659 if (_gameSpeed == 1) 660 660 _gameSpeed = 2; 661 661 else -
engines/draci/draci.cpp
293 293 } 294 294 break; 295 295 case Common::KEYCODE_F5: 296 if (event.kbd. flags == 0) {296 if (event.kbd.hasFlags(0)) { 297 297 openMainMenuDialog(); 298 298 } 299 299 break; -
engines/scumm/input.cpp
110 110 void ScummEngine::parseEvent(Common::Event event) { 111 111 switch (event.type) { 112 112 case Common::EVENT_KEYDOWN: 113 if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9'&&114 ((event.kbd. flags == Common::KBD_ALT&& canSaveGameStateCurrently()) ||115 (event.kbd. flags == Common::KBD_CTRL&& canLoadGameStateCurrently()))) {116 _saveLoadSlot = event.kbd.keycode - '0';113 if (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9 && 114 ((event.kbd.hasFlags(Common::KBD_ALT) && canSaveGameStateCurrently()) || 115 (event.kbd.hasFlags(Common::KBD_CTRL) && canLoadGameStateCurrently()))) { 116 _saveLoadSlot = event.kbd.keycode - Common::KEYCODE_0; 117 117 118 118 // don't overwrite autosave (slot 0) 119 119 if (_saveLoadSlot == 0) 120 120 _saveLoadSlot = 10; 121 121 122 122 sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot); 123 _saveLoadFlag = (event.kbd. flags == Common::KBD_ALT) ? 1 : 2;123 _saveLoadFlag = (event.kbd.hasFlags(Common::KBD_ALT)) ? 1 : 2; 124 124 _saveTemporaryState = false; 125 } else if (event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {125 } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) { 126 126 _fastMode ^= 1; 127 } else if (event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 'g') {127 } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_g) { 128 128 _fastMode ^= 2; 129 } else if ((event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 'd') ||130 129 } else if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) 130 || event.kbd.ascii == '~' || event.kbd.ascii == '#') { 131 131 _debugger->attach(); 132 } else if (event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 's') {132 } else if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_s) { 133 133 _res->resourceStats(); 134 134 } else { 135 135 // Normal key press, pass on to the game. … … 355 355 #ifdef ENABLE_SCUMM_7_8 356 356 void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) { 357 357 // F1 (the trigger for the original save/load dialog) is mapped to F5 358 if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit. flags == 0) {358 if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.hasFlags(0)) { 359 359 lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319); 360 360 } 361 361 362 362 // Alt-F5 should bring up the original save/load dialog, so map it to F1. 363 if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit. flags == Common::KBD_ALT) {363 if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) { 364 364 lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315); 365 365 } 366 366 … … 383 383 // version string is hard coded in the engine, hence we don't invoke 384 384 // versionDialog for it. Dig/FT version strings are partly hard coded, too. 385 385 if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) && 386 lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit. flags == Common::KBD_CTRL) {386 lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.hasFlags(Common::KBD_CTRL)) { 387 387 versionDialog(); 388 388 389 389 } else if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) { … … 408 408 #endif 409 409 410 410 void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) { 411 if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit. flags == Common::KBD_CTRL) {411 if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.hasFlags(Common::KBD_CTRL)) { 412 412 SubtitleSettingsDialog dialog(this, _voiceMode); 413 413 _voiceMode = runDialog(dialog); 414 414 … … 442 442 ScummEngine::processKeyboard(lastKeyHit); 443 443 444 444 // On Alt-F5 prepare savegame for the original save/load dialog. 445 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit. flags == Common::KBD_ALT) {445 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) { 446 446 prepareSavegame(); 447 447 if (_game.id == GID_MANIAC && _game.version == 0) { 448 448 runScript(2, 0, 0, 0); … … 467 467 ScummEngine::processKeyboard(lastKeyHit); 468 468 469 469 // On Alt-F5 prepare savegame for the original save/load dialog. 470 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit. flags == Common::KBD_ALT) {470 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(Common::KBD_ALT)) { 471 471 prepareSavegame(); 472 472 } 473 473 … … 504 504 if (_game.id == GID_CMI) 505 505 mainmenuKeyEnabled = true; 506 506 507 if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit. flags == 0)) {507 if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.hasFlags(0))) { 508 508 if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) 509 509 runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); 510 510 … … 513 513 if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) 514 514 runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0); 515 515 516 } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit. flags == 0)) {516 } else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.hasFlags(0))) { 517 517 confirmRestartDialog(); 518 518 519 } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit. flags == 0)) {519 } else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.hasFlags(0))) { 520 520 pauseGame(); 521 521 522 } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit. flags == 0)) {522 } else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.hasFlags(0))) { 523 523 _talkDelay = 0; 524 524 if (_sound->_sfxMode & 2) 525 525 stopTalk(); 526 526 527 } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit. flags == 0)) {527 } else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.hasFlags(0))) { 528 528 abortCutscene(); 529 529 530 530 // VAR_CUTSCENEEXIT_KEY doesn't exist in SCUMM0 531 531 if (VAR_CUTSCENEEXIT_KEY != 0xFF) 532 532 _mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY); 533 533 } else if (snapScrollKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_r && 534 lastKeyHit. flags == Common::KBD_CTRL) {534 lastKeyHit.hasFlags(Common::KBD_CTRL)) { 535 535 _snapScroll ^= 1; 536 536 if (_snapScroll) { 537 537 messageDialog("Snap scroll on"); -
engines/scumm/dialogs.cpp
725 725 } 726 726 727 727 void SubtitleSettingsDialog::handleKeyDown(Common::KeyState state) { 728 if (state.keycode == 't' && state.flags == Common::KBD_CTRL) {728 if (state.keycode == Common::KEYCODE_t && state.hasFlags(Common::KBD_CTRL)) { 729 729 cycleValue(); 730 730 731 731 reflowLayout(); -
engines/touche/touche.cpp
313 313 } else if (event.kbd.keycode == Common::KEYCODE_F10) { 314 314 _fastWalkMode = false; 315 315 } 316 if (event.kbd. flags == Common::KBD_CTRL) {316 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 317 317 if (event.kbd.keycode == Common::KEYCODE_f) { 318 318 _fastMode = !_fastMode; 319 319 } -
engines/agos/event.cpp
459 459 switch (event.type) { 460 460 case Common::EVENT_KEYDOWN: 461 461 if (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9 462 && (event.kbd. flags == Common::KBD_ALT||463 event.kbd. flags == Common::KBD_CTRL)) {462 && (event.kbd.hasFlags(Common::KBD_ALT) || 463 event.kbd.hasFlags(Common::KBD_CTRL))) { 464 464 _saveLoadSlot = event.kbd.keycode - Common::KEYCODE_0; 465 465 466 466 // There is no save slot 0 … … 469 469 470 470 memset(_saveLoadName, 0, sizeof(_saveLoadName)); 471 471 sprintf(_saveLoadName, "Quick %d", _saveLoadSlot); 472 _saveLoadType = (event.kbd. flags == Common::KBD_ALT) ? 1 : 2;472 _saveLoadType = (event.kbd.hasFlags(Common::KBD_ALT)) ? 1 : 2; 473 473 474 474 // We should only allow a load or save when it was possible in original 475 475 // This stops load/save during copy protection, conversations and cut scenes 476 476 if (!_mouseHideCount && !_showPreposition) 477 477 quickLoadOrSave(); 478 } else if (event.kbd. flags == Common::KBD_CTRL) {478 } else if (event.kbd.hasFlags(Common::KBD_CTRL)) { 479 479 if (event.kbd.keycode == Common::KEYCODE_a) { 480 480 GUI::Dialog *_aboutDialog; 481 481 _aboutDialog = new GUI::AboutDialog(); … … 492 492 } 493 493 494 494 if (getGameType() == GType_PP) { 495 if (event.kbd. flags == Common::KBD_SHIFT)495 if (event.kbd.hasFlags(Common::KBD_SHIFT)) 496 496 _variableArray[41] = 0; 497 497 else 498 498 _variableArray[41] = 1; -
engines/cruise/cruise_main.cpp
1759 1759 break; 1760 1760 } 1761 1761 1762 if (event.kbd. flags == Common::KBD_CTRL) {1762 if (event.kbd.hasFlags(Common::KBD_CTRL)) { 1763 1763 if (event.kbd.keycode == Common::KEYCODE_d) { 1764 1764 // Start the debugger 1765 1765 _vm->getDebugger()->attach(); -
engines/tinsel/tinsel.cpp
230 230 continue; 231 231 case Common::KEYCODE_m: 232 232 // Debug facility - scene hopper 233 if (TinselV2 && (evt.kbd. flags == Common::KBD_ALT))233 if (TinselV2 && (evt.kbd.hasFlags(Common::KBD_ALT))) 234 234 ProcessKeyEvent(PLR_JUMP); 235 235 break; 236 236 case Common::KEYCODE_q: 237 if ((evt.kbd. flags == Common::KBD_CTRL) || (evt.kbd.flags == Common::KBD_ALT))237 if ((evt.kbd.hasFlags(Common::KBD_CTRL)) || (evt.kbd.hasFlags(Common::KBD_ALT))) 238 238 ProcessKeyEvent(PLR_QUIT); 239 239 continue; 240 240 case Common::KEYCODE_PAGEUP: … … 1201 1201 // Handle any special keys immediately 1202 1202 switch (event.kbd.keycode) { 1203 1203 case Common::KEYCODE_d: 1204 if ((event.kbd.flags == Common::KBD_CTRL) && (event.type == Common::EVENT_KEYDOWN)) { 1204 // Checks for CTRL flag, ignoring all the sticky flags 1205 if ((Common::KBD_CTRL == (event.kbd.flags & ~(Common::KBD_NUM|Common::KBD_CAPS|Common::KBD_SCRL))) && (event.type == Common::EVENT_KEYDOWN)) { 1205 1206 // Activate the debugger 1206 1207 assert(_console); 1207 1208 _console->attach(); -
engines/sky/sky.cpp
113 113 _skySound->fnUnPauseFx(); 114 114 _systemVars.paused = false; 115 115 _skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette)); 116 } else if (_keyPressed. flags == Common::KBD_CTRL) {117 if (_keyPressed.keycode == 'f')116 } else if (_keyPressed.hasFlags(Common::KBD_CTRL)) { 117 if (_keyPressed.keycode == Common::KEYCODE_f) 118 118 _fastMode ^= 1; 119 else if (_keyPressed.keycode == 'g')119 else if (_keyPressed.keycode == Common::KEYCODE_g) 120 120 _fastMode ^= 2; 121 else if (_keyPressed.keycode == 'd')121 else if (_keyPressed.keycode == Common::KEYCODE_d) 122 122 _debugger->attach(); 123 123 } else if (_keyPressed.keycode) { 124 124 switch (_keyPressed.keycode) { -
engines/lure/game.cpp
195 195 if (events.type() == Common::EVENT_KEYDOWN) { 196 196 uint16 roomNum = room.roomNumber(); 197 197 198 if ((events.event().kbd. flags == Common::KBD_CTRL) &&198 if ((events.event().kbd.hasFlags(Common::KBD_CTRL)) && 199 199 (events.event().kbd.keycode == Common::KEYCODE_d)) { 200 200 // Activate the debugger 201 201 _debugger->attach(); -
engines/lure/fights.cpp
205 205 return; 206 206 207 207 case Common::KEYCODE_d: 208 if (events.event().kbd. flags == Common::KBD_CTRL) {208 if (events.event().kbd.hasFlags(Common::KBD_CTRL)) { 209 209 // Activate the debugger 210 210 game.debugger().attach(); 211 211 return; -
engines/parallaction/input.cpp
111 111 _hasKeyPressEvent = true; 112 112 _keyPressed = e.kbd; 113 113 114 if (e.kbd. flags == Common::KBD_CTRL && e.kbd.keycode == 'd')114 if (e.kbd.hasFlags(Common::KBD_CTRL) && e.kbd.keycode == Common::KEYCODE_d) 115 115 _vm->_debugger->attach(); 116 116 117 117 updateMousePos = false; -
engines/teenagent/teenagent.cpp
474 474 //debug(0, "event"); 475 475 switch (event.type) { 476 476 case Common::EVENT_KEYDOWN: 477 if ((event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 'd') ||477 if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) || 478 478 event.kbd.ascii == '~' || event.kbd.ascii == '#') { 479 479 console->attach(); 480 } else if (event.kbd. flags == 0&& event.kbd.keycode == Common::KEYCODE_F5) {480 } else if (event.kbd.hasFlags(0) && event.kbd.keycode == Common::KEYCODE_F5) { 481 481 openMainMenuDialog(); 482 } if (event.kbd. flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {482 } if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) { 483 483 _mark_delay = _mark_delay == 80? 40: 80; 484 484 debug(0, "mark_delay = %u", _mark_delay); 485 485 } -
common/keyboard.h
40 40 KEYCODE_PAUSE = 19, 41 41 KEYCODE_ESCAPE = 27, 42 42 KEYCODE_SPACE = 32, 43 KEYCODE_EXCLAIM = 33, 44 KEYCODE_QUOTEDBL = 34, 45 KEYCODE_HASH = 35, 46 KEYCODE_DOLLAR = 36, 47 KEYCODE_AMPERSAND = 38, 48 KEYCODE_QUOTE = 39, 43 KEYCODE_EXCLAIM = 33, // ! 44 KEYCODE_QUOTEDBL = 34, // " 45 KEYCODE_HASH = 35, // # 46 KEYCODE_DOLLAR = 36, // $ 47 KEYCODE_AMPERSAND = 38, // & 48 KEYCODE_QUOTE = 39, // ' 49 49 KEYCODE_LEFTPAREN = 40, 50 50 KEYCODE_RIGHTPAREN = 41, 51 KEYCODE_ASTERISK = 42, 51 KEYCODE_ASTERISK = 42, // * 52 52 KEYCODE_PLUS = 43, 53 53 KEYCODE_COMMA = 44, 54 54 KEYCODE_MINUS = 45, … … 105 105 KEYCODE_y = 121, 106 106 KEYCODE_z = 122, 107 107 KEYCODE_DELETE = 127, 108 KEYCODE_TILDE = 176, // ~ 108 109 109 110 // Numeric keypad 110 111 KEYCODE_KP0 = 256, … … 215 216 enum { 216 217 KBD_CTRL = 1 << 0, 217 218 KBD_ALT = 1 << 1, 218 KBD_SHIFT = 1 << 2 219 KBD_SHIFT = 1 << 2, 220 KBD_NUM = 1 << 3, 221 KBD_CAPS = 1 << 4, 222 KBD_SCRL = 1 << 5 219 223 }; 220 224 221 225 /** … … 245 249 /** 246 250 * Status of the modifier keys. Bits are set in this for each 247 251 * pressed modifier 248 * @see KBD_CTRL, KBD_ALT, KBD_SHIFT 252 * @see KBD_CTRL, KBD_ALT, KBD_SHIFT, KBD_NUM, KBD_CAPS, KBD_SCRL 249 253 */ 250 254 byte flags; 251 255 … … 266 270 ascii = flags = 0; 267 271 } 268 272 273 /** 274 * Check for flags, ignoring the sticky flags (KBD_NUM, KBD_CAPS, KBD_SCRL) 275 */ 276 bool hasFlags(byte f) { 277 return f == (flags & ~(KBD_NUM|KBD_CAPS|KBD_SCRL)); 278 } 279 269 280 bool operator ==(const KeyState &x) const { 270 281 return keycode == x.keycode && ascii == x.ascii && flags == x.flags; 271 282 } -
backends/events/default/default-events.cpp
103 103 _keyRepeatTime = time + kKeyRepeatInitialDelay; 104 104 #endif 105 105 // Global Main Menu 106 if (event.kbd. flags == Common::KBD_CTRL&& event.kbd.keycode == Common::KEYCODE_F5) {106 if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { 107 107 if (g_engine && !g_engine->isPaused()) { 108 108 Common::Event menuEvent; 109 109 menuEvent.type = Common::EVENT_MAINMENU; … … 135 135 } 136 136 } 137 137 #ifdef ENABLE_VKEYBD 138 else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd. flags == 0) {138 else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { 139 139 if (_vk->isDisplaying()) { 140 140 _vk->close(true); 141 141 } else { … … 149 149 } 150 150 #endif 151 151 #ifdef ENABLE_KEYMAPPER 152 else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd. flags == 0) {152 else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) { 153 153 if (!_remap) { 154 154 _remap = true; 155 155 Common::RemapDialog _remapDialog; -
backends/platform/sdl/sdl.cpp
232 232 _overlayscreen(0), _tmpscreen2(0), 233 233 _samplesPerSec(0), 234 234 _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), 235 _scrollLock(false), 235 236 _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), 236 237 _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), 237 238 _joystick(0), -
backends/platform/sdl/events.cpp
152 152 } 153 153 } 154 154 155 static byte SDLModToOSystemKeyFlags(SDLMod mod) { 156 byte b = 0; 155 static void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { 156 157 event.kbd.flags = 0; 158 157 159 #ifdef LINUPY 158 160 // Yopy has no ALT key, steal the SHIFT key 159 161 // (which isn't used much anyway) 160 162 if (mod & KMOD_SHIFT) 161 b|= Common::KBD_ALT;163 event.kbd.flags |= Common::KBD_ALT; 162 164 #else 163 165 if (mod & KMOD_SHIFT) 164 b|= Common::KBD_SHIFT;166 event.kbd.flags |= Common::KBD_SHIFT; 165 167 if (mod & KMOD_ALT) 166 b|= Common::KBD_ALT;168 event.kbd.flags |= Common::KBD_ALT; 167 169 #endif 168 170 if (mod & KMOD_CTRL) 169 b|= Common::KBD_CTRL;171 event.kbd.flags |= Common::KBD_CTRL; 170 172 171 return b; 173 // Sticky flags 174 if (mod & KMOD_NUM) 175 event.kbd.flags |= Common::KBD_NUM; 176 if (mod & KMOD_CAPS) 177 event.kbd.flags |= Common::KBD_CAPS; 172 178 } 173 179 174 180 bool OSystem_SDL::pollEvent(Common::Event &event) { … … 225 231 226 232 227 233 bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) { 228 byte b = 0;229 b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());230 234 235 SDLModToOSystemKeyFlags(SDL_GetModState(), event); 236 237 // Handle scroll lock as a key modifier 238 if (ev.key.keysym.sym == SDLK_SCROLLOCK) 239 _scrollLock = !_scrollLock; 240 241 if (_scrollLock) 242 event.kbd.flags |= Common::KBD_SCRL; 243 231 244 // Alt-Return and Alt-Enter toggle full screen mode 232 if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN 233 || ev.key.keysym.sym == SDLK_KP_ENTER)) { 245 if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) { 234 246 beginGFXTransaction(); 235 247 setFullscreenMode(!_videoMode.fullscreen); 236 248 endGFXTransaction(); … … 245 257 } 246 258 247 259 // Alt-S: Create a screenshot 248 if ( b == Common::KBD_ALT&& ev.key.keysym.sym == 's') {260 if (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 's') { 249 261 char filename[20]; 250 262 251 263 for (int n = 0;; n++) { … … 265 277 } 266 278 267 279 // Ctrl-m toggles mouse capture 268 if ( b == Common::KBD_CTRL&& ev.key.keysym.sym == 'm') {280 if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') { 269 281 toggleMouseGrab(); 270 282 return false; 271 283 } … … 284 296 } 285 297 #else 286 298 // Ctrl-z and Alt-X quit 287 if (( b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT&& ev.key.keysym.sym == 'x')) {299 if ((event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'z') || (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 'x')) { 288 300 event.type = Common::EVENT_QUIT; 289 301 return true; 290 302 } … … 296 308 } 297 309 298 310 // Ctrl-Alt-<key> will change the GFX mode 299 if (( b& (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {311 if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { 300 312 if (handleScalerHotkeys(ev.key)) 301 313 return false; 302 314 } … … 320 332 event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); 321 333 322 334 // Ctrl-Alt-<key> will change the GFX mode 323 byte b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); 324 if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { 335 SDLModToOSystemKeyFlags(SDL_GetModState(), event); 336 337 // Set the scroll lock sticky flag 338 if (_scrollLock) 339 event.kbd.flags |= Common::KBD_SCRL; 340 341 if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { 325 342 // Swallow these key up events 326 343 return false; 327 344 } -
backends/platform/sdl/sdl.h
412 412 kMouseColorKey = 1 413 413 }; 414 414 415 // Scroll lock state - since SDL doesn't track it 416 bool _scrollLock; 417 415 418 // joystick 416 419 SDL_Joystick *_joystick; 417 420