key remap: simplify and use movable allocations

Have action.c control the key remap buflib allocation so that it can
be made movable. With memory management offloaded, core_keymap.c only
needs to deal with loading keymap files. Simplify the code there and
use buflib pinning so the file can be loaded directly into the buffer.

Change-Id: Ia654cc05ce6b286f96c1031fa4f7d4b3859a2c1a
This commit is contained in:
Aidan MacDonald 2022-04-03 13:48:52 +01:00
parent f47aa584a8
commit e4aec7d648
4 changed files with 131 additions and 165 deletions

View file

@ -419,7 +419,7 @@ typedef struct
bool wait_for_release;
#ifndef DISABLE_ACTION_REMAP
struct button_mapping* core_keymap;
int key_remap;
#endif
#ifdef HAVE_TOUCHSCREEN
@ -449,7 +449,9 @@ bool action_userabort(int timeout);
const struct button_mapping* get_context_mapping(int context);
/* load a key map to allow buttons for actions to be remapped see: core_keymap */
int action_set_keymap(struct button_mapping* core_button_map, int count);
int action_set_keymap(struct button_mapping* core_keymap, int count);
/* load keymap in a handle: takes ownership of the handle on success */
int action_set_keymap_handle(int handle, int count);
/* returns the status code variable from action.c for the button just pressed
If button != NULL it will be set to the actual button code */