mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[input] Fix imt block management
Reset the blocks completely when loading configs and fix a leftover from when I thought I'd expose the block numbers to bindings but then changed my mind to simply track the base binding.
This commit is contained in:
parent
111e5d923e
commit
1381932552
1 changed files with 18 additions and 4 deletions
|
@ -194,24 +194,37 @@ imt_get_button_block (int count)
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
imt_reset_blocks (void)
|
||||||
|
{
|
||||||
|
DARRAY_RESIZE (&axis_blocks, 0);
|
||||||
|
DARRAY_RESIZE (&button_blocks, 0);
|
||||||
|
for (size_t i = 0; i < in_contexts.size; i++) {
|
||||||
|
for (imt_t *imt = in_contexts.a[i].imts; imt; imt = imt->next) {
|
||||||
|
DARRAY_RESIZE (&imt->axis_bindings, 0);
|
||||||
|
DARRAY_RESIZE (&imt->button_bindings, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
IMT_GetAxisBlock (int num_axes)
|
IMT_GetAxisBlock (int num_axes)
|
||||||
{
|
{
|
||||||
int base = imt_get_axis_block (num_axes);
|
int base = imt_get_axis_block (num_axes);
|
||||||
imt_block_t *block = imt_get_block (&axis_blocks);
|
imt_block_t *block = imt_get_block (&axis_blocks);
|
||||||
block->base = base;
|
block->base = base;
|
||||||
block->count = num_axes;
|
block->count = num_axes;
|
||||||
return block - axis_blocks.a;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
IMT_GetButtonBlock (int num_buttons)
|
IMT_GetButtonBlock (int num_buttons)
|
||||||
{
|
{
|
||||||
int base = imt_get_button_block (num_buttons);
|
int base = imt_get_button_block (num_buttons);
|
||||||
imt_block_t *block = imt_get_block (&button_blocks);
|
imt_block_t *block = imt_get_block (&button_blocks);
|
||||||
block->base = base;
|
block->base = base;
|
||||||
block->count = num_buttons;
|
block->count = num_buttons;
|
||||||
return block - button_blocks.a;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -749,6 +762,7 @@ IMT_SaveButtonConfig (plitem_t *buttons, int button_ind, int dev_button)
|
||||||
void
|
void
|
||||||
IMT_LoadConfig (plitem_t *config)
|
IMT_LoadConfig (plitem_t *config)
|
||||||
{
|
{
|
||||||
|
imt_reset_blocks ();
|
||||||
imt_drop_all_f ();
|
imt_drop_all_f ();
|
||||||
|
|
||||||
plitem_t *ctx_list = PL_ObjectForKey (config, "contexts");
|
plitem_t *ctx_list = PL_ObjectForKey (config, "contexts");
|
||||||
|
|
Loading…
Reference in a new issue