input.c (892B)
1 #include "input.h" 2 3 void UserInput_init(UserInput *input, GLFWwindow *window) 4 { 5 f64 mx, my; 6 glfwGetCursorPos(window, &mx, &my); 7 input->rotation_dx = 0.0f; 8 input->mouse_x = mx; 9 input->rotation_dy = 0.0f; 10 input->mouse_y = my; 11 12 input->move_dx = 0.0f; 13 input->move_dy = 0.0f; 14 input->move_dz = 0.0f; 15 } 16 17 void UserInput_update(UserInput *input, GLFWwindow *window) 18 { 19 f64 mx, my; 20 glfwGetCursorPos(window, &mx, &my); 21 input->rotation_dx = mx - input->mouse_x; 22 input->mouse_x = mx; 23 input->rotation_dy = my - input->mouse_y; 24 input->mouse_y = my; 25 26 input->move_dx = glfwGetKey(window, GLFW_KEY_D) 27 - glfwGetKey(window, GLFW_KEY_A); 28 input->move_dy = glfwGetKey(window, GLFW_KEY_SPACE) 29 - glfwGetKey(window, GLFW_KEY_LEFT_SHIFT); 30 input->move_dz = glfwGetKey(window, GLFW_KEY_W) 31 - glfwGetKey(window, GLFW_KEY_S); 32 33 }