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_req_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
#endif
require.h
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_req_t
Definition
require.h:51
system_req_t::input
input_t * input
Definition
require.h:62
system_req_t::rendering_ctx
rendering_ctx_t * rendering_ctx
Definition
require.h:63
system_process_input
static void system_process_input(system_req_t payload, allocator_t temporary_allocator)
Definition
input.h:8
Generated on Wed Jul 2 2025 16:57:45 for Subastra by
1.9.8