本文整理汇总了C++中common::EventManager::pollEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventManager::pollEvent方法的具体用法?C++ EventManager::pollEvent怎么用?C++ EventManager::pollEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::EventManager
的用法示例。
在下文中一共展示了EventManager::pollEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateEvents
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());
}
示例2: handleEvents
void BladeRunnerEngine::handleEvents() {
if (shouldQuit()) {
_gameIsRunning = false;
return;
}
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYUP:
handleKeyUp(event);
break;
case Common::EVENT_KEYDOWN:
handleKeyDown(event);
break;
case Common::EVENT_LBUTTONUP:
handleMouseAction(event.mouse.x, event.mouse.y, true, false);
break;
case Common::EVENT_RBUTTONUP:
case Common::EVENT_MBUTTONUP:
handleMouseAction(event.mouse.x, event.mouse.y, false, false);
break;
case Common::EVENT_LBUTTONDOWN:
handleMouseAction(event.mouse.x, event.mouse.y, true, true);
break;
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_MBUTTONDOWN:
handleMouseAction(event.mouse.x, event.mouse.y, false, true);
break;
default:
; // nothing to do
}
}
}
示例3: processVideoEvents
void VideoPlayer::processVideoEvents(Common::List<Common::Event> &stopEvents) {
Common::Event curEvent;
Common::EventManager *eventMan = g_system->getEventManager();
// Process events, and skip video if esc is pressed
while (eventMan->pollEvent(curEvent)) {
if (curEvent.type == Common::EVENT_RTL || curEvent.type == Common::EVENT_QUIT) {
_skipVideo = true;
}
for (Common::List<Common::Event>::const_iterator iter = stopEvents.begin(); iter != stopEvents.end(); iter++) {
if (curEvent.type == iter->type) {
if (iter->type == Common::EVENT_KEYDOWN || iter->type == Common::EVENT_KEYUP) {
if (curEvent.kbd.keycode == iter->kbd.keycode) {
_skipVideo = true;
break;
}
} else {
_skipVideo = true;
break;
}
}
}
}
}
示例4: keystrokeToChar
char EventTests::keystrokeToChar() {
Common::EventManager *eventMan = g_system->getEventManager();
bool quitLoop = false;
Common::Event event;
// handle all keybd events
while (!quitLoop) {
while (eventMan->pollEvent(event)) {
// Quit if explicitly requested!
if (Engine::shouldQuit()) {
return 0;
}
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
return 0;
}
for (int i = 0; i < ARRAYSIZE(keyCodeLUT); i++) {
if (event.kbd.keycode == keyCodeLUT[i].code) {
return keyCodeLUT[i].value;
}
}
break;
default:
break; // Ignore other events
}
}
}
return 0;
}
示例5: escDelay
bool Intro::escDelay(uint32 msecs) {
Common::EventManager *eventMan = _system->getEventManager();
Common::Event event;
if (_relDelay == 0) // first call, init with system time
_relDelay = (int32)_system->getMillis();
_relDelay += msecs; // now wait until _system->getMillis() >= _relDelay
int32 nDelay = 0;
do {
while (eventMan->pollEvent(event)) {
if (event.type == Common::EVENT_KEYDOWN) {
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
return false;
} else if (event.type == Common::EVENT_QUIT || event.type == Common::EVENT_RTL) {
return false;
}
}
nDelay = _relDelay - _system->getMillis();
if (nDelay < 0)
nDelay = 0;
else if (nDelay > 20)
nDelay = 20;
_system->delayMillis(nDelay);
_skyScreen->processSequence();
_system->updateScreen();
} while (nDelay == 20);
return true;
}
示例6: waitForMusicToPlay
void MidiTests::waitForMusicToPlay(MidiParser *parser) {
Common::EventManager *eventMan = g_system->getEventManager();
bool quitLoop = false;
Common::Event event;
CursorMan.showMouse(true);
while (!quitLoop) {
while (eventMan->pollEvent(event)) {
// Quit if explicitly requested!
if (Engine::shouldQuit()) {
return;
}
if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_RBUTTONDOWN) {
quitLoop = true;
} else {
Testsuite::writeOnScreen("Playing Midi Music, Click to end", Common::Point(0, 100));
if (!parser->isPlaying()) {
quitLoop = true;
}
}
}
}
CursorMan.showMouse(false);
return;
}
示例7: handleNextFrame
void MoviePlayer::handleNextFrame() {
Common::Event event;
Common::EventManager *eventMan = _vm->_system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
_leftButtonDown = true;
_rightButtonDown = true;
} else if (event.kbd.keycode == Common::KEYCODE_PAUSE) {
_vm->pause();
}
break;
case Common::EVENT_LBUTTONDOWN:
_leftButtonDown = true;
break;
case Common::EVENT_RBUTTONDOWN:
_rightButtonDown = true;
break;
case Common::EVENT_LBUTTONUP:
_leftButtonDown = false;
break;
case Common::EVENT_RBUTTONUP:
_rightButtonDown = false;
break;
default:
break;
}
}
if (_leftButtonDown && _rightButtonDown && !_vm->getBitFlag(41)) {
_skipMovie = true;
_mixer->stopHandle(_bgSound);
}
}
示例8: mainLoop
void NeverhoodEngine::mainLoop() {
uint32 nextFrameTime = 0;
while (!shouldQuit()) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) {
// Open debugger console
_console->attach();
continue;
}
_gameModule->handleKeyDown(event.kbd.keycode);
_gameModule->handleAsciiKey(event.kbd.ascii);
break;
case Common::EVENT_KEYUP:
break;
case Common::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
_gameModule->handleMouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
_gameModule->handleMouseDown(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
_gameModule->handleMouseUp(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_WHEELUP:
_gameModule->handleWheelUp();
break;
case Common::EVENT_WHEELDOWN:
_gameModule->handleWheelDown();
break;
default:
break;
}
}
if (_system->getMillis() >= nextFrameTime) {
_gameModule->checkRequests();
_gameModule->handleUpdate();
_gameModule->draw();
_console->onFrame();
_screen->update();
if (_updateSound)
_soundMan->update();
nextFrameTime = _screen->getNextFrameTime();
};
_audioResourceMan->updateMusic();
_system->updateScreen();
_system->delayMillis(10);
}
}
示例9: use
void Journal::use() {
BobSlot *joe = _vm->graphics()->bob(0);
_prevJoeX = joe->x;
_prevJoeY = joe->y;
_panelMode = PM_NORMAL;
_system = g_system;
_panelTextCount = 0;
memset(_panelTextY, 0, sizeof(_panelTextY));
memset(&_textField, 0, sizeof(_textField));
memset(_saveDescriptions, 0, sizeof(_saveDescriptions));
_vm->findGameStateDescriptions(_saveDescriptions);
setup();
redraw();
update();
_vm->display()->palFadeIn(ROOM_JOURNAL);
_quitMode = QM_LOOP;
while (_quitMode == QM_LOOP) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
handleKeyDown(event.kbd.ascii, event.kbd.keycode);
break;
case Common::EVENT_LBUTTONDOWN:
handleMouseDown(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_WHEELUP:
handleMouseWheel(-1);
break;
case Common::EVENT_WHEELDOWN:
handleMouseWheel(1);
break;
case Common::EVENT_RTL:
case Common::EVENT_QUIT:
return;
default:
break;
}
}
_system->delayMillis(20);
_system->updateScreen();
}
_vm->writeOptionSettings();
_vm->display()->clearTexts(0, GAME_SCREEN_HEIGHT - 1);
_vm->graphics()->putCameraOnBob(0);
if (_quitMode == QM_CONTINUE) {
continueGame();
}
}
示例10: handleEvents
void MadeEngine::handleEvents() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
// NOTE: Don't reset _eventNum to 0 here or no events will get through to the scripts.
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
_eventMouseX = event.mouse.x;
_eventMouseY = event.mouse.y;
break;
case Common::EVENT_LBUTTONDOWN:
_eventNum = 2;
break;
case Common::EVENT_LBUTTONUP:
_eventNum = 1;
break;
case Common::EVENT_RBUTTONDOWN:
_eventNum = 4;
break;
case Common::EVENT_RBUTTONUP:
_eventNum = 3;
break;
case Common::EVENT_KEYDOWN:
_eventKey = event.kbd.ascii;
// For unknown reasons, the game accepts ASCII code
// 9 as backspace
if (_eventKey == Common::KEYCODE_BACKSPACE)
_eventKey = 9;
_eventNum = 5;
break;
default:
break;
}
}
AudioCD.updateCD();
}
示例11: manageEvents
void manageEvents() {
Common::EventManager *eventMan = g_system->getEventManager();
uint32 nextFrame = g_system->getMillis() + g_cine->getTimerDelay();
do {
Common::Event event;
while (eventMan->pollEvent(event)) {
processEvent(event);
}
g_system->updateScreen();
g_system->delayMillis(20);
} while (g_system->getMillis() < nextFrame);
mouseData.left = mouseLeft;
mouseData.right = mouseRight;
}
示例12: mainLoop
void NeverhoodEngine::mainLoop() {
uint32 nextFrameTime = 0;
while (!shouldQuit()) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
_gameModule->handleKeyDown(event.kbd.keycode);
_gameModule->handleAsciiKey(event.kbd.ascii);
break;
case Common::EVENT_KEYUP:
break;
case Common::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
_gameModule->handleMouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
_gameModule->handleMouseDown(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
_gameModule->handleMouseUp(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_QUIT:
_system->quit();
break;
default:
break;
}
}
if (_system->getMillis() >= nextFrameTime) {
_gameModule->checkRequests();
_gameModule->handleUpdate();
_gameModule->draw();
_screen->update();
nextFrameTime = _screen->getNextFrameTime();
};
_soundMan->update();
_audioResourceMan->updateMusic();
_system->updateScreen();
_system->delayMillis(10);
}
}
示例13: mainLoop
void VirtualKeyboardGUI::mainLoop() {
Common::EventManager *eventMan = _system->getEventManager();
while (_displaying) {
if (_kbd->_keyQueue.hasStringChanged())
updateDisplay();
animateCaret();
animateCursor();
redraw();
_system->updateScreen();
Common::Event event;
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
if (_kbdBound.contains(event.mouse)) {
_kbd->handleMouseDown(event.mouse.x - _kbdBound.left,
event.mouse.y - _kbdBound.top);
}
break;
case Common::EVENT_LBUTTONUP:
if (_kbdBound.contains(event.mouse)) {
_kbd->handleMouseUp(event.mouse.x - _kbdBound.left,
event.mouse.y - _kbdBound.top);
}
break;
case Common::EVENT_MOUSEMOVE:
if (_drag)
move(event.mouse.x - _dragPoint.x,
event.mouse.y - _dragPoint.y);
break;
case Common::EVENT_SCREEN_CHANGED:
screenChanged();
break;
case Common::EVENT_QUIT:
_system->quit();
return;
default:
break;
}
}
// Delay for a moment
_system->delayMillis(10);
}
}
示例14: play
// TODO: this method will probably go away and be integrated in the main loop
void Animation::play() {
Common::EventManager *eventMan = g_system->getEventManager();
while (!hasEnded() && !Engine::shouldQuit()) {
process();
if (_changed) {
// Create a temporary surface to merge the overlay with the background
Graphics::Surface *s = new Graphics::Surface;
s->create(640, 480, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
draw(s);
// XXX: Update the screen
g_system->copyRectToScreen(s->getPixels(), s->pitch, 0, 0, s->w, s->h);
// Free the temporary surface
s->free();
delete s;
_changed = false;
}
g_system->updateScreen();
//FIXME: implement subtitles
g_system->delayMillis(20);
// Handle right-click to interrupt animations
Common::Event ev = Common::Event();
while (eventMan->pollEvent(ev)) {
if (ev.type == Common::EVENT_RBUTTONUP) {
// Stop audio
if (_audio)
_audio->finish();
// TODO start LNK file sound?
return;
}
}
}
}
示例15: handleInput
bool MoviePlayer::handleInput() {
Common::Event event;
Common::EventManager *eventMan = g_system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
return false;
break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
return false;
case Common::EVENT_QUIT:
_vm->quitGame();
return false;
default:
break;
}
}
return !_vm->shouldQuit();
}