From 1713482a2af615daa83887278716736799389c3d Mon Sep 17 00:00:00 2001 From: 0scar Date: Wed, 2 Aug 2023 09:22:57 +0200 Subject: Update input handling method --- include/engine/engine.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'include/engine/engine.h') diff --git a/include/engine/engine.h b/include/engine/engine.h index bd961a6..cf2283f 100644 --- a/include/engine/engine.h +++ b/include/engine/engine.h @@ -4,10 +4,11 @@ #include #include +#include #include #include #include -#include +#include #include typedef struct { @@ -29,12 +30,7 @@ typedef struct { typedef struct Window Window; -typedef struct Keybinding { - i32 keycode; - i32 modifiers; - void (*action)(void*); -} Keybinding; - +#define NUM_GLOBAL_BINDINGS 1 typedef struct { void *data; /* Contains textures and such */ u64 data_len; @@ -45,6 +41,7 @@ typedef struct { u64 frame; f32 fps_target; + /* TODO: Move mouse data to input ctx */ v2_i32 mouse_pos; v2_i32 mousedown; @@ -62,7 +59,11 @@ typedef struct { memory *mem; - void *bindings; + i_ctx **bindings; + usize bindings_sz; + usize bindings_len; + + binding_t bindings_global[NUM_GLOBAL_BINDINGS]; } Platform; /* Essential functions */ @@ -81,7 +82,8 @@ void engine_stop(Platform *p); /* Utility functions */ void engine_fps_max(u64 cap); -void engine_bindkey(i32 key, void (*action)(void*)); +void engine_input_ctx_push(i_ctx *ctx); +void engine_input_ctx_pop(void); void render_set_zoom(f32 new_zoom); void render_adjust_zoom(f32 diff); -- cgit v1.3