1
0
Fork 0
forked from len0rd/rockbox

Core Keyremap Allow setting keymap from plugin

Allow setting and removing keyremap on the fly

It was pretty annoying trying to work out a keyremap with a restart
required to set the remap and was quite annoying when I was no
longer able to navigate to the plugin or filebrowser due to setting
the wrong remap

now you can try out a keymap and if it doesn't work a restart will
sort things out

Change-Id: I848fb3bd759f9684ac2497324a371f92b7464f7b
This commit is contained in:
William Wilgus 2022-02-23 21:26:37 -05:00
parent f7bb9e2167
commit 295ec3790d
5 changed files with 81 additions and 10 deletions

View file

@ -105,7 +105,9 @@ enum {
M_SAVEKEYS,
M_LOADKEYS,
M_DELKEYS,
M_TMPCORE,
M_SETCORE,
M_DELCORE,
M_EXIT,
M_LAST_MAINITEM, //MAIN MENU ITEM COUNT
/*Menus not directly accessible from main menu*/
@ -126,7 +128,9 @@ MENU_ITEM(M_RESETKEYS, "Reset Keymap", 1),
MENU_ITEM(M_SAVEKEYS, "Save Keymap", 1),
MENU_ITEM(M_LOADKEYS, "Load Keymaps", 1),
MENU_ITEM(M_DELKEYS, "Delete Keymaps", 1),
MENU_ITEM(M_TMPCORE, "Temp Core Remap", 1),
MENU_ITEM(M_SETCORE, "Set Core Remap", 1),
MENU_ITEM(M_DELCORE, "Delete Core Remap", 1),
MENU_ITEM(M_EXIT, ID2P(LANG_MENU_QUIT), 0),
MENU_ITEM(M_ACTIONS, "Actions", LAST_ACTION_PLACEHOLDER),
MENU_ITEM(M_BUTTONS, "Buttons", -1), /* Set at runtime in plugin_start: */
@ -878,6 +882,17 @@ int menu_action_root(int *action, int selected_item, bool* exit, struct gui_sync
{
keyset.view_lastcol = -1;
}
else if (cur->menuid == MENU_ID(M_TMPCORE))
{
int entry_count;/* (ctx_count + ctx_count + act_count + 1) */
struct button_mapping *keymap = keyremap_create_temp(&entry_count);
if (rb->core_set_keyremap(keymap, entry_count) >= 0)
rb->splash(HZ *2, "Keymap Applied");
else
rb->splash(HZ *2, "Error Applying");
goto default_handler;
}
else if (cur->menuid == MENU_ID(M_SETCORE))
{
if (rb->file_exists(CORE_KEYREMAP_FILE) && 0 == core_savecount++)
@ -887,7 +902,25 @@ int menu_action_root(int *action, int selected_item, bool* exit, struct gui_sync
if (keyremap_save_current(CORE_KEYREMAP_FILE) == 0)
rb->splash(HZ *2, "Error Saving");
else
rb->splash(HZ *2, "Saved, Restart Device");
{
rb->splash(HZ *2, "Saved");
int entry_count;/* (ctx_count + ctx_count + act_count + 1) */
struct button_mapping *keymap = keyremap_create_temp(&entry_count);
rb->core_set_keyremap(keymap, entry_count);
}
goto default_handler;
}
else if (cur->menuid == MENU_ID(M_DELCORE))
{
rb->core_set_keyremap(NULL, -1);
if (rb->file_exists(CORE_KEYREMAP_FILE))
{
rb->rename(CORE_KEYREMAP_FILE, KMFDIR "/core_deleted" KMFEXT2);
rb->splash(HZ *2, "Removed");
}
else
rb->splash(HZ *2, "Error Removing");
goto default_handler;
}
else if (cur->menuid == MENU_ID(M_SAVEKEYS))