aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action_layer.c10
-rw-r--r--tmk_core/common/action_layer.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index 277a8f5d9..46ea58727 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -88,6 +88,16 @@ void layer_clear(void)
layer_state_set(0);
}
+bool layer_state_is(uint8_t layer)
+{
+ return layer_state_cmp(layer_state, layer);
+}
+
+bool layer_state_cmp(uint32_t cmp_layer_state, uint8_t layer) {
+ if (layer == 0) { return cmp_layer_state == 0; }
+ return (cmp_layer_state & (1UL<<layer)) > 0;
+}
+
void layer_move(uint8_t layer)
{
layer_state_set(1UL<<layer);
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index e71604d87..5fad18cbd 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -51,6 +51,8 @@ void default_layer_xor(uint32_t state);
extern uint32_t layer_state;
void layer_debug(void);
void layer_clear(void);
+bool layer_state_is(uint8_t layer);
+bool layer_state_cmp(uint32_t layer1, uint8_t layer2);
void layer_move(uint8_t layer);
void layer_on(uint8_t layer);
void layer_off(uint8_t layer);