// glutKeyboardFunc is called below to set this function to handle // all normal key presses. static void KeyPressFunc( unsigned char Key, int x, int y ) { switch ( Key ) { case 'R': case 'r': Key_r(); break; case 's': case 'S': Key_s(); break; case 27: // Escape key exit(1); } }
void handleKeypress(int theKey, int theAction) { // If a key is pressed, toggle the relevant key-press flag if (theAction == GLFW_PRESS) { switch (theKey) { case 'W': cam->holdingForward = true; break; case 'S': cam->holdingBackward = true; break; case 'A': cam->holdingLeftStrafe = true; break; case 'D': cam->holdingRightStrafe = true; break; case 'Q': cam->holdingUp = true; break; case 'E': cam->holdingDown = true; break; case 'M': case 'm': //Mudar o tipo de janela changeGameModeActive = true; break; case GLFW_KEY_UP: spinMode = true; holdingMoreSimulationSpeed = true; break; case GLFW_KEY_DOWN: holdingLessSimulationSpeed = true; break; default: // Do nothing... break; } } else // If a key is released, toggle the relevant key-release flag { switch (theKey) { case 'W': cam->holdingForward = false; break; case 'S': cam->holdingBackward = false; break; case 'A': cam->holdingLeftStrafe = false; break; case 'D': cam->holdingRightStrafe = false; break; case 'Q': cam->holdingUp = false; break; case 'E': cam->holdingDown = false; break; case GLFW_KEY_UP: holdingMoreSimulationSpeed = false; simulationSpeedChangeAcceleration = simulationSpeedChangeAccelerationOriginal; break; case GLFW_KEY_DOWN: holdingLessSimulationSpeed = false; simulationSpeedChangeAcceleration = simulationSpeedChangeAccelerationOriginal; break; case 'R': case 'r': Key_r(); break; case 'O': case 'o': drawOrbits = !drawOrbits; break; case 'M': case 'm': //Mudar o tipo de janela if (changeGameModeActive){ changeWindowMode(); changeGameModeActive = false; } break; case 'C': case 'c': //Tentativa de manter as posições, não funciona bem, //teria que ser mais trabalhado. /*if (arcCam){ cam->setPositionX(arcCamX); cam->setPositionY(arcCamY); cam->setPositionZ(arcCamZ); } else{ arcCamX = cam->getXPos(); arcCamY = cam->getYPos(); arcCamZ = cam->getZPos(); }*/ arcCamRadius = 100; arcCam = !arcCam; break; case 27: // tecla esc exit(1); default: // Do nothing... break; } } }