aboutsummaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorGravatar Konstantin Đorđević <vomindoraan@gmail.com>2020-07-16 14:27:55 +0200
committerGravatar GitHub <noreply@github.com>2020-07-16 22:27:55 +1000
commit61b64bb82a93c6d1441f07655a5e20b59a15fd29 (patch)
tree6821f6754bdcafd91fb16556f08e2e7ebf361bdf /quantum
parentf11437aef392dc44573bf45a738ae758784d2f1b (diff)
downloadqmk_firmware-61b64bb82a93c6d1441f07655a5e20b59a15fd29.tar.gz
Redefine IS_LAYER_ON/OFF() as aliases for existing layer functions (#6352)
* Add IS_LAYER_ON_STATE()/IS_LAYER_OFF_STATE() macros * Add docs for IS_LAYER_ON/OFF(_STATE) macros * Remove IS_LAYER_ON/OFF_STATE redefinition in userspace * Run clang-format on quantum/quantum.h * Redefine IS_LAYER_ON/OFF(_STATE) as aliases of existing layer functions Also update relevant doc entries. Needs testing to check if this breaks existing IS_LAYER_ON/OFF usage in certain edge cases (namely calling the macros with 0). * Reformat layer check function docs
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 17d1d41cc..51deac0cd 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -249,8 +249,11 @@ void set_single_persistent_default_layer(uint8_t default_layer);
void tap_random_base64(void);
-#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
-#define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
+#define IS_LAYER_ON(layer) layer_state_is(layer)
+#define IS_LAYER_OFF(layer) !layer_state_is(layer)
+
+#define IS_LAYER_ON_STATE(state, layer) layer_state_cmp(state, layer)
+#define IS_LAYER_OFF_STATE(state, layer) !layer_state_cmp(state, layer)
void matrix_init_kb(void);
void matrix_scan_kb(void);