diff options
Diffstat (limited to 'prge_input.c')
-rw-r--r-- | prge_input.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/prge_input.c b/prge_input.c index b841d6a..74de9e5 100644 --- a/prge_input.c +++ b/prge_input.c @@ -1,48 +1,51 @@ -Input input_init() +Input init_input() { - Input input = {0}; - input.first_mouse = 1; - input.is_running = 1; - return input; + Input in; + + MEM0STRUCT(&in); + + in.first_mouse = 1; + + return in; } -void input_update(Input *input) +/* NOTE(pryazha): Updates the last states of keys, mouse position and offset. + * Should be called every frame */ +void update_input(Input *in) { - 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; + in->last_mouse_pos = in->mouse_pos; + in->mouse_offset = V2_ZERO; + in->mouse_left.last = in->mouse_left.state; + in->mouse_right.last = in->mouse_right.state; + + in->move_right.last = in->move_right.state; + in->move_forward.last = in->move_forward.state; + in->move_left.last = in->move_left.state; + in->move_backward.last = in->move_backward.state; + in->move_up.last = in->move_up.state; + in->move_down.last = in->move_down.state; + in->jump.last = in->jump.state; + in->action_right.last = in->action_right.state; + in->action_up.last = in->action_up.state; + in->action_left.last = in->action_left.state; + in->action_down.last = in->action_down.state; + in->exit.last = in->exit.state; } -B32 key_is_pressed(Key key) +B32 is_key_down(Key key) { B32 r = (key.state == KeyState_PRESS); return r; } -B32 key_first_press(Key key) +B32 is_key_pressed(Key key) { - B32 r = ((key.last == KeyState_RELEASE) && - (key.state == KeyState_PRESS)); + B32 r = ((key.last == KeyState_RELEASE) && (key.state == KeyState_PRESS)); return r; } -B32 key_was_pressed(Key key) +B32 was_key_pressed(Key key) { - B32 r = ((key.last == KeyState_PRESS) && - (key.state == KeyState_RELEASE)); + B32 r = ((key.last == KeyState_PRESS) && (key.state == KeyState_RELEASE)); return r; } |