Beispiel #1
0
void GraphicsImpl::handleKeyEvents(const DataContainer& data)
{
	InputKeyboardEvent ev = boost::any_cast<InputKeyboardEvent>(data.data);

	if (ev.action == BUTTON_PRESSED) {
		gui->injectKeyPress((MyGUI::KeyCode::Enum) ev.type);

		if (ev.type == KEY_W) {
			movementVector.z = -1;
		}

		else if (ev.type == KEY_S) {
			movementVector.z = 1;
		}

		else if (ev.type == KEY_A) {
			movementVector.x = -1;
		}

		else if (ev.type == KEY_D) {
			movementVector.x = 1;
		}
	}

	else {
		gui->injectKeyRelease((MyGUI::KeyCode::Enum) ev.type);

		if (ev.type == KEY_W) {
			movementVector.z = 0;
		}

		else if (ev.type == KEY_S) {
			movementVector.z = 0;
		}

		else if (ev.type == KEY_A) {
			movementVector.x = 0;
		}

		else if (ev.type == KEY_D) {
			movementVector.x = 0;
		}
	}
}
Beispiel #2
0
	bool keyReleased(const OIS::KeyEvent &arg)
	{
		mGUI->injectKeyRelease(arg);
		return true;
	}