From f7bb9e21672566308ab837c370f27c10c154e6fc Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 2 Apr 2021 21:34:29 -0400 Subject: Add custom action mapping to core results of an idea I discussed in IRC changed the way the lookup in the remap file works.. entries consist of 3 int [action, button, prebtn] context look up table is at the beginning action_code contains the (context | CONTEXT_REMAPPED) button_code contains the index of the first remapped action for the matched context [0] CORE_CONTEXT_REMAP(ctx1) offset1=(3), count=(1) [1] CORE_CONTEXT_REMAP(ctx2, offset2=(5), count=(1) [2] sentinel, 0, 0 [3] act0, btn, 0 [4] sentinel 0, 0 [5] act1, btn, 0 [6] sentinel, 0, 0 Note: last entry of each group is always the sentinel [CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE] contexts must match exactly -- re-mapped contexts run before the built in w/ fall through contexts ie. you can't remap std_context and expect it to match std_context actions from the WPS context. -- Done -- Code for reading core remap entries -- Done -- import of core remap entires from disk -- Done -- plugin to set new key mapping (the hard part) The plugin is started and FULLY functional you can add actions and contexts you can change context, action, button, prebtn delete keymap files load keymapfiles save user keymaps test keymaps before applying them loading keymaps to core still requires restart ----------------------------------------------------------------------------------------------- Change-Id: Ib8b88c5ae91af4d540e1829de5db32669cd68203 --- apps/plugins/lib/action_helper.h | 2 +- apps/plugins/lib/action_helper.pl | 2 ++ apps/plugins/lib/button_helper.h | 2 ++ apps/plugins/lib/button_helper.pl | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'apps/plugins/lib') diff --git a/apps/plugins/lib/action_helper.h b/apps/plugins/lib/action_helper.h index 58d9c6c303..53f5c840f8 100644 --- a/apps/plugins/lib/action_helper.h +++ b/apps/plugins/lib/action_helper.h @@ -27,7 +27,7 @@ */ #ifndef _ACTION_HELPER_H_ #define _ACTION_HELPER_H_ - +extern const size_t action_helper_maxbuffer; char* action_name(int action); char* context_name(int context); diff --git a/apps/plugins/lib/action_helper.pl b/apps/plugins/lib/action_helper.pl index 1dfdcfd070..742419e23b 100755 --- a/apps/plugins/lib/action_helper.pl +++ b/apps/plugins/lib/action_helper.pl @@ -140,10 +140,12 @@ printf "#define CONTEXTBUFSZ %d\n\n", $len_max_context; if ($len_max_action > $len_max_context) { + print "const size_t action_helper_maxbuffer = ACTIONBUFSZ;\n"; print "static char name_buf[ACTIONBUFSZ];\n"; } else { + print "const size_t action_helper_maxbuffer = CONTEXTBUFSZ;\n"; print "static char name_buf[CONTEXTBUFSZ];\n"; } print <) { chomp($line); if($line =~ /^#define (BUTTON_[^\s]+) (.+)$/) { $def = "{\"$1\", $2},\n"; + my $slen = length($1) + 1; # NULL terminator + if ($slen > $len_max_button) { $len_max_button = $slen; } $val = $2; if($val =~ /^0/) { @@ -53,6 +56,8 @@ print <