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