summaryrefslogtreecommitdiff
path: root/input.h
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-10-12 15:25:23 +0500
committerpryazha <pryadeiniv@mail.ru>2025-10-12 15:25:23 +0500
commit818f818f583881156eb279c71b1359bf2c4f3580 (patch)
tree874e8d2fdc5334bc70925aa87923791f7662ddb8 /input.h
parent3cf987880e384140bf996c37f820ddeea38bc60e (diff)
change identation, maybe will change back, add own gl functions loading, and glx example
Diffstat (limited to 'input.h')
-rw-r--r--input.h70
1 files changed, 30 insertions, 40 deletions
diff --git a/input.h b/input.h
index 28090e9..b14dd60 100644
--- a/input.h
+++ b/input.h
@@ -1,46 +1,36 @@
-input_t init_input()
-{
- input_t input = {0};
- input.mouse.first = 1;
- return input;
-}
+#ifndef input_h
+#define input_h
-void update_input(input_t *input)
-{
- input->mouse.last = input->mouse.pos;
- input->mouse.offset = V2_ZERO;
- input->mouse.left.last = input->mouse.left.state;
- input->mouse.right.last = input->mouse.right.state;
+#include "prbm.h"
- 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;
+struct key {
+ i32 last;
+ i32 now;
+};
- 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;
-}
+struct mouse {
+ v2 pos;
+ v2 last;
+ v2 offset;
+ struct key left;
+ struct key right;
+ i32 first;
+ i32 capture;
+};
-i32 is_key_down(prge_key_t key)
-{
- i32 result = (key.state == key_state_press);
- return result;
-}
+struct input {
+ struct mouse mouse;
+ struct key right;
+ struct key left;
+ struct key up;
+ struct key down;
+ struct key forward;
+ struct key backward;
+};
-i32 is_key_pressed(prge_key_t key)
-{
- i32 result = ((key.last == key_state_release) && (key.state == key_state_press));
- return result;
-}
+struct input init_input(void);
+void update_input(struct input *input);
+i32 key_down(struct key key);
+i32 key_first(struct key key);
-i32 was_key_pressed(prge_key_t key)
-{
- i32 result = ((key.last == key_state_press) && (key.state == key_state_release));
- return result;
-}
+#endif