From a9713cdda4df398cbcb3131cce47cdb6e6d87386 Mon Sep 17 00:00:00 2001 From: onelin Date: Thu, 13 Mar 2025 18:48:58 +0100 Subject: Use nanoseconds for time measurements --- src/ctrl/include/engine/ctrl/input.h | 2 +- src/ctrl/src/input.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ctrl') diff --git a/src/ctrl/include/engine/ctrl/input.h b/src/ctrl/include/engine/ctrl/input.h index 73a265b..960428c 100644 --- a/src/ctrl/include/engine/ctrl/input.h +++ b/src/ctrl/include/engine/ctrl/input.h @@ -55,7 +55,7 @@ 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(f64 dt, usize numcalls, input_callback_t* c[], void* state_mem); -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, u64 time, scancode_t scancode); void key_callback(void* window, int key, int scancode, int action, int mods); diff --git a/src/ctrl/src/input.c b/src/ctrl/src/input.c index 4b878d1..4d29770 100644 --- a/src/ctrl/src/input.c +++ b/src/ctrl/src/input.c @@ -42,7 +42,7 @@ void key_callback(void* window, int key, int scancode, int action, int mods) { const i_ctx* bindings = *GLOBAL_PLATFORM->bindings; const usize bindings_len = GLOBAL_PLATFORM->bindings_len; - const f64 now = get_time(); + const u64 now = get_time(); for (usize b = 0; b < bindings_len; b++) { const action_t a = i_get_action(&bindings[b], now, scancode); @@ -190,6 +190,7 @@ bool i_update_unique_binding(i_ctx* ctx, binding_t* binding) { return false; } +/* Call binding callbacks of respective bindings */ void i_flush_bindings(f64 dt, usize numcalls, input_callback_t* c[], void* state_mem) { for (usize i = 0; i < numcalls; i++) { (c[i])(state_mem); @@ -198,7 +199,7 @@ void i_flush_bindings(f64 dt, usize numcalls, input_callback_t* c[], void* state callbacks_len = 0; } -action_t i_get_action(const i_ctx* restrict ctx, u32 time, +action_t i_get_action(const i_ctx* restrict ctx, u64 time, scancode_t scancode) { isize idx = 0; -- cgit v1.3