bool keyPressed(const OIS::KeyEvent &arg) { switch (arg.key) { case OIS::KC_ESCAPE: mExit = true; break; default: break; } mGUI->injectKeyPress(arg); return true; }
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; } } }