aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/common/action_layer.h
diff options
context:
space:
mode:
authorAlex Ong <the.onga@gmail.com>2020-05-11 10:04:38 +1000
committerGitHub <noreply@github.com>2020-05-11 01:04:38 +0100
commit361ac2f32ac8b906dbb29cd0a6c5f971dad298c3 (patch)
treed4b8a2e2cfc464314a713f00294881fefa67f983 /tmk_core/common/action_layer.h
parentd15a60d2d318ede79746c09d5beb79ba72037f30 (diff)
downloadfirmware-361ac2f32ac8b906dbb29cd0a6c5f971dad298c3.tar.gz
firmware-361ac2f32ac8b906dbb29cd0a6c5f971dad298c3.tar.bz2
firmware-361ac2f32ac8b906dbb29cd0a6c5f971dad298c3.zip
Optimization for scanning less layers. (#8311)
* Optimization for scanning less layers. * Rename NUM_LAYERS to MAX_LAYER.
Diffstat (limited to 'tmk_core/common/action_layer.h')
-rw-r--r--tmk_core/common/action_layer.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index c283d2623..16922c1ff 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -23,12 +23,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(LAYER_STATE_8BIT)
typedef uint8_t layer_state_t;
+# define MAX_LAYER_BITS 3
+# ifndef MAX_LAYER
+# define MAX_LAYER 8
+# endif
# define get_highest_layer(state) biton(state)
#elif defined(LAYER_STATE_16BIT)
typedef uint16_t layer_state_t;
+# define MAX_LAYER_BITS 4
+# ifndef MAX_LAYER
+# define MAX_LAYER 16
+# endif
# define get_highest_layer(state) biton16(state)
#else
typedef uint32_t layer_state_t;
+# define MAX_LAYER_BITS 5
+# ifndef MAX_LAYER
+# define MAX_LAYER 32
+# endif
# define get_highest_layer(state) biton32(state)
#endif
@@ -96,8 +108,7 @@ layer_state_t layer_state_set_kb(layer_state_t state);
/* pressed actions cache */
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
-/* The number of bits needed to represent the layer number: log2(32). */
-# define MAX_LAYER_BITS 5
+
void update_source_layers_cache(keypos_t key, uint8_t layer);
uint8_t read_source_layers_cache(keypos_t key);
#endif