]> git.lizzy.rs Git - shadowclad.git/blob - src/engine/input.c
Add copyright and license notices in source code
[shadowclad.git] / src / engine / input.c
1 /**
2  * Copyright 2020 Iwo 'Outfrost' Bujkiewicz
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8
9 #include "input.h"
10
11 #include <stdbool.h>
12
13 #include "_prelude.h"
14 #include "render.h"
15
16 static void (*keyboardInputCallback) (int, int, int, int);
17
18
19
20 void onKeyboardEvent(GLFWwindow* window UNUSED, int key, int scancode, int action, int mods) {
21         if (!(mods & GLFW_MOD_CONTROL)) {
22                 if (keyboardInputCallback) {
23                         keyboardInputCallback(key, scancode, action, mods);
24                 }
25                 return;
26         }
27
28         switch (key) {
29                 case GLFW_KEY_1:
30                         if (action == GLFW_PRESS) {
31                                 debugScene = !debugScene;
32                         }
33                         break;
34                 case GLFW_KEY_2:
35                         if (action == GLFW_PRESS) {
36                                 debugRender = !debugRender;
37                         }
38                         break;
39                 default:
40                         break;
41         }
42 }
43
44 void setKeyboardInputCallback(void (*callback) (int, int, int, int)) {
45         keyboardInputCallback = callback;
46 }