Subastra
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1#ifndef __H__SYSTEMS_INPUT__
2#define __H__SYSTEMS_INPUT__
3
4#include "require.h"
5
6#include "../engine/input.h"
7
9 allocator_t temporary_allocator) {
10 input_t *input = payload.input;
11 GLFWwindow *window = payload.rendering_ctx->window;
12
13 int keys[] = {GLFW_KEY_A, GLFW_KEY_D, GLFW_KEY_S, GLFW_KEY_W};
14 int *outs[] = {&input->left, &input->right, &input->down, &input->up};
15
16 for (int i = 0; i < 4; i++) {
17 int k = keys[i];
18 int state = glfwGetKey(window, k);
19
20 switch (state) {
21 case GLFW_PRESS:
22 *outs[i] = 1;
23 break;
24 case GLFW_RELEASE:
25 *outs[i] = 0;
26 break;
27 }
28 }
29}
30
31#endif
A generic allocator type passed by value. Contains a fallback allocator and a set of function pointer...
Definition memory.h:30
Definition input.h:10
i32 down
Definition input.h:11
i32 up
Definition input.h:11
i32 right
Definition input.h:11
i32 left
Definition input.h:11
GLFWwindow * window
Definition context.h:13
Definition require.h:51
input_t * input
Definition require.h:62
rendering_ctx_t * rendering_ctx
Definition require.h:63
static void system_process_input(system_req_t payload, allocator_t temporary_allocator)
Definition input.h:8