]> git.lizzy.rs Git - shadowclad.git/blob - src/engine/input.c
Create keybinds for scene and render debug functionalities
[shadowclad.git] / src / engine / input.c
1 #include "input.h"
2
3 #include <stdbool.h>
4
5 #include "render.h"
6
7 static void (*keyboardInputCallback) (int, int, int, int);
8
9
10
11 void onKeyboardEvent(GLFWwindow* window, int key, int scancode, int action, int mods) {
12         if (!(mods & GLFW_MOD_CONTROL)) {
13                 if (keyboardInputCallback) {
14                         keyboardInputCallback(key, scancode, action, mods);
15                 }
16                 return;
17         }
18
19         switch (key) {
20                 case GLFW_KEY_1:
21                         if (action == GLFW_PRESS) {
22                                 debugScene = !debugScene;
23                         }
24                         break;
25                 case GLFW_KEY_2:
26                         if (action == GLFW_PRESS) {
27                                 debugRender = !debugRender;
28                         }
29                         break;
30                 default:
31                         break;
32         }
33 }
34
35 void setKeyboardInputCallback(void (*callback) (int, int, int, int)) {
36         keyboardInputCallback = callback;
37 }