aboutsummaryrefslogtreecommitdiff
path: root/keyboards/crkbd/lib/layer_state_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/crkbd/lib/layer_state_reader.c')
-rw-r--r--keyboards/crkbd/lib/layer_state_reader.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/keyboards/crkbd/lib/layer_state_reader.c b/keyboards/crkbd/lib/layer_state_reader.c
new file mode 100644
index 000000000..63d80b136
--- /dev/null
+++ b/keyboards/crkbd/lib/layer_state_reader.c
@@ -0,0 +1,36 @@
1
2#include QMK_KEYBOARD_H
3#include <stdio.h>
4#include "crkbd.h"
5
6// in the future, should use (1U<<_LAYER_NAME) instead, but needs to be moved to keymap,c
7#define L_BASE 0
8#define L_LOWER 2
9#define L_RAISE 4
10#define L_ADJUST 8
11#define L_ADJUST_TRI 14
12
13char layer_state_str[24];
14
15const char *read_layer_state(void) {
16 switch (layer_state)
17 {
18 case L_BASE:
19 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Default");
20 break;
21 case L_RAISE:
22 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Raise");
23 break;
24 case L_LOWER:
25 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Lower");
26 break;
27 case L_ADJUST:
28 case L_ADJUST_TRI:
29 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Adjust");
30 break;
31 default:
32 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Undef-%ld", layer_state);
33 }
34
35 return layer_state_str;
36}