From: Colin T.A. Gray Date: Tue, 5 Dec 2017 18:59:53 +0000 (-0700) Subject: helper to compare current layer_state to user layer X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1620d78e73f8e01ed1d48255c655d9eb6cc1b135;p=qmk_firmware.git helper to compare current layer_state to user layer Performs the same bit comparison that the layer_move functions perform --- 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< 0; +} + void layer_move(uint8_t layer) { layer_state_set(1UL<