From 34821e9fefb0d7cbf9e72a2457b2901edbbe03bb Mon Sep 17 00:00:00 2001 From: pryazha Date: Thu, 20 Feb 2025 15:10:11 +0500 Subject: initial --- prge_input.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 prge_input.c (limited to 'prge_input.c') diff --git a/prge_input.c b/prge_input.c new file mode 100644 index 0000000..e295ebc --- /dev/null +++ b/prge_input.c @@ -0,0 +1,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); +} -- cgit v1.2.3-70-g09d2