Input init_input() { Input in; MEM0STRUCT(&in); in.first_mouse = 1; return in; } /* NOTE(pryazha): Updates the last states of keys, mouse position and offset. * Should be called every frame */ void update_input(Input *in) { 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 is_key_down(Key key) { B32 r = (key.state == KeyState_PRESS); return r; } B32 is_key_pressed(Key key) { B32 r = ((key.last == KeyState_RELEASE) && (key.state == KeyState_PRESS)); return r; } B32 was_key_pressed(Key key) { B32 r = ((key.last == KeyState_PRESS) && (key.state == KeyState_RELEASE)); return r; }