blob: e295ebc49250122284a20ca8bea84b2acdab330c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
Input input_init()
{
Input input = {0};
input.first_mouse = 1;
input.is_running = 1;
return(input);
}
void input_update(Input *input)
{
input->mouse_offset = V2_ZERO;
input->move_right.last = input->move_right.state;
input->move_forward.last = input->move_forward.state;
input->move_left.last = input->move_left.state;
input->move_backward.last = input->move_backward.state;
input->move_up.last = input->move_up.state;
input->move_down.last = input->move_down.state;
input->jump.last = input->jump.state;
input->action_right.last = input->action_right.state;
input->action_up.last = input->action_up.state;
input->action_left.last = input->action_left.state;
input->action_down.last = input->action_down.state;
input->exit.last = input->exit.state;
}
B32 key_is_pressed(Key key)
{
B32 result = (key.state == KeyState_PRESS);
return(result);
}
B32 key_first_press(Key key)
{
B32 result = ((key.last == KeyState_RELEASE) &&
(key.state == KeyState_PRESS));
return(result);
}
B32 key_was_pressed(Key key)
{
B32 result = ((key.last == KeyState_PRESS) &&
(key.state == KeyState_RELEASE));
return(result);
}
|