diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:48:05 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:48:05 +1000 |
commit | dfb6adbcbcc7d50b770b6d5ea82efdd8f8c32e25 (patch) | |
tree | a470b91a90716d7ea46fde53ed395449c24583a2 /archive/src/systems/input.h | |
parent | 54354e32c6498cc7f8839ab4deb1208d37216cc5 (diff) |
delete documentation workflow
Diffstat (limited to 'archive/src/systems/input.h')
-rw-r--r-- | archive/src/systems/input.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/archive/src/systems/input.h b/archive/src/systems/input.h new file mode 100644 index 0000000..c3b2500 --- /dev/null +++ b/archive/src/systems/input.h @@ -0,0 +1,53 @@ +/** + * @brief + */ +#pragma once + +#include "defines.h" +#include "keys.h" + +struct GLFWWindow; + +typedef enum MouseBtn { + MOUSEBTN_LEFT = 0, + MOUSEBTN_RIGHT = 1, + MOUSEBTN_MIDDLE = 2, +} MouseBtn; + +typedef struct mouse_state { + i32 x; + i32 y; + i32 x_delta; + i32 y_delta; + bool prev_pressed_states[3]; + bool cur_pressed_states[3]; +} mouse_state; + +typedef struct Input_State { + struct GLFWwindow* window; + mouse_state mouse; + bool depressed_keys[KEYCODE_MAX]; + bool just_pressed_keys[KEYCODE_MAX]; + bool just_released_keys[KEYCODE_MAX]; +} Input_State; + +/** @brief `key` is currently being held down */ +PUB bool key_is_pressed(keycode key); + +/** @brief `key` was just pressed */ +PUB bool key_just_pressed(keycode key); + +/** @brief `key` was just released */ +PUB bool key_just_released(keycode key); + +// TODO: right btn as well +PUB bool MouseBtn_Held(MouseBtn btn); + +// --- Lifecycle + +PUB bool Input_Init(Input_State* input, struct GLFWwindow* window); +PUB void Input_Shutdown(Input_State* input); + +PUB void Input_Update(Input_State* state); // must be run once per main loop + +PUB mouse_state Input_GetMouseState();
\ No newline at end of file |