summaryrefslogtreecommitdiff
path: root/include/engine/input.h
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2023-10-30 22:11:54 +0000
committer0scar <qgt268@alumni.ku.dk>2023-10-30 22:12:34 +0000
commit5c0311ff3095a5dd30fb15db54aa394498dd2bcf (patch)
tree2abb0e3dc145e4372fcf07aeeb736279d00471e5 /include/engine/input.h
parent3e3fe3d42206dc14baca2f50445e6fe8bb2d2480 (diff)
The great formattening!
Diffstat (limited to 'include/engine/input.h')
-rw-r--r--include/engine/input.h66
1 files changed, 32 insertions, 34 deletions
diff --git a/include/engine/input.h b/include/engine/input.h
index 767de1e..c93d74d 100644
--- a/include/engine/input.h
+++ b/include/engine/input.h
@@ -35,7 +35,7 @@ typedef struct binding_t {
action_t action;
// Change type depending on input handling back-end. like u16 for GLFW_KEY
- //enum SDL_Scancode keycode;
+ // enum SDL_Scancode keycode;
scancode_t scancode;
scancode_t scancode_alt;
@@ -43,53 +43,51 @@ typedef struct binding_t {
} binding_t;
typedef struct i_ctx {
- binding_t* bindings;
- isize len;
+ binding_t* bindings;
+ isize len;
} 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);
+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_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);
+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);
+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 = {\
- .type = InputType_action,\
- .callback = (input_callback_t*)&f_action,\
- .callback_str = strdup( #f_action ),\
- }},\
- .scancode = key,\
- .scancode_alt = altkey,\
- .since_last_activation = 0\
-}
-
-#define BindState(key, altkey, f_activate, f_deactivate) \
- (binding_t){\
- .action = (action_t){.state = {\
- .type = InputType_state,\
- .activate = (input_callback_t*)&f_activate,\
- .deactivate = (input_callback_t*)&f_deactivate,\
- .activate_str = strdup( #f_activate ),\
- .deactivate_str = strdup( #f_deactivate ),\
- }},\
- .scancode = key,\
- .scancode_alt = altkey,\
- .since_last_activation = 0\
-}
+#define BindAction(key, altkey, f_action) \
+ (binding_t) { \
+ .action = (action_t){.action = \
+ { \
+ .type = InputType_action, \
+ .callback = (input_callback_t*)&f_action, \
+ .callback_str = strdup(#f_action), \
+ }}, \
+ .scancode = key, .scancode_alt = altkey, .since_last_activation = 0 \
+ }
+#define BindState(key, altkey, f_activate, f_deactivate) \
+ (binding_t) { \
+ .action = \
+ (action_t){.state = \
+ { \
+ .type = InputType_state, \
+ .activate = (input_callback_t*)&f_activate, \
+ .deactivate = (input_callback_t*)&f_deactivate, \
+ .activate_str = strdup(#f_activate), \
+ .deactivate_str = strdup(#f_deactivate), \
+ }}, \
+ .scancode = key, .scancode_alt = altkey, .since_last_activation = 0 \
+ }
#endif