diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-08-15 07:10:08 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2023-08-15 07:10:08 +0000 |
| commit | 479b155fa1624ccbb3df19d827088c4093b5b6a4 (patch) | |
| tree | 8c359954ae7fb87ca5181c903040d8dd2296c574 /include/engine/input.h | |
| parent | 4abb242204e117edfec86a24bbecc689ace6a9a7 (diff) | |
Move input stuffs into input.{h,c}
Diffstat (limited to 'include/engine/input.h')
| -rw-r--r-- | include/engine/input.h | 41 |
1 files changed, 14 insertions, 27 deletions
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 |
