From 7b3afcaf77f96e7d62f6cd1623ead7f17512d79f Mon Sep 17 00:00:00 2001 From: Omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:47:46 +1100 Subject: repo init. partial port of existing code --- src/systems/input.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/systems/input.h (limited to 'src/systems/input.h') diff --git a/src/systems/input.h b/src/systems/input.h new file mode 100644 index 0000000..c119016 --- /dev/null +++ b/src/systems/input.h @@ -0,0 +1,41 @@ +/** + * @brief + */ +#pragma once + +#include "defines.h" +#include "keys.h" + +struct core; +struct GLFWWindow; + +typedef struct mouse_state { + i32 x; + i32 y; + i32 x_delta; + i32 y_delta; + bool prev_left_btn_pressed; + bool left_btn_pressed; +} 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 */ +bool key_is_pressed(keycode key); + +/** @brief `key` was just pressed */ +bool key_just_pressed(keycode key); + +/** @brief `key` was just released */ +bool key_just_released(keycode key); + +// --- Lifecycle +bool input_system_init(input_state *input, struct GLFWwindow *window); +void input_system_shutdown(input_state *input); +void input_update(input_state *state); \ No newline at end of file -- cgit v1.2.3-70-g09d2