Skip to content

Commit 76455f2

Browse files
committed
fix: resolve split peripheral linker errors on non-split boards
- rgb_underglow_layer.c: fix #if guards to use CONFIG_ZMK_SPLIT check, non-split boards now use zmk_keymap_highest_layer_active() directly - peripheral_layers_nonsplit.c: add stub implementations of split peripheral layer functions for non-split builds (linker needs symbols even though code paths are never reached at runtime)
1 parent dd175dc commit 76455f2

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2020 The ZMK Contributors
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
/*
8+
* Stub implementation of peripheral_layers for non-split keyboards.
9+
* The split_peripheral_layer_changed event is never raised on non-split boards,
10+
* so these functions are never called at runtime, but the linker needs the symbols.
11+
*/
12+
13+
#include <stdint.h>
14+
#include <stdbool.h>
15+
16+
void set_peripheral_layers_state(uint32_t new_layers) {}
17+
18+
bool peripheral_layer_active(uint8_t layer) { return false; }
19+
20+
uint8_t peripheral_highest_layer_active(void) { return 0; }

app/src/rgb_underglow_layer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
1515
#include <zmk/keymap.h>
1616
#include <zmk/rgb_underglow_layer.h>
1717

18-
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
18+
#if IS_ENABLED(CONFIG_ZMK_SPLIT) && !IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
1919
#include <zmk/split/peripheral_layers.h>
2020
#endif
2121

@@ -75,10 +75,10 @@ uint8_t rgb_underglow_top_layer_with_state(uint32_t state_to_test) {
7575
}
7676

7777
uint8_t rgb_underglow_top_layer(void) {
78-
#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
79-
return zmk_keymap_highest_layer_active();
80-
#else
78+
#if IS_ENABLED(CONFIG_ZMK_SPLIT) && !IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
8179
return peripheral_highest_layer_active();
80+
#else
81+
return zmk_keymap_highest_layer_active();
8282
#endif
8383
}
84-
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
84+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

0 commit comments

Comments
 (0)