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
32 .name = "system_process_input",
33 .dependencies = 0,
34 .dependency_count = 0,
35 .entities_const = 0,
36 .entities_mut = 0,
38 .pin_to_main = false,
39 .resources =
41 .runner = system_process_input};
42
43#endif
@ SYSTEM_RESOURCE_MASK_RENDERING_CONTEXT
Definition require.h:70
@ SYSTEM_RESOURCE_MASK_INPUT
Definition require.h:69
@ SYSTEM_PHASE_PRE_UPDATE
Definition require.h:11
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:54
rendering_ctx_t * rendering_ctx
Definition require.h:55
Definition require.h:89
const char * name
Definition require.h:90
static void system_process_input(system_payload_t payload, allocator_t temporary_allocator)
Definition input.h:8
static system_requirements_declaration_t system_decl_process_input
Definition input.h:31