From f5e5a6fdf58f3135f3211135bfbcb6e70630309f Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 26 Jul 2024 18:58:43 +1000 Subject: fix glfw get key range so it doesnt panic on mac --- src/systems/input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/systems') diff --git a/src/systems/input.c b/src/systems/input.c index fa76273..b5cdcdb 100644 --- a/src/systems/input.c +++ b/src/systems/input.c @@ -4,6 +4,7 @@ #include #include +#include "keys.h" #include "log.h" static Input_State *g_input; // Use a global to simplify caller code @@ -14,7 +15,7 @@ bool Input_Init(Input_State *input, GLFWwindow *window) { input->window = window; // Set everything to false. Could just set memory to zero but where's the fun in that - for (int i = 0; i < KEYCODE_MAX; i++) { + for (int i = KEYCODE_SPACE; i < KEYCODE_MAX; i++) { input->depressed_keys[i] = false; input->just_pressed_keys[i] = false; input->just_released_keys[i] = false; @@ -37,7 +38,7 @@ void Input_Update(Input_State *input) { // if we go from un-pressed -> pressed, set as "just pressed" // if we go from pressed -> un-pressed, set as "just released" - for (int i = 0; i < KEYCODE_MAX; i++) { + for (int i = KEYCODE_SPACE; i < KEYCODE_MAX; i++) { bool new_state = false; if (glfwGetKey(input->window, i) == GLFW_PRESS) { new_state = true; -- cgit v1.2.3-70-g09d2