blob: b841d6affa8ffb61f2971d9688ca183ef0918c4a (
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
46
47
48
|
Input input_init()
{
Input input = {0};
input.first_mouse = 1;
input.is_running = 1;
return input;
}
void input_update(Input *input)
{
input->last_mouse_pos = input->mouse_pos;
input->mouse_offset = V2_ZERO;
input->mouse_left.last = input->mouse_left.state;
input->mouse_right.last = input->mouse_right.state;
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 r = (key.state == KeyState_PRESS);
return r;
}
B32 key_first_press(Key key)
{
B32 r = ((key.last == KeyState_RELEASE) &&
(key.state == KeyState_PRESS));
return r;
}
B32 key_was_pressed(Key key)
{
B32 r = ((key.last == KeyState_PRESS) &&
(key.state == KeyState_RELEASE));
return r;
}
|