twn_input.c: fix scancode unbinding (ie make it actually work lol)

This commit is contained in:
wanp 2024-09-20 12:39:37 -03:00
parent db11bb754e
commit 5cc36ab46c

View File

@ -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,13 +167,11 @@ 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]);
size_t shifted_size = elements_after_index * sizeof action->bindings[0];
memmove(action->bindings + index, action->bindings + index + 1, shifted_size);
--action->num_bindings;
}
}
void input_state_init(struct input_state *input) {