Exemplo n.º 1
0
void Events::pollEvents() {
	checkForNextFrameCounter();

	Common::Event event;
	if (!g_system->getEventManager()->pollEvent(event))
		return;

	switch (event.type) {
	case Common::EVENT_MOUSEMOVE:
		_mousePos = event.mouse;
		eventTarget()->mouseMove(_mousePos);
		break;
	case Common::EVENT_LBUTTONDOWN:
		_specialButtons |= MK_LBUTTON;
		_mousePos = event.mouse;
		eventTarget()->leftButtonDown(_mousePos);
		break;
	case Common::EVENT_LBUTTONUP:
		_specialButtons &= ~MK_LBUTTON;
		_mousePos = event.mouse;
		eventTarget()->leftButtonUp(_mousePos);
		break;
	case Common::EVENT_MBUTTONDOWN:
		_specialButtons |= MK_MBUTTON;
		_mousePos = event.mouse;
		eventTarget()->middleButtonDown(_mousePos);
		break;
	case Common::EVENT_MBUTTONUP:
		_specialButtons &= ~MK_MBUTTON;
		_mousePos = event.mouse;
		eventTarget()->middleButtonUp(_mousePos);
		break;
	case Common::EVENT_RBUTTONDOWN:
		_specialButtons |= MK_RBUTTON;
		_mousePos = event.mouse;
		eventTarget()->rightButtonDown(_mousePos);
		break;
	case Common::EVENT_RBUTTONUP:
		_specialButtons &= ~MK_RBUTTON;
		_mousePos = event.mouse;
		eventTarget()->rightButtonUp(_mousePos);
		break;
	case Common::EVENT_WHEELUP:
	case Common::EVENT_WHEELDOWN:
		_mousePos = event.mouse;
		eventTarget()->mouseWheel(_mousePos, event.type == Common::EVENT_WHEELUP);
		break;
	case Common::EVENT_KEYDOWN:
		handleKbdSpecial(event.kbd);
		eventTarget()->keyDown(event.kbd);
		break;
	case Common::EVENT_KEYUP:
		handleKbdSpecial(event.kbd);
		eventTarget()->keyUp(event.kbd);
		break;
	default:
		break;
	}
}
Exemplo n.º 2
0
void EventsManager::pollEvents() {
    checkForNextFrameCounter();
    _mouseMoved = false;

    Common::Event event;
    while (g_system->getEventManager()->pollEvent(event)) {
        // Handle keypress
        switch (event.type) {
        case Common::EVENT_QUIT:
        case Common::EVENT_RTL:
            return;

        case Common::EVENT_KEYDOWN:
            // Check for debugger
            if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) {
                // Attach to the debugger
                _vm->_debugger->attach();
                _vm->_debugger->onFrame();
            } else {
                _pendingKeys.push(event);
            }
            return;
        case Common::EVENT_KEYUP:
            return;
        case Common::EVENT_LBUTTONDOWN:
        case Common::EVENT_RBUTTONDOWN:
            _mouseClicked = true;
            _mouseButtons = 1;
            _mouseMoved = true;
            if (event.type == Common::EVENT_RBUTTONDOWN) {
                _rightMousePressed = true;
                _mouseStatus |= 2;
            } else {
                _mouseStatus |= 1;
            }
            return;
        case Common::EVENT_LBUTTONUP:
        case Common::EVENT_RBUTTONUP:
            _mouseClicked = false;
            _mouseReleased = true;
            _mouseMoved = true;
            _rightMousePressed = false;
            if (event.type == Common::EVENT_RBUTTONUP) {
                _mouseStatus &= ~2;
            } else {
                _mouseStatus &= ~1;
            }
            return;
        case Common::EVENT_MOUSEMOVE:
            _mousePos = event.mouse;
            _currentPos = event.mouse;
            _mouseMoved = true;
            break;
        default:
            break;
        }
    }
}
Exemplo n.º 3
0
void Events::pollEvents() {
	checkForNextFrameCounter();

	Common::Event event;
	if (!g_system->getEventManager()->pollEvent(event))
		return;

	switch (event.type) {
	case Common::EVENT_MOUSEMOVE:
		_mousePos = event.mouse;
		eventTarget()->mouseMove(_mousePos);
		break;
	case Common::EVENT_LBUTTONDOWN:
		_mousePos = event.mouse;
		eventTarget()->leftButtonDown(_mousePos);
		break;
	case Common::EVENT_LBUTTONUP:
		_mousePos = event.mouse;
		eventTarget()->leftButtonUp(_mousePos);
		break;
	case Common::EVENT_MBUTTONDOWN:
		_mousePos = event.mouse;
		eventTarget()->middleButtonDown(_mousePos);
		break;
	case Common::EVENT_MBUTTONUP:
		_mousePos = event.mouse;
		eventTarget()->middleButtonUp(_mousePos);
		break;
	case Common::EVENT_RBUTTONDOWN:
		_mousePos = event.mouse;
		eventTarget()->rightButtonDown(_mousePos);
		break;
	case Common::EVENT_RBUTTONUP:
		_mousePos = event.mouse;
		eventTarget()->rightButtonUp(_mousePos);
		break;
	case Common::EVENT_KEYDOWN:
		eventTarget()->keyDown(event.kbd);
		break;
	case Common::EVENT_KEYUP:
		eventTarget()->keyUp(event.kbd);
		break;
	default:
		break;
	}
}
Exemplo n.º 4
0
void Events::pollEvents() {
	checkForNextFrameCounter();

	Common::Event event;
	while (g_system->getEventManager()->pollEvent(event)) {
		_mousePos = event.mouse;

		// Handle events
		switch (event.type) {
		case Common::EVENT_QUIT:
		case Common::EVENT_RTL:
			return;

		case Common::EVENT_KEYDOWN:
			// Check for debugger
			if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) {
				// Attach to the debugger
				_vm->_debugger->attach();
				_vm->_debugger->onFrame();
			} else {
				_pendingKeys.push(event.kbd);
			}
			return;
		case Common::EVENT_KEYUP:
			return;
		case Common::EVENT_LBUTTONDOWN:
			_mouseButtons |= LEFT_BUTTON;
			return;
		case Common::EVENT_RBUTTONDOWN:
			_mouseButtons |= RIGHT_BUTTON;
			return;
		case Common::EVENT_LBUTTONUP:
			_mouseButtons &= ~LEFT_BUTTON;
			return;
		case Common::EVENT_RBUTTONUP:
			_mouseButtons &= ~RIGHT_BUTTON;
			return;
		default:
 			break;
		}
	}
}
Exemplo n.º 5
0
bool Events::waitForPress(uint expiry) {
	uint32 delayEnd = g_system->getMillis() + expiry;

	while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
		g_system->delayMillis(10);
		checkForNextFrameCounter();

		Common::Event event;
		if (g_system->getEventManager()->pollEvent(event)) {
			switch (event.type) {
			case Common::EVENT_LBUTTONDOWN:
			case Common::EVENT_MBUTTONDOWN:
			case Common::EVENT_KEYDOWN:
				return true;
			default:
				break;
			}
		}
	}

	return false;
}
Exemplo n.º 6
0
void EventsManager::pollEvents(bool skipTimers) {
	if (checkForNextFrameCounter()) {
		nextFrame();
	}

	if (checkForNextTimerUpdate() && !skipTimers)
		nextTimer();

	_vm->_sound->checkSoundQueue();

	_wheelUp = _wheelDown = false;

	Common::Event event;
	while (g_system->getEventManager()->pollEvent(event)) {
		switch (event.type) {
		case Common::EVENT_QUIT:
		case Common::EVENT_RTL:
			return;

		case Common::EVENT_KEYDOWN:
			// Check for debugger
			if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) {
				// Attach to the debugger
				_vm->_debugger->attach();
				_vm->_debugger->onFrame();
			} else {
				keyControl(event.kbd.keycode, true);
			}
			return;
		case Common::EVENT_KEYUP:
			keyControl(event.kbd.keycode, false);
			return;
		case Common::EVENT_MOUSEMOVE:
			_mousePos = event.mouse;
			_mouseCol = _mousePos.x / 8;
			_mouseRow = _mousePos.y / 8;
			break;
		case Common::EVENT_LBUTTONDOWN:
			_leftButton = true;
			return;
		case Common::EVENT_LBUTTONUP:
			_leftButton = false;
			return;
		case Common::EVENT_RBUTTONDOWN:
			_rightButton = true;
			return;
		case Common::EVENT_RBUTTONUP:
			_rightButton = false;
			return;
		case Common::EVENT_MBUTTONDOWN:
			_middleButton = true;
			return;
		case Common::EVENT_MBUTTONUP:
			_middleButton = false;
			return;
		case Common::EVENT_WHEELUP:
			_wheelUp = true;
			return;
		case Common::EVENT_WHEELDOWN:
			_wheelDown = true;
			return;
		default:
 			break;
		}
	}
}