From 5cc36ab46c7c02d10d591f19d598fe269b4266c2 Mon Sep 17 00:00:00 2001 From: wanp Date: Fri, 20 Sep 2024 12:39:37 -0300 Subject: [PATCH] twn_input.c: fix scancode unbinding (ie make it actually work lol) --- src/twn_input.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/twn_input.c b/src/twn_input.c index a589720..63d1510 100644 --- a/src/twn_input.c +++ b/src/twn_input.c @@ -156,6 +156,7 @@ static void input_unbind_code_from_action(struct input_state *input, break; } + /* stop early, this won't change */ if (is_bound) break; } @@ -166,12 +167,10 @@ static void input_unbind_code_from_action(struct input_state *input, } /* remove the element to unbind and shift the rest so there isn't a gap */ - if (action->num_bindings == SDL_arraysize(action->bindings)) { - size_t elements_after_index = action->num_bindings - index; - size_t shifted_size = elements_after_index * (sizeof action->bindings[0]); - memmove(action->bindings + index, action->bindings + index + 1, shifted_size); - --action->num_bindings; - } + size_t elements_after_index = action->num_bindings - index; + size_t shifted_size = elements_after_index * sizeof action->bindings[0]; + memmove(action->bindings + index, action->bindings + index + 1, shifted_size); + --action->num_bindings; }