underglow-layer: use behaviors to control RGBs
This commit is contained in:
parent
aa151f7473
commit
f178f86a54
20 changed files with 352 additions and 26 deletions
|
|
@ -24,13 +24,24 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
|
||||
#define UNDERGLOW_LAYER_ENABLED
|
||||
#define LAYER_ID(node) DT_PROP(node, layer_id)
|
||||
#define RGB_BINDINGS(node) DT_PROP(node, bindings)
|
||||
|
||||
static uint32_t zmk_rgbmap[ZMK_RGBMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = {
|
||||
DT_INST_FOREACH_CHILD_SEP(0, RGB_BINDINGS, (, ))};
|
||||
#define TRANSFORMED_RGB_LAYER(node) \
|
||||
{COND_CODE_1(DT_NODE_HAS_PROP(node, bindings), \
|
||||
(LISTIFY(DT_PROP_LEN(node, bindings), ZMK_RGBMAP_EXTRACT_BINDING, (, ), node)), \
|
||||
())}
|
||||
|
||||
#define RGBMAP_VAR(_name, _opts) \
|
||||
static _opts struct zmk_behavior_binding _name[ZMK_RGBMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { \
|
||||
DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP(0, TRANSFORMED_RGB_LAYER, (, ))};
|
||||
|
||||
RGBMAP_VAR(zmk_rgbmap, COND_CODE_1(IS_ENABLED(CONFIG_ZMK_KEYMAP_SETTINGS_STORAGE), (), (const)))
|
||||
|
||||
const int pixel_lookup_table[] = DT_INST_PROP(0, pixel_lookup);
|
||||
|
||||
static int zmk_rgbmap_ids[ZMK_RGBMAP_LAYERS_LEN] = {DT_INST_FOREACH_CHILD_SEP(0, LAYER_ID, (, ))};
|
||||
|
||||
const int rgb_pixel_lookup(int idx) { return pixel_lookup_table[idx]; };
|
||||
|
||||
const int zmk_rgbmap_id(uint8_t layer) {
|
||||
for (uint8_t i = 0; i < ZMK_RGBMAP_LAYERS_LEN; i++) {
|
||||
if (zmk_rgbmap_ids[i] == layer) {
|
||||
|
|
@ -40,7 +51,7 @@ const int zmk_rgbmap_id(uint8_t layer) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
uint32_t *rgb_underglow_get_bindings(uint8_t layer) {
|
||||
const struct zmk_behavior_binding *rgb_underglow_get_bindings(uint8_t layer) {
|
||||
int rgblayer = zmk_rgbmap_id(layer);
|
||||
if (rgblayer == -1) {
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue