Subastra
Loading...
Searching...
No Matches
src
systems
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
8
static
void
system_process_input
(
system_payload_t
payload,
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
static
system_requirements_declaration_t
system_decl_process_input
= {
32
.
name
=
"system_process_input"
,
33
.dependencies = 0,
34
.dependency_count = 0,
35
.entities_const = 0,
36
.entities_mut = 0,
37
.phase =
SYSTEM_PHASE_PRE_UPDATE
,
38
.pin_to_main =
false
,
39
.resources =
40
SYSTEM_RESOURCE_MASK_INPUT
|
SYSTEM_RESOURCE_MASK_RENDERING_CONTEXT
,
41
.runner =
system_process_input
};
42
43
#endif
require.h
SYSTEM_RESOURCE_MASK_RENDERING_CONTEXT
@ SYSTEM_RESOURCE_MASK_RENDERING_CONTEXT
Definition
require.h:70
SYSTEM_RESOURCE_MASK_INPUT
@ SYSTEM_RESOURCE_MASK_INPUT
Definition
require.h:69
SYSTEM_PHASE_PRE_UPDATE
@ SYSTEM_PHASE_PRE_UPDATE
Definition
require.h:11
allocator_t
A generic allocator type passed by value. Contains a fallback allocator and a set of function pointer...
Definition
memory.h:30
input_t
Definition
input.h:10
input_t::down
i32 down
Definition
input.h:11
input_t::up
i32 up
Definition
input.h:11
input_t::right
i32 right
Definition
input.h:11
input_t::left
i32 left
Definition
input.h:11
rendering_ctx_t::window
GLFWwindow * window
Definition
context.h:13
system_payload_t
Definition
require.h:51
system_payload_t::input
input_t * input
Definition
require.h:54
system_payload_t::rendering_ctx
rendering_ctx_t * rendering_ctx
Definition
require.h:55
system_requirements_declaration_t
Definition
require.h:89
system_requirements_declaration_t::name
const char * name
Definition
require.h:90
system_process_input
static void system_process_input(system_payload_t payload, allocator_t temporary_allocator)
Definition
input.h:8
system_decl_process_input
static system_requirements_declaration_t system_decl_process_input
Definition
input.h:31
Generated on Mon Jul 14 2025 21:56:20 for Subastra by
1.9.8