12 static void cursor_pos_callback(__attribute__((unused)) GLFWwindow* window, double current_x, double current_y)
14 static double last_x, last_y = 0.0;
16 double delta_x = current_x - last_x;
17 double delta_y = current_y - last_y;
21 input.client->player.yaw += (f32) delta_x * M_PI / 180.0f / 8.0f;
22 input.client->player.pitch -= (f32) delta_y * M_PI / 180.0f / 8.0f;
24 input.client->player.pitch = fmax(fmin(input.client->player.pitch, 89.0f), -89.0f);
26 set_camera_angle(input.client->player.yaw, input.client->player.pitch);
29 static bool move(int forward, int backward, vec3 dir)
34 if (glfwGetKey(input.window, forward) == GLFW_PRESS)
36 else if (glfwGetKey(input.window, backward) == GLFW_PRESS)
41 input.client->player.velocity.x += dir[0] * speed * sign;
42 // input.client->player.velocity.y += dir[1] * speed * sign;
43 input.client->player.velocity.z += dir[2] * speed * sign;
50 input.client->player.velocity.x = 0.0f;
51 // input.client->player.velocity.y = 0.0f;
52 input.client->player.velocity.z = 0.0f;
54 move(GLFW_KEY_W, GLFW_KEY_S, movement_dirs.front);
55 move(GLFW_KEY_SPACE, GLFW_KEY_LEFT_SHIFT, movement_dirs.up);
56 move(GLFW_KEY_D, GLFW_KEY_A, movement_dirs.right);
59 void init_input(Client *client, GLFWwindow *window)
61 input.client = client;
62 input.window = window;
64 glfwSetCursorPosCallback(input.window, &cursor_pos_callback);