-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinput.h
More file actions
38 lines (33 loc) · 1.22 KB
/
input.h
File metadata and controls
38 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Manejar la entrada
#pragma once
#include "debug.h"
namespace tofu::input
{
inline void keymaps() {
// Ver si el usuario quiere cerrar la ventana
if (gl.io.teclas[GLFW_KEY_LEFT_SHIFT].mantenida and gl.io.teclas[GLFW_KEY_Q].presionada)
glfwSetWindowShouldClose(gl.win, true);
// Cambiar el modo del ratón
if (gl.io.teclas[GLFW_KEY_ESCAPE].presionada) {
glfwSetInputMode(gl.win, GLFW_CURSOR, gl.raton_conectado ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
gl.raton_conectado = not gl.raton_conectado;
}
}
inline void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (action == GLFW_PRESS) {
gl.io.teclas[key].presionada = true;
gl.io.teclas[key].mantenida = true;
}
if (action == GLFW_RELEASE) {
gl.io.teclas[key].liberada = true;
gl.io.teclas[key].mantenida = false;
}
keymaps();
}
inline void mouseCallback(GLFWwindow* window, double xpos, double ypos) {
gl.io.mouse.xoff = xpos - gl.io.mouse.x;
gl.io.mouse.yoff = gl.io.mouse.y - ypos;
gl.io.mouse.x = xpos;
gl.io.mouse.y = ypos;
}
}