summaryrefslogtreecommitdiff
path: root/prge_input.c
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-02-20 15:10:11 +0500
committerpryazha <pryadeiniv@mail.ru>2025-02-20 15:10:11 +0500
commit34821e9fefb0d7cbf9e72a2457b2901edbbe03bb (patch)
tree59ec69f7d19aa48091b3d39ad0dfd6b26bacb88b /prge_input.c
initial
Diffstat (limited to 'prge_input.c')
-rw-r--r--prge_input.c45
1 files changed, 45 insertions, 0 deletions
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);
+}