fix: gamepad integration with upgrade module

This commit is contained in:
Szymon Szczubkowski 2024-02-08 02:36:34 +01:00
parent b8e72defc7
commit 383f7eaf90

View File

@ -121,7 +121,6 @@ void processInput(GLFWwindow* window)
float cameraSpeed = 0.1f * deltaTime * 15;
if (engineIs == 2)
//cameraSpeed = cameraSpeed * 1.8;//1.5;
cameraSpeed = 0.1f * deltaTime * 15 * 1.8;
if (!glfwJoystickIsGamepad(GLFW_JOYSTICK_1)) {
@ -134,9 +133,6 @@ void processInput(GLFWwindow* window)
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
engineIs = 2;
}
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
spaceshipPos += cameraSpeed * spaceshipDir;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@ -154,15 +150,14 @@ void processInput(GLFWwindow* window)
engineIs = 2;
}
if(currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER] > 0.01)
spaceshipPos += deltaTime * 5 * spaceshipDir * currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER];
spaceshipPos += cameraSpeed * 2 * spaceshipDir * currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER];
if (currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER] > 0.01)
spaceshipPos -= deltaTime * 5 * spaceshipDir * currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER];
spaceshipPos -= cameraSpeed * 2 * spaceshipDir * currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER];
if (abs(currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_X]) > 0.01)
spaceshipDir = glm::vec3(glm::eulerAngleY(deltaTime * -5 * currentState.axes[GLFW_GAMEPAD_AXIS_LEFT_X]) * glm::vec4(spaceshipDir, 0));
if (abs(currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y]) > 0.01)
spaceshipDir.y = currentState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y]/3;
}
std::cout << glm::to_string(spaceshipDir) << std::endl;
cameraDir = spaceshipDir;
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.05f;
}