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/action.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'apps/action.h') diff --git a/apps/action.h b/apps/action.h index 3217ce4d6f..7fadc015c8 100644 --- a/apps/action.h +++ b/apps/action.h @@ -28,10 +28,13 @@ #define TIMEOUT_NOBLOCK 0 #define CONTEXT_STOPSEARCHING 0xFFFFFFFF + #define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */ #define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */ #define CONTEXT_CUSTOM2 0x20000000 /* as above */ #define CONTEXT_PLUGIN 0x10000000 /* for plugins using get_custom_action */ +#define CONTEXT_REMAPPED 0x08000000 /* marker for key remap context table */ +#define CORE_CONTEXT_REMAP(context) (CONTEXT_REMAPPED | context) #ifdef HAVE_LOCKED_ACTIONS #define CONTEXT_LOCKED 0x04000000 /* flag to use alternate keymap when screen is locked */ #endif @@ -415,6 +418,11 @@ typedef struct bool repeated; bool wait_for_release; +#ifndef DISABLE_ACTION_REMAP + bool check_remap; + struct button_mapping* core_keymap; +#endif + #ifdef HAVE_TOUCHSCREEN bool ts_short_press; int ts_data; @@ -441,6 +449,9 @@ bool action_userabort(int timeout); /* no other code should need this apart from action.c */ 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); + /* 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 */ #define ACTION_REMOTE 0x1 /* remote was pressed */ -- cgit v1.2.3