summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2023-08-15 07:10:08 +0000
committer0scar <qgt268@alumni.ku.dk>2023-08-15 07:10:08 +0000
commit479b155fa1624ccbb3df19d827088c4093b5b6a4 (patch)
tree8c359954ae7fb87ca5181c903040d8dd2296c574 /include
parent4abb242204e117edfec86a24bbecc689ace6a9a7 (diff)
Move input stuffs into input.{h,c}
Diffstat (limited to 'include')
-rw-r--r--include/engine/engine.h3
-rw-r--r--include/engine/input.h41
2 files changed, 14 insertions, 30 deletions
diff --git a/include/engine/engine.h b/include/engine/engine.h
index d3c3e87..02b5703 100644
--- a/include/engine/engine.h
+++ b/include/engine/engine.h
@@ -82,9 +82,6 @@ void engine_stop(Platform *p);
/* Utility functions */
void engine_fps_max(u64 cap);
-void engine_input_ctx_push(i_ctx *ctx);
-void engine_input_ctx_pop(void);
-void engine_input_ctx_reset(void);
void render_set_zoom(f32 new_zoom);
void render_adjust_zoom(f32 diff);
diff --git a/include/engine/input.h b/include/engine/input.h
index 12b1bba..767de1e 100644
--- a/include/engine/input.h
+++ b/include/engine/input.h
@@ -48,9 +48,23 @@ typedef struct i_ctx {
} i_ctx;
void i_ctx_t_free(i_ctx* c);
+/* Executes all callbacks that has been pushed onto the callstack and resets the
+ * callstack */
void i_flush_bindings(usize numcalls, void* state_mem, input_callback_t* c[]);
action_t i_get_action(const i_ctx *restrict ctx, u32 time, scancode_t scancode);
+void i_ctx_push(i_ctx *ctx);
+void i_ctx_pop(void);
+void i_ctx_reset(void);
+
+/* Finds and updates the scancode of a binding with the given action in ctx */
+void i_bind_ctx(i_ctx *c, scancode_t s, action_t *a);
+void i_bind_ctx_alt(i_ctx *c, scancode_t s, action_t *a);
+
+/* Update the scancode of a binding */
+void i_bind(binding_t *b, scancode_t s);
+void i_bind_alt(binding_t *b, scancode_t s);
+
#define BindAction(key, altkey, f_action) \
(binding_t){\
.action = (action_t){.action = {\
@@ -77,32 +91,5 @@ action_t i_get_action(const i_ctx *restrict ctx, u32 time, scancode_t scancode);
.since_last_activation = 0\
}
-// Lazy binds, used internally
-#define BindActionLazy(key, altkey, action_str) \
- (binding_t){\
- .action = (action_t){.action = {\
- .type = InputType_action,\
- .callback = NULL,\
- .callback_str = strdup( action_str ),\
- }},\
- .scancode = key,\
- .scancode_alt = altkey,\
- .since_last_activation = 0\
-}
-
-#define BindStateLazy(key, altkey, _activate_str , _deactivate_str) \
- (binding_t){\
- .action = (action_t){.state = {\
- .type = InputType_state,\
- .activate = NULL,\
- .deactivate = NULL,\
- .activate_str = strdup( _activate_str ),\
- .deactivate_str = strdup( _deactivate_str ),\
- }},\
- .scancode = key,\
- .scancode_alt = altkey,\
- .since_last_activation = 0\
-}
-
#endif