void DrasculaEngine::updateEvents() { Common::Event event; Common::EventManager *eventMan = _system->getEventManager(); updateMusic(); #ifdef _WIN32_WCE if (eventMan->pollEvent(event)) { #else while (eventMan->pollEvent(event)) { #endif switch (event.type) { case Common::EVENT_KEYDOWN: if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) { // Start the debugger getDebugger()->attach(); getDebugger()->onFrame(); } addKeyToBuffer(event.kbd); break; case Common::EVENT_KEYUP: break; case Common::EVENT_MOUSEMOVE: _mouseX = event.mouse.x; _mouseY = event.mouse.y; break; case Common::EVENT_LBUTTONDOWN: _leftMouseButton = 1; break; case Common::EVENT_LBUTTONUP: _leftMouseButton = 0; break; case Common::EVENT_RBUTTONDOWN: // We changed semantic and react only on button up event break; case Common::EVENT_RBUTTONUP: _rightMouseButton = 1; break; default: break; } } } void DrasculaEngine::delay(int ms) { uint32 end = _system->getMillis() + ms * 2; // originally was 1 do { _system->delayMillis(10); updateEvents(); _system->updateScreen(); } while (_system->getMillis() < end && !shouldQuit()); }
void DrasculaEngine::updateEvents() { Common::Event event; Common::EventManager *eventMan = _system->getEventManager(); updateMusic(); #ifdef _WIN32_WCE if (eventMan->pollEvent(event)) { #else while (eventMan->pollEvent(event)) { #endif switch (event.type) { case Common::EVENT_KEYDOWN: addKeyToBuffer(event.kbd); break; case Common::EVENT_KEYUP: break; case Common::EVENT_MOUSEMOVE: mouseX = event.mouse.x; mouseY = event.mouse.y; break; case Common::EVENT_LBUTTONDOWN: leftMouseButton = 1; break; case Common::EVENT_LBUTTONUP: leftMouseButton = 0; break; case Common::EVENT_RBUTTONDOWN: // We changed semantic and react only on button up event break; case Common::EVENT_RBUTTONUP: rightMouseButton = 1; break; case Common::EVENT_QUIT: // TODO endChapter(); _system->quit(); break; default: break; } } } void DrasculaEngine::delay(int ms) { uint32 end = _system->getMillis() + ms * 2; // originally was 1 do { _system->delayMillis(10); updateEvents(); _system->updateScreen(); } while (_system->getMillis() < end); }
void Util::processInput(bool scroll) { Common::Event event; Common::EventManager *eventMan = g_system->getEventManager(); int16 x = 0, y = 0; bool hasMove = false; _vm->_vidPlayer->updateLive(); while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: hasMove = true; x = event.mouse.x; y = event.mouse.y; break; case Common::EVENT_LBUTTONDOWN: _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) | ((uint32) kMouseButtonsLeft)); break; case Common::EVENT_RBUTTONDOWN: _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) | ((uint32) kMouseButtonsRight)); break; case Common::EVENT_LBUTTONUP: _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsLeft)); break; case Common::EVENT_RBUTTONUP: _mouseButtons = (MouseButtons) (((uint32) _mouseButtons) & ~((uint32) kMouseButtonsRight)); break; case Common::EVENT_KEYDOWN: if (event.kbd.hasFlags(Common::KBD_CTRL)) { if (event.kbd.keycode == Common::KEYCODE_f) _fastMode ^= 1; else if (event.kbd.keycode == Common::KEYCODE_g) _fastMode ^= 2; else if (event.kbd.keycode == Common::KEYCODE_p) _vm->pauseGame(); else if (event.kbd.keycode == Common::KEYCODE_d) { _vm->getDebugger()->attach(); _vm->getDebugger()->onFrame(); } break; } addKeyToBuffer(event.kbd); break; case Common::EVENT_KEYUP: break; default: break; } } _vm->_global->_speedFactor = MIN(_fastMode + 1, 3); if (hasMove && scroll) { x = CLIP(x, _vm->_global->_mouseMinX, _vm->_global->_mouseMaxX); y = CLIP(y, _vm->_global->_mouseMinY, _vm->_global->_mouseMaxY); x -= _vm->_video->_screenDeltaX; y -= _vm->_video->_screenDeltaY; _vm->_util->setMousePos(x, y); _vm->_game->wantScroll(x, y); // WORKAROUND: // Force a check of the mouse in order to fix the sofa bug. This apply only for Gob3, and only // in the impacted TOT file so that the second screen animation is not broken. if ((_vm->getGameType() == kGameTypeGob3) && !scumm_stricmp(_vm->_game->_curTotFile, "EMAP1008.TOT")) _vm->_game->evaluateScroll(); } }
void TTwaitForChar(void) { #if MEOPT_MOUSE union REGS rg ; if(meMouseCfg & meMOUSE_ENBLE) { meUShort mc ; meUInt arg ; /* If mouse state flags that the mouse should be visible then we * must make it visible. We had to make it invisible to get the * screen-updates correct */ if(mouseState & MOUSE_STATE_SHOW) { mouseState |= MOUSE_STATE_VISIBLE ; rg.x.ax = 0x0001 ; int86(0x33, &rg, &rg) ; } /* If no keys left then if theres currently no mouse timer and * theres a button press (No mouse-time key) then check for a * time-mouse-? key, if found add a timer start a mouse checking */ if(!isTimerActive(MOUSE_TIMER_ID) && ((mc=(mouseState & MOUSE_STATE_BUTTONS)) != 0)) { mc = ME_SPECIAL | TTmodif | (SKEY_mouse_time+mouseKeys[mc]) ; if((!TTallKeys && (decode_key(mc,&arg) != -1)) || (TTallKeys & 0x2)) { /* Start a timer and move to timed state 1 */ /* Start a new timer to clock in at 'delay' intervals */ /* printf("Setting mouse timer for delay %1x %1x %d\n",TTallKeys,meTimerState[MOUSE_TIMER_ID],delayTime) ;*/ timerSet(MOUSE_TIMER_ID,-1,delayTime); } } } #endif #if MEOPT_CALLBACK /* IDLE TIME: Check the idle time events */ if(kbdmode == meIDLE) /* Check the idle event */ doIdlePickEvent() ; #endif for(;;) { handleTimerExpired() ; if(TTahead()) break ; #if MEOPT_MOUSE if(meMouseCfg & meMOUSE_ENBLE) { meShort row, col, but ; meUShort cc ; /* Get new mouse status. It appears that the fractional bits of * the mouse change across reads. ONLY Compare the non-fractional * components. */ rg.x.ax = 0x0003 ; int86(0x33, &rg, &rg) ; but = rg.x.bx & MOUSE_STATE_BUTTONS ; col = rg.x.cx>>3 ; row = rg.x.dx>>3 ; /* Check for mouse state changes */ if(((mouseState ^ but) & MOUSE_STATE_BUTTONS) || (mouse_X != col) || (mouse_Y != row)) { int ii ; /* Get shift status */ rg.h.ah = 0x02; int86(0x16,&rg,&rg) ; TTmodif = ((rg.h.al & 0x01) << 8) | ((rg.h.al & 0x0E) << 7) ; /* Record the new mouse positions */ mouse_X = col ; mouse_Y = row ; /* Check for button changes, these always create keys */ if((mouseState ^ but) & MOUSE_STATE_BUTTONS) { /* Iterate down the bit pattern looking for changes * of state */ for (ii=1 ; ii<8 ; ii<<=1) { /* Test each key and add to the stack */ if((mouseState ^ but) & ii) { /* Up or down press ?? */ if(but & ii) cc = ME_SPECIAL+SKEY_mouse_pick_1-1 ; /* Down */ else cc = ME_SPECIAL+SKEY_mouse_drop_1-1 ; /* Up !! */ cc = TTmodif | (cc + mouseKeys[ii]) ; addKeyToBuffer(cc) ; } } /* Correct the mouse state */ mouseState = (mouseState & ~MOUSE_STATE_BUTTONS) | but ; } else { meUInt arg; /* Decode key argument */ /* Check for a mouse-move key */ cc = (ME_SPECIAL+SKEY_mouse_move+mouseKeys[but]) | TTmodif ; /* Are we after all movements or mouse-move bound ?? */ if((!TTallKeys && (decode_key(cc,&arg) != -1)) || (TTallKeys & 0x1)) addKeyToBuffer(cc) ; /* Add key to keyboard buffer */ else { /* Mouse has been moved so we must make it visible */ if(!(mouseState & MOUSE_STATE_VISIBLE)) { mouseState |= MOUSE_STATE_VISIBLE ; rg.x.ax = 0x0001 ; int86(0x33, &rg, &rg) ; } continue ; } } /* As we are adding a mouse key, the mouse is active * so add the 'show' flag, so on entry next time * the mouse will automatically become visible. */ mouseState |= MOUSE_STATE_SHOW ; break ; } } #endif } /* ' for' */
void TTgetkeyc(void) { union REGS rg ; meUShort ii ; meUByte cc ; /* call the dos to get a char */ rg.h.ah = 7; /* dos Direct Console Input call */ intdos(&rg, &rg); cc = rg.h.al; /* grab the char */ rg.h.ah = 0x02; /* get shift status */ int86(0x16,&rg,&rg) ; TTmodif = ((rg.h.al & 0x01) << 8) | ((rg.h.al & 0x0E) << 7) ; #ifdef _DEBUG_KEYS if(dklog==NULL) dklog = fopen("log","w+") ; #endif if(cc == 0) { rg.h.ah = 0x07 ; /* dos Direct Console Input call */ intdos(&rg, &rg) ; cc = TTextkey_lut[rg.h.al] ; #ifdef _DEBUG_KEYS fprintf(dklog,"special key, mode 0x%04x - cc %d al = %d\n",TTmodif,rg.h.al,cc) ; #endif if(cc & ME_EXT_FLAG) ii = (cc & 0x7f) | TTmodif ; else return_spec: ii = ME_SPECIAL | cc | TTmodif ; } else { #ifdef _DEBUG_KEYS fprintf(dklog,"normal key, mode 0x%04x - cc %d\n",TTmodif,cc) ; #endif if(cc == 0x7f) { if(TTmodif) cc = SKEY_backspace ; else cc = SKEY_delete ; goto return_spec ; } if((TTmodif & ME_CONTROL) == 0) { if(cc == 0x08) { cc = SKEY_backspace ; goto return_spec ; } if(cc == 0x09) { cc = SKEY_tab ; goto return_spec ; } if(cc == 0x0d) { cc = SKEY_return ; goto return_spec ; } if(cc == 0x1b) { cc = SKEY_esc ; goto return_spec ; } } if(cc == 0x20) ii = cc | (TTmodif & (ME_CONTROL|ME_ALT)) ; else ii = cc ; } addKeyToBuffer(ii) ; #if MEOPT_MOUSE /* If the mouse is active and flagged to show, as the user has pressed a * key, we should now flag to not automatically show the mouse. */ mouseState &= ~MOUSE_STATE_SHOW ; #endif }