twn_input.c: fix scancode unbinding (ie make it actually work lol)
This commit is contained in:
parent
db11bb754e
commit
5cc36ab46c
@ -156,6 +156,7 @@ static void input_unbind_code_from_action(struct input_state *input,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* stop early, this won't change */
|
||||||
if (is_bound)
|
if (is_bound)
|
||||||
break;
|
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 */
|
/* 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 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);
|
memmove(action->bindings + index, action->bindings + index + 1, shifted_size);
|
||||||
--action->num_bindings;
|
--action->num_bindings;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user