[Feature] FS#13884 allow merging imported text keymaps

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Thu, 4 Jun 2026 12:19:19 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit ad05e23b72db68422636fa0ef5b9d838dcc60bcc
Author: William Wilgus <[email protected]>
Date:   Tue May 19 21:23:58 2026 -0400

    [Feature] FS#13884 allow merging imported text keymaps
    
    allows you to import a file and merge text keymaps
    
    pops a yes no prompt to erase existing
    
    duplicates will be overwritten
    
    Change-Id: I0f4425e765f0a2ff6b73b830bcaea1b3f31e83cb

diff --git a/apps/plugins/keyremap.c b/apps/plugins/keyremap.c
index 59a54b59f0..ff10b86bba 100644
--- a/apps/plugins/keyremap.c
+++ b/apps/plugins/keyremap.c
@@ -742,6 +742,19 @@ static int keymap_add_button_entry(int context, int action_code,
             break;
         }
     }
+
+    for (int i = 0; i < ctx_data.act_count; i++)
+    {
+        if (ctx_data.act_map[i].context == context &&
+            ctx_data.act_map[i].map.action_code == action_code)
+        {
+            /*Duplicate -- Update the existing entry */
+            ctx_data.act_map[i].map.button_code = button_code;
+            ctx_data.act_map[i].map.pre_button_code = pre_button_code;
+            return ctx_data.act_count;
+        }
+    }
+
     if (!hasctx || keyremap_buffer.end - sizeof(struct action_mapping_t) < keyremap_buffer.front)
         goto fail;
     keyremap_buffer.end -= sizeof(struct action_mapping_t);
@@ -948,7 +961,11 @@ static int keyremap_import_file(char *filenamebuf, size_t bufsz)
     char *pact;
     int ctx = -1;
 
-    keyremap_reset_buffer();
+    if (ctx_data.ctx_count == 0 || rb->yesno_pop("Delete Current Entries?") == true)
+    {
+        keyremap_reset_buffer();
+    }
+
 next_line:
     while (rb->read_line(fd, filenamebuf, (int) bufsz) > 0)
     {
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs