]> git.lizzy.rs Git - shadowclad.git/blob - src/game/input.c
Add copyright and license notices in source code
[shadowclad.git] / src / game / 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 <GLFW/glfw3.h>
12
13 #include "engine/_prelude.h"
14
15 #include "player.h"
16
17 void keyboardInput(int key, int scancode UNUSED, int action, int mods UNUSED) {
18         switch (key) {
19                 case GLFW_KEY_W:
20                         if (action == GLFW_PRESS) {
21                                 startMovement(DIRECTION_UP);
22                         }
23                         else if (action == GLFW_RELEASE) {
24                                 stopMovement(DIRECTION_UP);
25                         }
26                         break;
27                 case GLFW_KEY_S:
28                         if (action == GLFW_PRESS) {
29                                 startMovement(DIRECTION_DOWN);
30                         }
31                         else if (action == GLFW_RELEASE) {
32                                 stopMovement(DIRECTION_DOWN);
33                         }
34                         break;
35                 case GLFW_KEY_A:
36                         if (action == GLFW_PRESS) {
37                                 startMovement(DIRECTION_LEFT);
38                         }
39                         else if (action == GLFW_RELEASE) {
40                                 stopMovement(DIRECTION_LEFT);
41                         }
42                         break;
43                 case GLFW_KEY_D:
44                         if (action == GLFW_PRESS) {
45                                 startMovement(DIRECTION_RIGHT);
46                         }
47                         else if (action == GLFW_RELEASE) {
48                                 stopMovement(DIRECTION_RIGHT);
49                         }
50                         break;
51                 default:
52                         break;
53         }
54 }