Ejemplo n.º 1
0
void Window::processEvents()
{
    if (m_eventQueue.empty() || !m_context)
        return;

    glfwMakeContextCurrent(m_window);

    while (!m_eventQueue.empty())
    {
        WindowEvent* event = m_eventQueue.front();
        m_eventQueue.pop();
        event->setWindow(this);

        processEvent(*event);

        delete event;

        if (!m_context)
        {
            clearEventQueue();
            return;
        }
    }

    glfwMakeContextCurrent(nullptr);
}
Ejemplo n.º 2
0
void GrimEngine::handleControls(Common::EventType operation, const Common::KeyState &key) {
	// Might also want to support keypad-enter?
	if (key.hasFlags(Common::KBD_ALT) && key.keycode == Common::KEYCODE_RETURN && operation == Common::EVENT_KEYDOWN) {
		_changeFullscreenState = true;
	}

	if (key.hasFlags(Common::KBD_CTRL) && key.keycode == Common::KEYCODE_d && operation == Common::EVENT_KEYDOWN) {
		_debugger->attach();
		clearEventQueue();
		return;
	}
	// If we're not supposed to handle the key then don't
	if (!_controlsEnabled[key.keycode])
		return;

	LuaObjects objects;
	objects.add(key.keycode);
	if (operation == Common::EVENT_KEYDOWN) {
		objects.add(1);
		objects.add(1);
	} else {
		objects.addNil();
		objects.add(0);
	}
	objects.add(0);
	if (!LuaBase::instance()->callback("buttonHandler", objects)) {
		error("handleControls: invalid keys handler");
	}
	//  if (!LuaBase::instance()->callback("axisHandler", objects)) {
	//      error("handleControls: invalid joystick handler");
	//  }

	if (operation == Common::EVENT_KEYDOWN)
		_controlsState[key.keycode] = true;
	else if (operation == Common::EVENT_KEYUP)
		_controlsState[key.keycode] = false;
}