summaryrefslogtreecommitdiff
path: root/apps/core_keymap.h
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-04-02 21:34:29 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-02-23 08:47:12 -0500
commitf7bb9e21672566308ab837c370f27c10c154e6fc (patch)
tree688aa4e1a44572452ee192838b0af510b57ce770 /apps/core_keymap.h
parent7952687185aa27fcecc0924efa45c0e64e0ed4fe (diff)
downloadrockbox-f7bb9e21672566308ab837c370f27c10c154e6fc.tar.gz
rockbox-f7bb9e21672566308ab837c370f27c10c154e6fc.zip
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
Diffstat (limited to 'apps/core_keymap.h')
-rw-r--r--apps/core_keymap.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/apps/core_keymap.h b/apps/core_keymap.h
new file mode 100644
index 0000000000..39d35e9cd9
--- /dev/null
+++ b/apps/core_keymap.h
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2020 by William Wilgus
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef CORE_KEYMAP_H
22#define CORE_KEYMAP_H
23
24#include <stdbool.h>
25#include <inttypes.h>
26#include "config.h"
27#define KEYREMAP_VERSION 1
28#define KEYREMAP_HEADERID (LAST_ACTION_PLACEHOLDER | (TARGET_ID << 8))
29
30/* If exists remap file will be loaded at startup */
31#define CORE_KEYREMAP_FILE ROCKBOX_DIR "/keyremap.kmf"
32
33/* open_key_remap(filename , *fd (you must close file_descriptor), *fsize)
34 * checks/strips header and returns remaining count
35 * fd is opened and set to first record
36 * filesize contains the size of the remaining records
37*/
38int open_key_remap(const char *filename, int *fd, size_t *filesize);
39
40/* load a remap file to allow buttons for actions to be remapped */
41int core_load_key_remap(const char *filename);
42
43/*
44 * entries consist of 3 int [action, button, prebtn]
45 * the header (VERSION, LAST_DEFINED_ACTION, count) is stripped by open_key_remap
46 *
47 * context look up table is at the beginning
48 * action_code contains (context | CONTEXT_REMAPPED)
49 * button_code contains index of first remapped action for the matched context
50 * prebtn_code contains count of actions in this remapped context
51 * [-1] REMAP_VERSION, REMAP_HEADERID, entry count(9) / DISCARDED AFTER LOAD
52 * [0] CORE_CONTEXT_REMAP(ctx1), offset1=(3), count=(1)
53 * [1] CORE_CONTEXT_REMAP(ctx2, offset2=(5), count=(2)
54 * [2] sentinel, 0, 0
55 * [3] act0, btn, 0
56 * [4] sentinel 0, 0
57 * [5] act1, btn, 0
58 * [6] act2, btn1
59 * [7] sentinel, 0, 0
60 *
61 * Note:
62 * last entry of each group is always the sentinel [CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE]
63 * contexts must match exactly -- re-mapped contexts run before the built in w/ fall through contexts
64 * ie. you can't remap std_context and expect it to match std_context actions from the WPS context.
65 */
66
67#endif /* CORE_KEYMAP_H */
68