diff options
Diffstat (limited to 'input.h')
| -rw-r--r-- | input.h | 70 |
1 files changed, 30 insertions, 40 deletions
@@ -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 |
